I have a local variable which is receiving BacthPayloadInput Response from process model
local!updatedPurchasers_at: index( ri!EF_GeneralUpdatePayload_cdt.RequestJson, wherecontains( tostring("PowerPurchasers"), cast(103, index(ri!EF_GeneralUpdatePayload_cdt,"RequestEndpoint",{})) ), null ),
when i output the values it contains in expression rule it gives me output like this:
I want to extract the only "KeyPowerPurchasers" out of it which i am not able to do so.
I have been trying to get it in following these two methods but both are having problem:
first one:
local!purchaserKeys_int:reject( fn!isnull, { if( a!isNullOrEmpty(local!updatedPurchasers_at), null, cast(101, index(local!updatedPurchasers_at, "KeyPowerPurchasers", {})) ) } ),
it gives empty array {}
2nd one:
local!purchaserKeys_int:reject( fn!isnull, { if( a!isNullOrEmpty(local!updatedPurchasers_at), null, cast(101,a!fromJson(local!updatedPurchasers_at).KeyPowerPurchasers) ) } ),
this gives
Expression evaluation error at function a!fromJson : The jsonText parameter was not valid JSON.
can anyone please guide how can i get the list of KeyPowerPurchasers out of it only?
Discussion posts and replies are publicly visible
a!forEach( items: local!list, expression: extract( fv!item,"KeyPowerPurchasers:","," ) )
Save your output in a variable and pass that in place of local!list
is it possible to map it into single list?
How do you want your output to look like?
{-2147483254, -2147483253} in this form
Yes. It is the same, Try looking at your output in expression instead of formatted.
Do you have any control over how the data is formatted before being passed out from the process model? It'd save you a lot of hassle in terms of parsing if you just wrap the data into a JSON string, instead of trying to do your own ad-hoc parsing.
You can also utilize the keval() function:
a!localVariables( local!list: { "[KeyPowerPurchaser:-2147483254,ExpectedPowerPurchased: 123]", "[KeyPowerPurchaser:-2147483253,ExpectedPowerPurchased: 456]" }, local!result: a!forEach( items: local!list, expression: keyval( local!list[fv!index], /* text */ "KeyPowerPurchaser", /* keys */ ":", /* separtors */ "," /* delimiters */ ) ), a!flatten(local!result) )