Hi @dr_dan ,
This is what I tried
// **************************************************
// Custom code for JobEntryForm
// Created: 10/03/2022 3:24:47 PM
// **************************************************
extern alias Erp_Contracts_BO_Project;
extern alias Erp_Contracts_BO_Part;
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
public class Script
{
// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **
private EpiDataView edvJobOper;
private EpiDataView edvCallContextBpmData;
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
this.edvJobOper = ((EpiDataView)(this.oTrans.EpiDataViews["JobOper"]));
this.edvJobOper.EpiViewNotification += new EpiViewNotification(this.edvJobOper_EpiViewNotification);
this.edvCallContextBpmData = ((EpiDataView)(this.oTrans.EpiDataViews["CallContextBpmData"]));
this.edvCallContextBpmData.EpiViewNotification += new EpiViewNotification(this.edvCallContextBpmData_EpiViewNotification);
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
// End Wizard Added Custom Method Calls
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
this.edvJobOper.EpiViewNotification -= new EpiViewNotification(this.edvJobOper_EpiViewNotification);
this.edvJobOper = null;
this.edvCallContextBpmData.EpiViewNotification -= new EpiViewNotification(this.edvCallContextBpmData_EpiViewNotification);
this.edvCallContextBpmData = null;
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void epiButtonC1_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
edvCallContextBpmData.dataView[edvCallContextBpmData.Row]["Character01"] = "UPDATE ORDER";
edvJobOper.dataView[edvJobOper.Row]["RowMod"] = "U";
oTrans.Update();
}
private void edvJobOper_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
// ** Argument Properties and Uses **
// view.dataView[args.Row]["FieldName"]
// args.Row, args.Column, args.Sender, args.NotifyType
// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
if ((args.NotifyType == EpiTransaction.NotifyType.AddRow))
{
if ((args.Row > -1))
{
}
}
}
private void edvCallContextBpmData_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
// ** Argument Properties and Uses **
// view.dataView[args.Row]["FieldName"]
// args.Row, args.Column, args.Sender, args.NotifyType
// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
if ((args.NotifyType == EpiTransaction.NotifyType.AddRow))
{
if ((args.Row > -1))
{
}
}
}
}
And for BPM I used this:
string msg ="Test";
string jobnum = "";
string company = "";
int ordernum = 0;
string CustName_c ="";
string Address1_c ="";
string Address2_c ="";
string Address3_c ="";
string City_c ="";
string State_c ="";
string PostalCode_c ="";
string Country_c ="";
string ContactPerson_c ="";
string ContactPhone_c ="";
string ContactEmail_c ="";
string ShipVia_c ="";
bool orderhedconfirmed = false;
bool orderrelconfirmed = false;
int orderrelnum = 0;
int orderlinenum = 0;
if(ttJobOper.Any())
{
this.PublishInfoMessage(msg,Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
foreach (var joboperrow in (from joboper_Row in ttJobOper
//where joboper_Row.Company == company && joboper_Row.OrderNum == ordernum
select joboper_Row))
{
//valueOTSCountryNum = countryrow.Description;
jobnum = joboperrow.JobNum ;
company = joboperrow.Company ;
this.PublishInfoMessage("checkpoint01",Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
int jobnumlength = jobnum.Length;
this.PublishInfoMessage("checkpoint02",Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
int orderlineindex = jobnum.IndexOf('-')+1;
this.PublishInfoMessage("checkpoint03",Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
int orderrelindex = jobnum.IndexOf('-', jobnum.IndexOf('-') + 1)+1;
this.PublishInfoMessage(jobnum,Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
this.PublishInfoMessage(jobnumlength.ToString(),Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
this.PublishInfoMessage(orderlineindex.ToString(),Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
this.PublishInfoMessage(orderrelindex.ToString(),Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
string orderlineindexstring = jobnum.Substring(orderlineindex, orderlineindex-orderrelindex-2);
string orderrelindexstring = jobnum.Substring(orderrelindex, jobnumlength-1);
this.PublishInfoMessage(orderlineindexstring,Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
this.PublishInfoMessage(orderrelindexstring,Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
string callcontext = callContextBpmData.Character01;
string rowmod = joboperrow.RowMod;
if(!rowmod.Equals("U") || !callcontext.Equals("UPDATE ORDER"))
{
}
else
{
foreach (var jobprodrow in (from jobprod_Row in Db.JobProd
where jobprod_Row.Company == company && jobprod_Row.JobNum == jobnum
select jobprod_Row))
{
ordernum = jobprodrow.OrderNum ;
}
foreach (var orderhedrow in (from orderhed_Row in Db.OrderHed
where orderhed_Row.Company == company && orderhed_Row.OrderNum == ordernum
select orderhed_Row))
{
foreach (var orderrelrow in (from orderrel_Row in Db.OrderRel
where orderrel_Row.Company == company && orderrel_Row.OrderNum == ordernum && orderrel_Row.OrderLine == orderlinenum && orderrel_Row.OrderRelNum == orderrelnum
select orderrel_Row))
{
ordernum = orderrelrow.OrderNum ;
}
//CustName_c = orderhedrow.UDField<System.Boolean>("CustName_c");
if(true)
{
}
CustName_c = orderhedrow.UDField<System.String>("CustName_c");
Address1_c = orderhedrow.UDField<System.String>("Address1_c");
Address2_c = orderhedrow.UDField<System.String>("Address2_c");
Address3_c = orderhedrow.UDField<System.String>("Address3_c");
City_c = orderhedrow.UDField<System.String>("City_c");
State_c = orderhedrow.UDField<System.String>("State_c");
PostalCode_c = orderhedrow.UDField<System.String>("PostalCode_c");
Country_c = orderhedrow.UDField<System.String>("Country_c");
ContactPerson_c = orderhedrow.UDField<System.String>("ContactPerson_c");
ContactPhone_c = orderhedrow.UDField<System.String>("ContactPhone_c");
ContactEmail_c = orderhedrow.UDField<System.String>("ContactEmail_c");
ShipVia_c = orderhedrow.UDField<System.String>("ShipVia_c");
}
callContextBpmData.Character01 = "";
}
}
}
I get this error:
Server Side Exception
BPM runtime caught an unexpected exception of 'ArgumentOutOfRangeException' type.
See more info in the Inner Exception section of Exception Details.
Exception caught in: Epicor.ServiceModel
Error Detail
============
Correlation ID: a9405720-6a2b-4994-ae57-32123d5b582c
Description: BPM runtime caught an unexpected exception of 'ArgumentOutOfRangeException' type.
See more info in the Inner Exception section of Exception Details.
Program: CommonLanguageRuntimeLibrary
Method: Substring
Original Exception Type: ArgumentOutOfRangeException
Framework Method: A001_CustomCodeAction
Framework Line Number: 0
Framework Column Number: 0
Framework Source: A001_CustomCodeAction at offset 1155 in file:line:column <filename unknown>:0:0
Client Stack Trace
==================
at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets)
at Erp.Proxy.BO.JobEntryImpl.Update(JobEntryDataSet ds)
at Erp.Adapters.JobEntryAdapter.OnUpdate()
at Ice.Lib.Framework.EpiBaseAdapter.Update()
at Erp.UI.App.JobEntry.Transaction.Update()
Inner Exception
===============
Specified argument was out of the range of valid values.
Parameter name: Length cannot be less than zero.
Parameter name: length
The interesting fact is that not even the first part of BPM runs (the message just to see if it is entering the loop) so it seems something is wrong on Customization side. The customization compiles successfully, so I am not sure what could be causing this.
Thank you in advance