The problem statement is:
To create a username for a person by joining their Last name and first letter of their First name.
Following is the code:
a!localVariables( local!userList: { "derek.romeo@gg.com", "gloria.juarez@gg.com", "pearson.vue@gg.com", "stefan.price@gg.com" }, local!names, local!result, { a!forEach( items: local!userList, expression: { append(local!names,tostring(reverse(rdrop(split(split(fv!item,"@"),"."),2)))), local!result:{ index(split(local!names),";")&index(index(split(local!names,";"),2),1) } } ), } )
This code is throwing the below error:
Expression evaluation error at function a!forEach [line 13]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function 'split' [line 18]: A null parameter has been passed as parameter 1.
When I run the code without lines 17 and 18, I get the below result:
List of Variant - 4 items
and this the expected answer. I am not sure when I try to use the local!names within the same forEach loop for further operations, it says it doesn't contain any values.
Any help in resolving this query will be helpful.
Thanks!
Discussion posts and replies are publicly visible
You try to modify variables during runtime. Appian follows a functional paradigm and does not support the way of programming you might be used to.
And there is also not concept or need for any kind of explicit definition of a "return" value. An expression just creates some output.
Working code could look like this:
a!localVariables( local!userList: { "derek.romeo@gg.com", "gloria.juarez@gg.com", "pearson.vue@gg.com", "stefan.price@gg.com" }, a!forEach( items: local!userList, expression: concat( left(fv!item, 1), extract(fv!item, ".", "@") ) ), )
Hi @Stefan,
Thank you so much for the clarification. The code did work with your input. I'll have to learn more about functional paradigm.
Kind Regards,
Ritika