Standard Directive - Table has multiple rows

How is this method kicked off in the first place?

Its a scheduled function to create material queue records.

Can we see that part, or could you describe it?

The only reference on the function is this dll file.
image

I cant get into it, it seems to be locked.

We run it on a schedule and it picks up any sales orders that can be picked in the warehouse and sends them out to the material queue for picking. It auto allocates to available warehouse bins, skipping the Fulfilment Workbench.

Ok, let me think on it. Or maybe someone else will understand the data directive problem better.

Start here:

Pay particular attention to the posts by @Rich

But the rest are essential as well.

The gist I got from it is do your work in the in trans data directive,
and pass it to the standard through the call context data or some other means
and do your final work/post there.

@klincecum I have managed to get the Standard Directive firing and bringing over the MtlQueueSeq field from in transaction. which is a great start so thank you for pointing me in that direction.

First issue. if i update 4 records i only get the latest record not the preceding 3.

Second issue, The post to the API fails but i imagine it is to do with the below error from Event Viewer.

That is correct.

You will need to somehow store the data you need for processing, and do your processing
off of that.

You only get the last record written.

by storing do you mean use the BPM Data fields in in-transaction to store data i want to use in Standard Directive?

Yes, at least that’s what I would try first.

Your in-trans will fire for each record.

I would use a Character field and add data with a delimiter, or json object, on each iteration, and
pick it up in the standard.

I have made some progress.

I can create .txt files for each record updated which contains the correct data from within Standard Directives using.

image

I cant however trigger the API post code block after this using the code.

If you’re going to go down this road, I would suggest a slightly different approach.

I would choose a UD table, or the systag table, and add a record or a tag for each updated
record.

Then you could query in the standard directive for that data, act upon it, and then delete or mark
the temporary rows inactive.


I’m unsure exactly what you mean about not being able to trigger what you need next.

I’m going to ask some questions in the next post to keep it separate.

Ok, here are my questions.

Is there anything in the first part (in trans) of your code, that is unique, but common to each record, that we could use as a “flag” or “identifier” of sorts, so we would know what to trigger off of in the standard
directive?

If so, I would first try to use the call context to store that information. But however you do it, if you
have something common to all records, but unique to the transaction, we can use that to pass to the standard.

If the answer is yes, I will suggest a way to pull that data in standard.

I think maybe the WarehouseGroupCode = “CAR” could be used.
Individual to each row would be the MtlQueueSeq field.

I only really need to focus on each individual record. and create an API post based on that 1 record.

I think I might have a more simple idea, but it only works if these come in batches.
Wouldn’t hurt to try it.

For the first record, the call context should be blank most likely.

Choose a field say, “Character01”

each time the in-trans fires, add a row, serialized to json, to Character01 and add a delimiter like a pipe.

callContextBpmData.Character01 += JsonConvert.SerializeObject(yourRow) + "|";

when the standard fires, first, check and pull off the last pipe “|”

if( callContextBpmData.Character01.EndsWith("|") ) 
{
    callContextBpmData.Character01 = callContextBpmData.Character01.Remove(callContextBpmData.Character01.Length - 1)
}

//or just 

callContextBpmData.Character01.TrimEnd("|");

Then split that string into json strings:

List<string> rowsList = callContextBpmData.Character01.Split("|").ToList();

Then, clear the callContextBpmData.Character01 field:
callContextBpmData.Character01 = ""

now you have the json for each row

you can deserialize that list back into actual rows, and get your data.

and this would give me 1 record each time inside the standard directive?

It would give you 1 batch of records, for each time the in trans fired.

Say in trans had 10 records, in standard, the call context field would have a list of the 10 records that fired.

You foreach on that rowsList, and do your process for each record.

something like

foreach(var rowStringJson in rowsList)
{
    MyTypeOfRow myrow = JsonConvert.DeserializeObject<MyTypeOfRow>(rowStringJson);

    DoSomeActionOn(myRow.whatever);

}

Hi, unsure on the adding a row on the first section. JsonConvert.SerializeObject(yourRow)
What should be going into yourRow?

I was going off the cuff and not looking at your code

“your row” is whatever row you need to store data from in the first part.

I would guess each MtlQueue row.