showFieldMsg on a variable in a Request Item

poyntzj
Kilo Sage

We have Client Catalog Scripts inside variable sets that are used to check values on a form and make use of the showFieldMsg function

Working on a new catalog item and the requester want to have a message appear between two values asking the user to reconsider.   easy - done

However, if I go into the Requested Item, the info message is not showing with the field - and he would like to be shown so they can contact the end user and confirm

I modified the client script to ensure it is still firing - and it is

g_form.addInfoMessage('Boo1 : ' + g_form.getValue('variables.predicted_growth'));

g_form.showFieldMsg('number','Boo 2','info');

g_form.showFieldMsg('number','Boo 3','error');

g_form.showFieldMsg('predicted_growth','Boo 4','info');

g_form.showFieldMsg('variables.predicted_growth','Boo 5','info');

g_form.showFieldMsg('variable.predicted_growth','Boo 6','info');

g_form.showFieldMsg('cat_item','Boo 7','info');

Line 1 shows the message and the value of the variable.

Lines 2, 3 and 7 all add the test message as expected on fields in the sc_req_item

Line 4 works on the Service Catalog - not in this sc_req_item

Lines 5 and 6 were me trying something different.

anyone got any ideas

Cheers

1 ACCEPTED SOLUTION

manikorada
ServiceNow Employee
ServiceNow Employee

Julian,



This is a bug with Service Now where certain function doesn't work on Requested Item.


You can check this from : https://hi.service-now.com/kb_view.do?sysparm_article=KB0547171&sysparm_order=6aecdfc487ccc100957bb3...


As a workaround, have your function something like this:



var theForm = typeof g_sc_form != "undefined" ? g_sc_form : g_form;


theForm.showFieldMsg('number','Boo 2','info');  


theForm.showFieldMsg('number','Boo 3','error');  


theForm.showFieldMsg('predicted_growth','Boo 4','info');  


theForm.showFieldMsg('variables.predicted_growth','Boo 5','info');  


theForm.showFieldMsg('variable.predicted_growth','Boo 6','info');  


theForm.showFieldMsg('cat_item','Boo 7','info');


View solution in original post

2 REPLIES 2

manikorada
ServiceNow Employee
ServiceNow Employee

Julian,



This is a bug with Service Now where certain function doesn't work on Requested Item.


You can check this from : https://hi.service-now.com/kb_view.do?sysparm_article=KB0547171&sysparm_order=6aecdfc487ccc100957bb3...


As a workaround, have your function something like this:



var theForm = typeof g_sc_form != "undefined" ? g_sc_form : g_form;


theForm.showFieldMsg('number','Boo 2','info');  


theForm.showFieldMsg('number','Boo 3','error');  


theForm.showFieldMsg('predicted_growth','Boo 4','info');  


theForm.showFieldMsg('variables.predicted_growth','Boo 5','info');  


theForm.showFieldMsg('variable.predicted_growth','Boo 6','info');  


theForm.showFieldMsg('cat_item','Boo 7','info');


Quick test and all looking good


I'll put the real code in tomorrow



Cheers