- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2020 11:20 AM
Hi All,
Just a small query.
I have Variable which is referring to custom table.
Custom Table :
Role Display is Reference variable and above "Test Table" is used for reference. So When i select US-Store in the "Role Display" it should show relevant "US"country related location in the "Location" variable. here if US-STORE (then it is US country store. If they select (NZ-Store) then its is News Zealand country store.
So i tried script include and reference qualifier like below. But whatever i tried that is static one. I just wants to change that to dynamic one as per above logic.
Script Include :
getLocation: function(role_display) {
var gr=new GlideRecord('cmn_location');
return 'country=Australia^u_active=true';
},
Reference Qualifier :
javascript:new LocUtils().getLocation(current.variables.role_display)
Its working as expected. but if i have one store then it should be fine but i have many stores. So i just wanted to change this to dynamic one. can anyone help me on this?
Thanks in Advance!!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2020 02:02 AM
I have created script include and called the script include in the reference variable using advance.It worked .
Thanks all for your support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2020 12:15 AM
Hi Sanjiv,
US-Store is Role in my custom table. You can see here. If that role selected in Role Display variable then in the Location variable it should show US country related location details(Location variable is referenced to cmn_location table) . Maybe my previous response would have confused you (sorry for that).
Hope this is clear.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2020 12:26 AM
Hi Rani,
do you have some field on cmn_location table which holds the role i.e. US-Store
if yes then directly you can have something like this in advanced ref qualifier and no script include needed
javascript: 'role_field=' + current.variables.role_display;
If you want to use script include then you need to query it like this
getLocation: function(role_display) {
var arr = [];
var gr=new GlideRecord('cmn_location');
gr.addQuery('role_field', role_display);
gr.query();
while(gr.next()){
arr.push(gr.sys_id.toString());
}
return 'sys_idIN' + arr.toString();
},
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2020 06:02 AM
Hi Ankur,
No .I dont't have US-Store in cmn_location table. Its only in my custom table.
Only this if i select Role Display : US-Store from my custom table then it should show US related location in Location variable.
In my script include somewhere i have to say to the system like if role display is "US-Store" then go and search for US country related record in cmn location table and show it in Location variable.
Something like this.
Role Display: Referenced to "Test Table"
Location : Referenced to "cmn_location"
So when selection of Role Display, Location should populate like this.
I hope its clear now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2020 07:52 AM
Hi Rani,
So if you don't have any field on cmn_location table to hold the information how the query can be made?
Are you saying you want to search for the name i.e. US-Store in the name field of location table
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2020 10:14 AM