I have a data with following format-
[entity: somevalue , data:[id:1,name:a],[id=2,name:b]
Now i need to pass data part in loop. As it has 2 occurrences for data so loop should run two times. And for each occurrence it should pas only relevant data.
1st occurrence- [entity: somevalue , data:[id:1,name:a]
2nd occurrence- [entity: somevalue , data:[id=2,name:b]
As data is type of array so not able to do indexing here.
Any suggestion.
Discussion posts and replies are publicly visible
Could you please try the below Code.
a!localVariables( local!data: a!map( entity: "Some Entity", data: { { id: 1, name: "ABC" }, { id: 2, name: "DEF" } } ), a!forEach( items: local!data.data, expression: { entity: "Some Entity", data:fv!item } ) )
That didn't help as process is receiving process variable of entity type. As per your example, issue is to get data part of local!data
deepakg's example is essentially it, here's the same just with a specific Entity Data type utilized. What are you doing with the data? Passing it where?
a!localVariables( local!data: a!entityData( entity: cons!COE_DS_SAMPLE, data: { {id: 1, name: "test 1"}, {id: 2, name: "test 2"} } ), a!forEach( items: local!data.data, expression: { /* each data set can be utilized here */ fv!item } ) )
in my process, Process variable is entitydata type and contains entity value and data (multiple).
Now if i configure the above way then getting-
a!localVariables( local!data: ri!entityDataPV, a!forEach( items: local!data.data, expression: { fv!item } ))
Cannot index "data" because it is an array type (List of variant). Only fields with scalar types can be indexed from an array
could you please show the structure of your entityDataPV? what type of value it contains we want to see that.
Something like below?
In entityDataPV rule input, i used the below code.
a!entityData( entity: cons!UAS_DSE, data: { 'type!{urn:com:appian:types:UAC}UAC_UAS_Onboard_Data'( uniqueassetid: 1, ), 'type!{urn:com:appian:types:UAC}UAC_UAS_Onboard_Data'( uniqueassetid: 2, ), 'type!{urn:com:appian:types:UAC}UAC_UAS_Onboard_Data'( uniqueassetid: 3, ), 'type!{urn:com:appian:types:UAC}UAC_UAS_Onboard_Data'( uniqueassetid: 4, ) } )
piyusha6151, You need to index the data as it is a non-scaler type. I have modified Chris' code and attached it below. Try using it..
a!localVariables( local!data: a!entityData( entity: cons!COE_DS_SAMPLE, data: { {id: 1, name: "test 1"}, {id: 2, name: "test 2"} } ), a!forEach( items: local!data[1].data, expression: { /* each data set can be utilized here */ fv!item } ) )