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

Ankur Bawiskar
Tera Patron
Tera Patron

@1_DipikaD 

onChange is written on which variable?

are you sure you are comparing the correct choice value in your IF condition?

is the choice value as 1 for the choice label Add?

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

On change written on request_type field . Yes, the value of the choice is 1.

@1_DipikaD 

share screenshot of that variable config.

did you try adding alert and see what came in newValue?

try this

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

	alert(newValue);

    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

}

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

Tried this but couldn't get the result .