Hi @klincecum
I had created this thread previously and since I did not get any response I desperately looked for similar issues.
The code compiled well, there is still an issue. I get an error and the error is due to the section that I wrote with your help (To be honest you helped and wrote all of it, I cannot take any credit for that) which I am very grateful for.
This is the complete code that I have:
string company = "";
int ordernum = 0;
decimal orderamount = 0;
bool creditPaymentReceived = false;
int custnum = 0;
int BTcustnum = 0;
bool bypassCreditCheckUnder10k = false;
bool IsWarranty = false;
string CustomerPaymentTerm = "";
bool NoOverdueInvoice = true;
bool shouldAutoRelease = false;
DateTime today = DateTime.Now;
this.PublishInfoMessage("checkpoint00", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");
if(ttOrderHed.Any())
{
this.PublishInfoMessage("checkpoint01", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");
foreach (var OrderHedRow in ttOrderHed)
{
company = OrderHedRow.Company;
ordernum = OrderHedRow.OrderNum;
this.PublishInfoMessage("OrderNum is -->"+ordernum.ToString(), Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");
orderamount = OrderHedRow.TotalCharges-OrderHedRow.TotalDiscount+OrderHedRow.TotalTax+OrderHedRow.TotalMisc;
creditPaymentReceived = (bool)OrderHedRow["CreditPaymentReceived_c"];
custnum = OrderHedRow.CustNum;
BTcustnum = OrderHedRow.BTCustNum;
IsWarranty = (bool)OrderHedRow["IsWarranty_c"];
foreach (var CustomerRow in (from Customer_Row in Db.Customer
where Customer_Row.Company == company && Customer_Row.CustNum == BTcustnum
select Customer_Row))
{
this.PublishInfoMessage("Customer Name -->"+CustomerRow.Name, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");
bypassCreditCheckUnder10k = false;
CustomerPaymentTerm = CustomerRow.TermsCode;
}
if(orderamount<1 && orderamount >-1)
{
//Auto Release --> No Charge Order
this.PublishInfoMessage("Auto Release --> No Charge Order", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");
shouldAutoRelease = true;
}
else if(IsWarranty)
{
//Auto Release --> Warranty
this.PublishInfoMessage("Auto Release --> Warranty", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");
shouldAutoRelease = true;
}
else if(creditPaymentReceived && orderamount<=10000)
{
//Auto Release --> Credit Card Payment Received
this.PublishInfoMessage("Auto Release --> Credit Card Payment Received", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");
shouldAutoRelease = true;
}
else if(!creditPaymentReceived)
{
//Auto Release --> No Credit Payment
this.PublishInfoMessage("Auto Release --> No Credit Payment", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");
if(CustomerPaymentTerm.Equals("NET30"))
{
//Auto Release --> NET30 and no overdue
this.PublishInfoMessage("Auto Release --> NET30 and no overdue", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");
shouldAutoRelease = true;
foreach (var InvcHeadRow in (from InvcHead_Row in Db.InvcHead
where InvcHead_Row.Company == company && InvcHead_Row.CustNum == BTcustnum
select InvcHead_Row))
{
if(InvcHeadRow.InvoiceBal >0 && InvcHeadRow.DueDate>today)
{
shouldAutoRelease = false;
}
}
}
}
else if(bypassCreditCheckUnder10k && orderamount<=10000)
{
//Auto Release --> Bypass and under 10k
this.PublishInfoMessage("Auto Release --> Bypass and under 10k", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");
shouldAutoRelease = true;
}
}
if(shouldAutoRelease)
{
this.PublishInfoMessage("shouldAutoRelease", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");
var CMsvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.CreditManagerSvcContract>(Db);
Erp.Tablesets.CMOrderHedTableset CMTs = new Erp.Tablesets.CMOrderHedTableset();
CMTs = CMsvc.GetOrders(BTcustnum.ToString());
CMOrderHedRow ordersToRemoveHoldFrom = (from ordersOnHold in CMTs.CMOrderHed where ordersOnHold.OrderNum == ordernum select ordersOnHold).FirstOrDefault();
ordersToRemoveHoldFrom.CreditHold = false;
ordersToRemoveHoldFrom.CreditOverride = true;
ordersToRemoveHoldFrom.CreditOverrideLimit = ordersToRemoveHoldFrom.OrderTotal;
ordersToRemoveHoldFrom.RowMod="U";
CMsvc.ChangeOrderCreditHold(ref CMTs);
CMsvc.UpdateCMOrderHed(BTcustnum,ref CMTs );
}
else if(!shouldAutoRelease)
{
}
}
I have used this in SalesOrder Update function using Method Directive.
When I save any record, it throws this error right away, it does not even show the Message Box that I have in the custom code, without that section we added together the code runs fine.
Something seems to be Null for some reason…
This is also in case required. I hope this is not totally wrong