klincecum
(Kevin Lincecum)
March 8, 2023, 3:02pm
21
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.
Ricky90
(Ricky Horne)
March 8, 2023, 3:07pm
22
I think maybe the WarehouseGroupCode = “CAR” could be used.
Individual to each row would be the MtlQueueSeq field.
Ricky90
(Ricky Horne)
March 8, 2023, 3:10pm
23
I only really need to focus on each individual record. and create an API post based on that 1 record.
klincecum
(Kevin Lincecum)
March 8, 2023, 3:18pm
24
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.
Ricky90
(Ricky Horne)
March 8, 2023, 3:21pm
25
and this would give me 1 record each time inside the standard directive?
klincecum
(Kevin Lincecum)
March 8, 2023, 3:25pm
26
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);
}
Ricky90
(Ricky Horne)
March 8, 2023, 3:30pm
27
Hi, unsure on the adding a row on the first section. JsonConvert.SerializeObject(yourRow)
What should be going into yourRow?
klincecum
(Kevin Lincecum)
March 8, 2023, 3:36pm
28
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.
Ricky90
(Ricky Horne)
March 8, 2023, 3:45pm
30
2 questions.
Am I still to use the foreach on all code blocks in Standard Directive?
Also, I’m getting an error below.
klincecum
(Kevin Lincecum)
March 8, 2023, 3:46pm
31
try ‘|’
on the other question, gimme a sec
klincecum
(Kevin Lincecum)
March 8, 2023, 3:48pm
32
In the standard directive, I think the only foreach would be on your
rows list from the call context.
klincecum
(Kevin Lincecum)
March 8, 2023, 3:51pm
33
If you want to post the code instead of screenshots, I could edit it to make you a
“skeleton” to work off of and test.
Ricky90
(Ricky Horne)
March 8, 2023, 3:58pm
34
I currently have this but it throws a few errors.
I will screenshot them seperately
if( callContextBpmData.Character01.EndsWith(“|”) )
{
callContextBpmData.Character01 = callContextBpmData.Character01.Remove(callContextBpmData.Character01.Length - 1);
}
List rowsList = callContextBpmData.Character01.Split(‘|’).ToList();
callContextBpmData.Character01 = “”;
foreach(var rowStringJson in rowsList)
{
MyTypeOfRow myrow = JsonConvert.DeserializeObject(rowStringJson);
DoSomeActionOn(myRow.whatever);
}
Ricky90
(Ricky Horne)
March 8, 2023, 3:59pm
35
maybe i dont have all the correct references.
klincecum
(Kevin Lincecum)
March 8, 2023, 4:05pm
36
MyTypeOfRow was for you to fill in with the type of row you are storing/retrieving.
Ricky90
(Ricky Horne)
March 8, 2023, 4:10pm
37
Sorry, you have lost me there.
Im not sure what is meant by type of row?
klincecum
(Kevin Lincecum)
March 8, 2023, 4:14pm
38
You’ll be storing a row from MtlQueue, it has a type, I don’t know what that is off the top of
my head, but we need to know so we can deserialize it properly.
Ricky90
(Ricky Horne)
March 8, 2023, 4:21pm
39
Right, as in Anonymous, Dynamic and nullable types?
If thats the case im unsure what it is.