we have select box varaible on record producer and choic values are reference to sys choice table

vijani
Tera Expert

We have selectBox variable Rank on record producer and values are reference to sys choice table. choice values are like below.

NW01, NW05, NW21, NW23
BY01, BYC1, BYC3, BYC7, BY04, BY04

for example, on form load the Rank variable has NW01 value. if user wants change Rank value from NW01 to NW21 or BYC1 to BYC3 then user should get a info message like your Rank has been increased.

could you please anybody help me how to achieve this.

 

 

 

5 REPLIES 5

Deepak Shaerma
Kilo Sage

Hi @vijani 
simply create a Onchange client script.
- Click New to create a new Client Script.
- Name:
- Table: Select the table that your record producer targets, or choose “Service Catalog” if it’s specifically for a Catalog Item.
- UI Type: All or Desktop depending on your requirement.
- Type: onChange
- Field name: Choose your “Rank” variable.

var ranks = ["NW01", "NW05", "NW21", "NW23", "BY01", "BYC1", "BYC3", "BYC7", "BY04"];
      var oldIndex = ranks.indexOf(oldValue);
      var newIndex = ranks.indexOf(newValue);

      if (newIndex > oldIndex) {
        // Displaying an info message relies on g_form.addInfoMessage(message)
        g_form.addInfoMessage('Your Rank has been increased.');
      }
    }


Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma

Hi thanks for reply @Deepak Shaerma  but similarly we have n no of choices are there under Rank field.  

Deepak Shaerma
Kilo Sage

Hi @vijani 
logic was still the same. you just need to modify the script according to your needs. 2 things there.
1.  select the related Table. For a record producer, you might not directly apply it to a table, but this is where you would if adapting for form use on specific records.

 

 var oldIndex = parseInt(oldValue.substring(2));
       var newIndex = parseInt(newValue.substring(2));

       if (newIndex > oldIndex) {
           alert('Your Rank has been increased.'); // Or use g_form.addInfoMessage for a less intrusive message
       }

 

Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma

Community Alums
Not applicable

Hi @vijani ,

I tried your problem in my PDI. 

Can you please create one onChange client script and it works on changing of your rank variable and try to add below code.

 

if (newValue != oldValue) {
       alert('Your Rank has been increased.');
}

 

Please mark my answer correct and helpful if this works for you

 

Thanks and Regards 

Sarthak