List of current objects accessible by script?

robbbryn
Kilo Contributor

I'm brand new to ServiceNow and it's scripting engine and have been digging through the documentation that is available but am stuck on one issue.   Is there a list of accessible objects or any way to generate a list?

For Example:

I'm building a list definition for use on a content page.   The list is based on the "Change Request" table and I want to show the short description, planned start date, planned end date, and the first X characters of the body of the request.

I know that ${current.short_description.getDisplayValue()} will give me the title... but how do I find out any other objects that I can access in scripts short of guessing each object.   Is there any way to generate a list of all accessible objects for a record?

1 ACCEPTED SOLUTION

coryseering
ServiceNow Employee
ServiceNow Employee

Hi Robert,



You can access any of the fields on Change Request. If you want to know what those fields are, go to the Tables module, which should open the list view for the sys_db_object table:


Screen Shot 2015-09-16 at 9.18.39 AM.PNG


Find the Change Request table in this list, and scroll down to the Columns:


Screen Shot 2015-09-16 at 9.19.37 AM.PNG



You can access any of the columns using the same JEXL syntax:


${current.location.getDisplayValue()}


$$current.comments_and_work_notes}


${current.opened_at}


${current.priority}


...and so forth.


View solution in original post

4 REPLIES 4

yetesh_ch
ServiceNow Employee
ServiceNow Employee

Hi,


You can use getFields() method.



var fields = current.getFields();



// Enumerate GlideElements in the GlideRecord object that have values


gs.print('Enumerating over all fields with values:');


for (var i = 0; i < fields.size(); i++) {


  var glideElement = fields.get(i);


  if (glideElement.hasValue()) {


      gs.print(glideElement.getName());


  }


}


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Robert,



In addition, you may find the below link helpful.


http://wiki.servicenow.com/?title=Scripting_for_Email_Notifications


coryseering
ServiceNow Employee
ServiceNow Employee

Hi Robert,



You can access any of the fields on Change Request. If you want to know what those fields are, go to the Tables module, which should open the list view for the sys_db_object table:


Screen Shot 2015-09-16 at 9.18.39 AM.PNG


Find the Change Request table in this list, and scroll down to the Columns:


Screen Shot 2015-09-16 at 9.19.37 AM.PNG



You can access any of the columns using the same JEXL syntax:


${current.location.getDisplayValue()}


$$current.comments_and_work_notes}


${current.opened_at}


${current.priority}


...and so forth.


Thanks everyone... that's exactly what I was looking for.