Misc Amount is not Reflecting in Invoice Header and Invoice Detail

Hello All, I wanted to automate Misc Charges , so i created Data directives in InvcDtl , and Called Bo Method to Create a New Misc Line for Invoice , the Line is created . However the Miscamt is not Reflecting in InvcDtl and Invcheader , how to update the Miscamt in header and Lines?

image

1 Like

Do not invoke BOs in Data Directives, I hope you meant Method Directive. One should never invoke BOs from a Data Directive, hence why its not even available as a widget there.

You can complete this easily with no code, using widgets in Method Directives.

You need to do a trace and complete the other calls it is something along the lines of. (Please note this is just example, your trace may have different method names)

  • GetNewInvcMisc
  • OnChangeMiscCharge
  • OnChangeMiscDocActualAmt
  • Update
// Example of Receipt Misc Automation
var dsNew = new Erp.Tablesets.ReceiptTableset();
bo.GetNewRcvMisc(ref dsNew, vendorNum, purPoint, packSlip);
bo.OnChangeMiscCharge(vendorNum, purPoint, packSlip, 0, "FRTI", ref dsNew); 
bo.OnChangeMiscDocActualAmt(vendorNum, purPoint, packSlip, 0, _value, ref dsNew);
dsNew.RcvMisc[0].CommentText = "Automatically Applied from PO";
dsNew.RcvMisc[0].RowMod = IceRow.ROWSTATE_ADDED;
bo.Update(ref dsNew);
3 Likes

@hasokeric Thanks for the Heads-up .the end goal is to create Credit memo for RMA and add Misc. Line Automatically for the the Invoice, However I can’t able to use Method Directives to call BO AR Invoice. this causes Compilation errors.

There is at least one compilation error.

Blockquote

UpdateExt.CommonTypes.cs(163,33): error CS0433: The type ‘InvcDtlTable’ exists in both ‘Erp.Contracts.BO.ARInvoice, Version=10.2.300.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’ and ‘Erp.Contracts.BO.RMAProc, Version=10.2.300.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’
UpdateExt.CommonTypes.cs(173,33): error CS0433: The type ‘LegalNumGenOptsTable’ exists in both ‘Erp.Contracts.BO.ARInvoice, Version=10.2.300.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’ and ‘Erp.Contracts.BO.RMAProc, Version=10.2.300.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’
UpdateExt.CommonTypes.cs(70,55): error CS0433: The type ‘InvcDtlRow’ exists in both ‘Erp.Contracts.BO.ARInvoice, Version=10.2.300.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’ and 'Erp.Contracts.BO.RMAProc, Version=10.2.300.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992

That is a known issue that can’t be resolved unless you move the logic to Epicor Functions. Given than you are on 10.2.300 you have another option you can make use of.

You create an Updatable BAQ lets call it CODE-CreateRMA and you create Calculated fields Calculated_Company, Calculated_InvoiceNum (etc) then you create code inside of the Updatable BAQ under BPM section, under Update (just pick Advanced BPM). You don’t have to have any tables.

Then you invoke the UBAQ from your Method Directive. Use the Updatable BAQ basically as a Function. Then the UBAQ BPM invokes the RMA BO.


Example Code how to invoke UBAQ from Method Directive

// You may need to reference Ice.Contracts.BO.DynamicQuery as Reference in your Invoice BPM

// Create the Logged Invoice by calling out to a Updatable BAQ
bool more;
var ds = dq.GetListByID("CODE-zCreateLoggedInvoice", null, 0, 0, out more); 
				
// set the calculated fields in the BAQ                    
ds.Tables["Results"].Rows[0]["Calculated_Company"] = sel.Company;
ds.Tables["Results"].Rows[0]["Calculated_VendorNum"] = sel.VendorNum;
ds.Tables["Results"].Rows[0]["Calculated_InvoiceNum"] = sel.InvoiceNum;
ds.Tables["Results"].Rows[0]["Calculated_InvoiceAmt"] = sel.DocInvoiceVendorAmt;
ds.Tables["Results"].Rows[0]["Calculated_GroupID"] = callContextBpmData.ShortChar01;
ds.Tables["Results"].Rows[0]["Calculated_PONum"] = sel.REFPONum;
// don't forget to  set the RowMod = "U" so that the update works
ds.Tables["Results"].Rows[0]["RowMod"] = "U"; 

// Run the updatable BAQ
ds = dq.UpdateByID("CODE-zCreateLoggedInvoice", ds); 

Then basically in your UBAQ you can read the Calculated Columns and get more data and do whatever you want.

var row = ttResults.FirstOrDefault();

if (row != null)
{          
	bool LogAPInvExists = (from LogAPInv_Row in Db.LogAPInv
		where LogAPInv_Row.Company == row.Calculated_Company
		&& LogAPInv_Row.VendorNum == row.Calculated_VendorNum
		&& LogAPInv_Row.InvoiceNum == row.Calculated_InvoiceNum
		select LogAPInv_Row).Any();
							
	// If no Logged Invoice exists
	if (!LogAPInvExists)
	{
		var LogAPInvSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.LogAPInvSvcContract>(Db);
		LogAPInvTableset ds = new LogAPInvTableset();
		LogAPInvSvc.GetNewLogAPInvInvoice(ref ds, row.Calculated_GroupID);
		string OurMsg = "";
		LogAPInvSvc.ChangeRefPONum(row.Calculated_PONum, true, out OurMsg, ref ds);
		// etc
	}
}
2 Likes

@hkeric.wci Thank you so much , I Will keep you posted once done.

It may seem intimidating, but once you do it once - you may even start to use this method going forward, until you get to Functions. Because now you can just call CODE-CreateRMA from ANY BPM and as long as you pass in the right variables, you can create an RMA.

INCLUDING Customizations.

When someones tries to invoke a fake BPM from a Customization, I always tell them just invoke a UBAQ, viola! :slight_smile: no hijacking of Update or anything.

2 Likes

Any reason for a UBAQ over an Epicor Function?

10.2.300 was the only reason in his case.

@hkeric.wci Hello , I tried Advanced BPM , However it doesn’t fire the the UBAQBPM, may I know what is the Expression for the Calculated Fields Should be , whether should i use Parameters in Expression?

Just make your calculated fields anything.

image

Then in the BPM You will fill them out and set RowMod to ‘U’ and then invoke Update.

In your Advanced BPM under Update PRE You will then use them:
image
image

You can post some of your code, we can help easier, the more screenshots the better

@hasokeric Thanks for the Quick Reply , Now i set the BAQ Calc Fields to Blanks , and Triggered the Bpm , it prompts a exception, refer the Screenshots Below.
Note: I enabled BPM in UBAQ.
BPM Code:


Exception:

@hkeric.wci I Figured it out , I need to enable base processing and make it as Dummy , then Method Fires , is it mandatory to enable base processing ?

2 Likes

Yes, you can also make your BPM as the BASE, but I found sometimes when copying it to another environment Epicor deletes it. Yes you need a dummy BASE.

1 Like