Hi all,
I am currently writing a web-api that will help integrate an external system with appian. I want to write a function that returns selected fields from all the user objects in the system. To that end, I have started writing a web-api that contains this key code:
local!allusers: a!forEach( items: getdistinctusers(cons!IWMS_ALL_USERS_GROUP), expression: { firstName: user(fv!item.username, "firstName"), lastName: user(fv!item.username, "lastName"), email: user(fv!item.username, "email"), phoneNumber: user(fv!item.username, "phoneOffice") } )
However, this fails with the error: "Expression evaluation error [evaluation ID = 5RH87KD4] at function a!forEach [line 24]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function 'user' parameter 2 [line 27]: Invalid index: Cannot index property 'username' of type Text into type User"
If I code it as:
local!allusers: a!forEach( items: getdistinctusers(cons!IWMS_ALL_USERS_GROUP), expression: fv!item )
I get the json results as: [{ "id" : "LukeLiv" }, { "id" : "JamesLiv" }, { "id" : "EllaLiv" }, { "id" : "AvaFin" }, { "id" : "FredLiv" }]
What do I need to do in the expression to retrieve more fields than simply the id field in the returned json?
thanks heaps,
David
Discussion posts and replies are publicly visible
Hi David,
Please try the below code:
a!toJson(a!forEach( items: getdistinctusers(cons!IWMS_ALL_USERS_GROUP),expression: {firstName: user(fv!item, "firstName"),lastName: user(fv!item, "lastName"),email: user(fv!item, "email"),phoneNumber: user(fv!item, "phoneOffice")}))
thanks heaps, that's got it. :-)