Data Directive 1 to fire off Data Directive 2

I’ve got a Data Directive that runs off the SysAgentSched, it runs each day and checks on the InvcHead table for the due date of the invoice, if the condition is met it sets the AutoPrint Ready field to true

All good so far… this happens

I have a second DataDirective that checks the InvcHead for changes of the AutoPrintReady field and it is meant to run the Auto Print in the directive…

The problem I have is that the second Data Directive doesn’t fire off when the field is set by the first Directive

The second Data Directive will only fire when I manually change the field in the UI

Is this a known problem and does anyone know of a work-a-round???

I’m on 10.2.400.13

Can you post both data directives?

Hello @kylepbsps

image

And Code

bool tvSYS = ttSysAgentSched.Any(s => s.Updated() && ttSysAgentSched.Any(s1 => s1.Unchanged() && s1.SysRowID == s.SysRowID && s1.LastRunOn != s.LastRunOn && s.AgentSchedNum == 194922));
if (tvSYS == true)
{

///Date in 3 days time
var fud = DateTime.Today.AddDays(3);

var invs = Db.InvcHead.Where(i => i.Company == Session.CompanyID && i.OpenInvoice == true && i.CreditMemo == false && i.UnappliedCash == false && i.DueDate == fud).ToList();
if(invs != null)
{
foreach(var inv in invs)
{
var send = inv.AutoPrintReady;
if(!send)
{

inv.AutoPrintReady = true;
Db.Validate();
}
if(send)
{

inv.AutoPrintReady = false;
Db.Validate();

}

}
}
}

Second Data Directive

Data Directives are fired off an internal trigger which doesn’t always fire when you bypass the business object and write directly to the table (like you are doing in your first Data Directive)

You should use the Business Object to make that update if you want the secondary DD to trigger.

Particularly the field changed from x to y triggers need a BI (Before Image) which only comes from the BO (or if its manually created)

1 Like

I have a feeling doing a manual click and save is different than the system changing the field. I would maybe try method directive for the 2nd one.

Ok, thank you for the direction, do you have any pointers for using BO’s in C# ???

I bet you can use a condition and check for field change with the UI buttons instead of C#, if you’re just printing.

@kylepbsps That’s what I’m doing in the second DD

Here’s an example

Thanks @josecgomez, I’ve seen that post before, It’s more about printing a BAQ report to a local printer, I’m trying to fire off the Auto Print on the Invoice Head of selected invoices, this will then send the overdue invoices to the customer using break routing

I think what @josecgomez is meaning is to use the following:

using (var svcARInvoice = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.ARInvoiceSvcContract>(Db) )

along with the methods GetByID (to get the invoice dataset) and UpdateMaster (to update based on the dataset)

The second data directive is not called at all? or it is not called only when there is a condition for AutoPrintReady?
if data directive for invoice head us triggered with no condition then one of the quickest solution right now I can think is to use bpmcallcontext field as a pointer to trigger the invoice head data directive.

Right this was meant to be an example of how to calla business object not the exact one just how to do it. Like @AndrewM said.

Yeah I figured that, calling BO’s from BPM C# is my biggest stumbling block at the moment, while hunting around this site I was able to work out how to fire of the print without having to update the field in InvcHead

I just need to work out how the BO’s work…

Start with a trace do you have that?

Yep I do have trace

Is a BO used for updating or is it used for creating new records? or Both?

Looking at the post below, I think this would be how I would update a record??

I found this…

and this

I think I’ve now got some idea of how they work

Or, if you like torture, you could probably just use widgets to achieve what you have in the code you posted.

1 Like