Having trouble with a cascading dropdown. Basically, I have an editable grid tha

Certified Senior Developer
Having trouble with a cascading dropdown. Basically, I have an editable grid that has 3 dropdowns. The user selects a user from the first dropdown, assigns a role to the user with the second dropdown and assigns an area of expertise with the third dropdown. I got the rule to work with the first 2 dropdowns, but the choices presented with the third dropdown are dependent on the user selected in the first one. I have a query rule that brings back a list of expertises based on the userId. So I created a local!selectedUserId variable to use in my query rule that displays the dropdown list and added an a!save statement to update that local variable with the selected user id. But I get an error when I access this form because the query rule cannot find a userId. Here's the error I'm getting and I've attached my updated rule for the grid.
Expression evaluation error in rule 'ips_getexpertisebyuserid' (called by rules 'ips_assignuserrolesgr...

ips_assignUserRolesGrid_new.txt

OriginalPostID-170455

OriginalPostID-170455

  Discussion posts and replies are publicly visible

Parents
  • @judy We missed populating the local!expertise when the value of the userId is set via 'Active Employees' Dropdown. Trying the below dropdown for 'Active Employees' might be worth.

    a!dropdownField(
    label: "Active Employees",
    choiceLabels: apply(rule!ips_formatUserName, local!users.data),
    choiceValues: index(
    local!users.data,
    "id",
    {}
    ),
    placeholderLabel: "---Select User---",
    value: if(rule!APN_isEmpty(ri!newTeamLink_cdt[ri!index]),null,if(rule!APN_isBlank(ri!newTeamLink_cdt[ri!index].userId),null,ri!newTeamLink_cdt[ri!index].userId)),
    saveInto: {
    ri!newTeamLink_cdt[ri!index].userId,
    \ t /*Populate the local!expertise based on the value set for userId*/
    \ t a!save(
    \ tlocal!expertise,
    \ tif(
    \ trule!APN_isBlank(ri!newTeamLink_cdt[ri!index].userId),
    \ tnull,
    \ trule!ips_getExpertiseByUserId(ri!newTeamLink_cdt[ri!index].userId)
    \ t)
    \ t )
    \ t /*Always set expertiseId to null because expertise dropdown data changes upon the change in the value of userId. So you should also set expertiseId to null.*/
    \ t a!save(ri!newTeamLink_cdt[ri!index].expertiseId,null)
    },
    required: true(),
    readOnly: false()
    )
Reply
  • @judy We missed populating the local!expertise when the value of the userId is set via 'Active Employees' Dropdown. Trying the below dropdown for 'Active Employees' might be worth.

    a!dropdownField(
    label: "Active Employees",
    choiceLabels: apply(rule!ips_formatUserName, local!users.data),
    choiceValues: index(
    local!users.data,
    "id",
    {}
    ),
    placeholderLabel: "---Select User---",
    value: if(rule!APN_isEmpty(ri!newTeamLink_cdt[ri!index]),null,if(rule!APN_isBlank(ri!newTeamLink_cdt[ri!index].userId),null,ri!newTeamLink_cdt[ri!index].userId)),
    saveInto: {
    ri!newTeamLink_cdt[ri!index].userId,
    \ t /*Populate the local!expertise based on the value set for userId*/
    \ t a!save(
    \ tlocal!expertise,
    \ tif(
    \ trule!APN_isBlank(ri!newTeamLink_cdt[ri!index].userId),
    \ tnull,
    \ trule!ips_getExpertiseByUserId(ri!newTeamLink_cdt[ri!index].userId)
    \ t)
    \ t )
    \ t /*Always set expertiseId to null because expertise dropdown data changes upon the change in the value of userId. So you should also set expertiseId to null.*/
    \ t a!save(ri!newTeamLink_cdt[ri!index].expertiseId,null)
    },
    required: true(),
    readOnly: false()
    )
Children
No Data