The Zurich release has arrived! Interested in new features and functionalities? Click here for more

how to show a field message when particular value selected on variable of catalog ?

1_DipikaD
Kilo Sage

Hi , 

I have below catalog with mentioned select box type variable . I want to show a field message when " add" is selected on that variable . I have tired the below Onchange catalog client script but couldn't get the result .

Please suggest what changes should I make to achieve this ?

 

Thank You

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
   if (newValue === '1') {
    g_form.showFieldMsg('request_type',"This request requires email approval from the Business mgmt", 'info');
   }
else{g_form.hideFieldMsg('request_type','true');
}


   //Type appropriate comment here, and begin script below
   
}

1_DipikaD_0-1756189366491.png

 

1 ACCEPTED SOLUTION

Please select UI Type as All.

Also, could you post a screenshot of whole Client script. I guess this is the only issue - UI Type is not selected as all.

View solution in original post

12 REPLIES 12

@1_DipikaD 

alert didn't come?

if yes then your client script config is wrong.

client script is marked as Applies on Catalog item view right?

if not then it won't run

share client script config screenshot

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

BrahmjeetTanwar
Tera Guru

Hi @1_DipikaD 
Try few things:

1. Try using == 1 instead of === '1' and check for an alert.

2. Check the correct value of the dropdown choice list.

3. check if "request_type" field is visible on the form, try using alert first and then show field message.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Thanks,
Brahmjeet

Hi @BrahmjeetTanwar ,

Tried as you said but couldn't get the desired result.

Could you please share the screenshot of client script and the variables as well with their backend name along with values?

Hi@BrahmjeetTanwar 

It is working on platform side but not working on portal as shown in the SS.

1_DipikaD_0-1756194624300.png

1_DipikaD_1-1756194737925.png1_DipikaD_2-1756195771695.png

1_DipikaD_3-1756196358964.png