The CreatorCon Call for Content is officially open! Get started here.

Query question

amatthews
Kilo Explorer

I   am trying to pull back the records of a particular field in a table.   The query is done on the catalog task so I have to glide to the table where the records reside.   Can anyone tell me the best way to do this?   I have tried the following but not sure it is working:

var xx = new GlideRecord('table');

xx.addQuery('u_requested_item', g_form.getValue('sys_id');

xx.addQuery('fieldname');

xx.query();

while (xx.next()) {

                                                if (fieldname != '' && fieldname != null && action != 'close_task') {

                                                          alert(message);

                                                          return false;

At this point I receive the alert but the task will still close.   I want to prevent the task from closing until the 'fieldname' has been populated.   Any feedback is greatly appreciated.

7 REPLIES 7

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi,



Can you just add the else condition too in your script


Script:


else


{


return true;


}



Thanks,


Pradeep Sharma


Thanks, i did try adding the return true but the task still closes :-(.


Hi,



Can you please give some more info on this requirement with some screenshot.



Thanks,


Pradeep


My requirement is to display the following fields on the task for the desktop group to determine the following:


Field to display to Desktop Support:


  • Requires License Verification? (required) — Options will include: None (default), Yes and No.
  • Requires Software Assessment? (required) — Options will include: None (default), Yes and No.

The 'Requires Software Assessment? field in located in the Software table and the Requires License Verification? field is located in the Employee Software table.


I have tried creating a UI policy to make the fields mandatory but the action is not recognized on the task.   Not sure if this is because the two fields are located in seperate tables. I did a dot walk to the fields under the UI action section of the policy.   Since I have not found a way to make the fields mandatory,my next option is a client script.   I am using a client script to return false if the fields are not populated. Once again, I receive the alerts but once you close the alert the task can be closed with the fields blank.


SWR.png


Let me know if more info is needed.   Thanks for your feedback.