/*data inputs are: index(int), newLinkToken (any type), newTeamLink_cdt (any type), */ load( local!users: todatasubset( rule!ips_getAllActiveUsersForTeam() ), local!roles: todatasubset( rule!ips_getAllRoles() ), local!expertise: if( rule!APN_isEmpty(ri!newTeamLink_cdt[ri!index]), null, if( rule!APN_isBlank(ri!newTeamLink_cdt[ri!index].userId), null, rule!ips_getExpertiseByUserId(ri!newTeamLink_cdt[ri!index].userId) ) ), a!gridRowLayout( id:ri!index, contents: { 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, /*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.*/ /*Populate the local!expertise based on the value set for userId*/ a!save( local!expertise, if( rule!APN_isBlank(ri!newTeamLink_cdt[ri!index].userId), null, rule!ips_getExpertiseByUserId(ri!newTeamLink_cdt[ri!index].userId) ) ), /*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.*/ a!save(ri!newTeamLink_cdt[ri!index].expertiseId,null) }, required: true(), readOnly: false() ), a!dropdownField( label: "Employee Role", choiceLabels: local!roles.data.roleName, choiceValues: index( local!roles.data, "id", {} ), placeholderLabel: "---Select User Role---", value: ri!newTeamLink_cdt[ri!index].roleId, saveInto: ri!newTeamLink_cdt[ri!index].roleId, required: true(), readOnly: false() ), if(rule!APN_isEmpty(local!expertise), /*A dummy dropdown just to give a look and feel that a dropdown exists as a column and is required*/ a!dropdownField( label: "Area of Expertise", choiceLabels: {" "}, choiceValues: {" "}, placeholderLabel: "---Assign Area of Expertise---", value: null, /*saveInto: ri!newTeamLink_cdt[ri!index].expertiseId,*/ required: true(), readOnly: false(), disabled:false() ), /*A true dropdown that will be populated upon valid selection of userId and expertise data*/ a!dropdownField( label: "Area of Expertise", choiceLabels: local!expertise.data.expertise, choiceValues: index( local!expertise.data, "id", {} ), placeholderLabel: "---Assign Area of Expertise---", /*Null handling being done for value attribute*/ value: if(rule!APN_isEmpty(ri!newTeamLink_cdt[ri!index]),null,if(rule!APN_isBlank(ri!newTeamLink_cdt[ri!index].expertiseId),null,ri!newTeamLink_cdt[ri!index].expertiseId)), saveInto: ri!newTeamLink_cdt[ri!index].expertiseId, required: true(), readOnly: false() ) ), a!linkField( label: "delete " & ri!index, align: "CENTER", links: a!dynamicLink( label: char( 10005 ), value: ri!index, saveInto: { a!save( ri!newTeamLink_cdt, remove( ri!newTeamLink_cdt, save!value ) ), /* * When modifying the size of the array used in a!applyComponents, * make the same change in the "token" array variable*/ a!save( ri!newLinkToken, remove( ri!newLinkToken, save!value ) ) } ) ) } ) )