gridTextColumn

Hi, 

I have the following code: 

a!gridTextColumn(
label: "Approved By",
field: "approvedString",
data: index(local!datasubset.data,"approvedString", null))

That returns a text array: 

111, 222, 333

I want to send each of these array elements to expression rule!convertID that will convert it to a username.

For example:

  • 111 = Jon Smith
  • 222 = Sally Jones
  • 333 = James Harris

Please can someone please tell me the syntax to apply the the rule!convertID to each element returned by data: index(local!datasubset.data,"approvedString", null))?

Thank you.

  Discussion posts and replies are publicly visible

  • You can use apply() to iterate each item in the list like apply(rule!converId,{111,222,333})

    or

    You can use new looping function a!forEach() which does everything apply() does with better null handling and it supports SAIL components.

    a!forEach(
    items: {111,222,333},
    expression: rule!convertid(fv!item)
    )
  • Thanks ammireddys,

    I'm using V16.3 so can not use forEach function.

    I updated my statement below, but I'm still getting evaluation error --> 

           a!gridTextColumn(

             label: "Approved By",

             field: "approvedString",

             data: apply(rule!AH_formatUserName, {local!datasubset.data, "approvedString"})

           )

    Note:

    The following text array is correctly returned by the below statement: {111,222,333}

           a!gridTextColumn(

             label: "Approved By",

             field: "approvedString",

             data: index(

               local!datasubset.data,

               "approvedString",

               null

             )

           )

     

    Thank you.

  • 0
    A Score Level 1
    in reply to zrizvi
    Try this

    a!gridTextColumn(
    label: "Approved By",
    field: "approvedString",
    data: apply(
    rule!AH_formatUserName,
    index(
    local!datasubset.data,
    "approvedString",
    null
    )
    )
    )

    if you are getting values beforehand, its good to parse the subset data before populating it in grid text column so that it would be easier for null handling.
  • Thank you, I'm getting evaluation error as follows: 

    Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error in rule 'ah_formatusername' at function 'user' [line 3]: Error evaluating function 'user' : [InvalidUserException]

    Note:

    rule!AH_formatUserName contains the following expression to handle a single userName input:

    =if(a!isNullOrEmpty(ri!username),

     tostring(null),

     user(ri!userName, "firstName") & " " & user(ri!userName, "lastName")

    )

    Any other suggestions will be much appreciated.

  • 0
    A Score Level 1
    in reply to zrizvi
    Check what exactly "approvedString" holds, is it username array or full names?
  • Approved string holds a text array of userIDs. The user IDs are numeric (111111) and can convert to a full user name i.e. John Smith.

    I copied this "approvedString" variable directly from one of the processes:

    206504320, 206504472, 206504472, 206504472, 206504472, 206504472, 206504472, 206504472

    Example:

    rule!AH_formatUserName(206504472) RETURNS "John Smith"

  • Hi ammireddys,

    "approvedString" holds a text array of numeric User IDs which are the usernames in Appian. 

    From the username, the rule AH_formatUserName returns "Firstname Lastname"

    I am trying to take the username, and return the "firstname lastname".

    Example:

    Username: 206504476

    Firstname: John

    Lastname: Doe

    rule!formatUserName(206504476) RETURNS "John Doe" 

    Note: 

    the rule does not accept arrays, only single user names. 

    Will your below code still work in this case?

    a!gridTextColumn(
    label: "Approved By",
    field: "approvedString",
    data: apply(
    rule!AH_formatUserName,
    index(
    local!datasubset.data,
    "approvedString",
    null
    )
    )
    )

  • why cannot you create a new datasubset , which has new field and in that field you just have to use user function to get the user name . I think its better not to complicate logic in the field itself.
  • hi rizviz,
    once try below code,and make sure that rule input of rule rule!AH_formatUserName must be of type "text" because the approvedString is text Array
    a!gridTextColumn(
    label: "Approved By",
    field: "approvedString",
    data: apply(
    rule!AH_formatUserName(_),
    index(
    local!datasubset.data,
    "approvedString",
    null
    )
    )
    )

  • 0
    Certified Lead Developer
    First of all I don't think there's any such thing like a!isNullOrEmpty. Use fn!isnull instead.
    Secondly, you have used ri!username in one place and ri!userName in other place. In one there is small n and in other one there is capital N.