hi,
I have a record list with values
{name:"Test1",id:1},{name:"Test1",id:2},{name:"Test2",id:3},{name:"Test1",id:4}
my output should show - pid should be concat of the name and the sequence based on count
1. id:1,pid:"Test1001"
2. id:2,pid:"Test1002"
3.id:3,pid:"Test2001"
4.id:4,pid:"Test1003"
any code suggestion will help
Discussion posts and replies are publicly visible
a!localVariables( local!data: { { name: "Test1", id: 1 }, { name: "Test1", id: 2 }, { name: "Test2", id: 3 }, { name: "Test1", id: 1 } }, a!forEach( local!data, a!map( id: property(fv!item, "id", null), pid: concat( property(fv!item, "name", null), substitute(padleft( length(tointeger(wherecontains( tostring(property(fv!item, "name", null)), touniformstring(property(index(local!data,enumerate(fv!index)+1,{}),"name", null)) ))), 3)," ",0) ) ) ) )
This will return the data as per your requirement.
a!localVariables( local!data: { { name: "Test1", id: 1 }, { name: "Test1", id: 2 }, { name: "Test2", id: 3 }, { name: "Test1", id: 1 } }, a!forEach( local!data, a!map( id: property(fv!item, "id", null), pid: concat( property(fv!item, "name", null), substitute(padleft( length(tointeger(wherecontains( tostring(property(fv!item, "name", null))&tostring(property(fv!item,"id",null). ---> this returns length zero touniformstring(property(index(local!data,enumerate(fv!index)+1,{}),"name", null)) ))), 3)," ",0) ) )))
It will evaluate to zero when name and id fields are not present for a particular index