Pulling extra detail to a Data Directive

Hello All,

I have been doing simple Data Directives up until now, but need to expand some with C#

I don’t have much clue in C# but this is what I need to achieve

From a Standard Data Directive, I need to be able send off an email to the Sales Rep
The trigger to send the email is based on a condition in the OrderHed,
The only field available in the OrderHed related to the sales rep is SalesRepList which contains a list of sales rep numbers related to the sales order, all our sales orders only have one sales rep so that part is fine, what I need to be able to do is look up the SalesRep table, match the sales rep number and return the email address and name

If the values of the field OrderHed.SalesRepList are equals to the value of SalesRep.SalesRepCode you can try below code using the Execute Custom Code function.
First assigned or set the callContextBpmData.Character01 to ttOrderHedRow.SalesRepList using Set BPM Data Field.

var SysSalesRep = (from SysSalesRep_Row in Db.SalesRep
where SysSalesRep_Row.Company == Session.CompanyID
&& SysSalesRep_Row.SalesRepCode == callContextBpmData.Character01

select SysSalesRep_Row).FirstOrDefault();
if (SysSalesRep != null)
callContextBpmData.Character02 = SysSalesRep.Name;
callContextBpmData.Character03 = SysSalesRep.EMailAddress;

Now you can use these callContextBpmData.Character02 and callContextBpmData.Character03 as the name and email address.

Thank you!! worked with no modifications,

I’d been trying to pull the data straight into the Custom Code without passing the Rep ID to a callContext first

1 Like