How to write Script include on cmn_location table to give lookup list Status=Active
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2024 10:39 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2024 12:45 AM
You can follow this example. This script include will return an array of location names.
javascript
var LocationLookup = Class.create();
LocationLookup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getLocationList: function() {
var locationArray = [];
var locationGR = new GlideRecord('cmn_location');
locationGR.query();
while(locationGR.next()) {
locationArray.push(locationGR.name.toString());
}
return locationArray;
},
type: 'LocationLookup'
});
Here's a summary of the steps:
- Create a new Script Include in ServiceNow.
- Name the Script Include "LocationLookup".
- Extend the AbstractAjaxProcessor class to allow the script to be called via AJAX.
- Create a new method called "getLocationList".
- Inside this method, create a new GlideRecord object for the 'cmn_location' table.
- Query the table and loop through the results.
- For each record, push the name of the location to the locationArray.
- Return the locationArray, which now contains a list of all location names.
Please note that this is a very basic example and may need to be adjusted based on your specific requirements.
Regrds
Shaqeel
***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
***********************************************************************************************************************
Regards
Shaqeel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2024 02:42 AM
Just to be clear with the requirement , you want to populate only those locations in the lookup list which are active. If yes, can you please let me know where you want to populate this list i.e. either on a Catalog Variable or somewhere else ?
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2024 10:28 PM
Approval Matrix conditions
Assignment Rules conditions
Catalog Task Rules conditions
On the above records we given location condition when we click the lookup using list it will go the cmn_location table. So, i want to on location table.