Skip to main content
May 16, 2021
Solved

How to get Selected Choice Label in a rule input Variable

  • May 16, 2021
  • 3 replies
  • 0 views

My dropdown field is this:

a!dropdownField(

label: "Appliance Id",
labelPosition: "JUSTIFIED",
placeholder: "Select the appliance",
choiceLabels: rule!LN_Concatenate_Appliance_Customer_Details(local!userId),
choiceValues: rule!LN_Fetch_Appliance_Based_Customer_Id(local!userId).data.applianceId.applianceId,
value: if(isnull(local!applianceId), null, local!applianceId),
saveInto: {local!applianceId, ri!Servicing.applianceId.applianceId},
showWhen: ri!isCustomerCare

),

I want the selected Choice Label to be saved in a rule input variable. How can I do that? The choice values is basically the id, but I need it, so I cannot replace it with the same expression rule as choiceLabel.

Thanks in advance!!

Best answer by harshitb6843

Hi,

You can use displayValue function inside your saveInto param. That way, you will be able to identify the selected label and save it into the desired RI. 
For instance, let's suppose the RI in which you want to save is 'selectedLabel'. Now please refer to the code snippet below.

a!dropdownField(
  label: "Appliance Id",
  labelPosition: "JUSTIFIED",
  placeholder: "Select the appliance",
  choiceLabels: rule!LN_Concatenate_Appliance_Customer_Details(local!userId),
  choiceValues: rule!LN_Fetch_Appliance_Based_Customer_Id(local!userId).data.applianceId.applianceId,
  value: local!applianceId,
  saveInto: {
    local!applianceId,
    ri!Servicing.applianceId.applianceId,
    a!save(
      ri!selectedLabel,
      displayvalue(
        local!applianceId,
        rule!LN_Fetch_Appliance_Based_Customer_Id(local!userId).data.applianceId.applianceId,
        rule!LN_Concatenate_Appliance_Customer_Details(local!userId),
        null
      )
    )
  },
  showWhen: ri!isCustomerCare
)
It should do the work. 

Thanks,
Harshit

3 replies

harshitb6843
May 16, 2021

Hi,

You can use displayValue function inside your saveInto param. That way, you will be able to identify the selected label and save it into the desired RI. 
For instance, let's suppose the RI in which you want to save is 'selectedLabel'. Now please refer to the code snippet below.

a!dropdownField(
  label: "Appliance Id",
  labelPosition: "JUSTIFIED",
  placeholder: "Select the appliance",
  choiceLabels: rule!LN_Concatenate_Appliance_Customer_Details(local!userId),
  choiceValues: rule!LN_Fetch_Appliance_Based_Customer_Id(local!userId).data.applianceId.applianceId,
  value: local!applianceId,
  saveInto: {
    local!applianceId,
    ri!Servicing.applianceId.applianceId,
    a!save(
      ri!selectedLabel,
      displayvalue(
        local!applianceId,
        rule!LN_Fetch_Appliance_Based_Customer_Id(local!userId).data.applianceId.applianceId,
        rule!LN_Concatenate_Appliance_Customer_Details(local!userId),
        null
      )
    )
  },
  showWhen: ri!isCustomerCare
)
It should do the work. 

Thanks,
Harshit

harshitb6843
May 16, 2021

Also, you might need to explicitly cast the params of displayValue in the desired data type for ease of use.