- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2021 12:54 AM
Hi,
We have a Brand table in which I have created a list controller location field to select multiple location in one brand. And we have an application services table which has brand field referencing to brand table and location field referencing to location table and i have created a checkbox in this table.
The requirement is when we add any location in the multiple select field in brand table then it should make checkbox true of the application service related to that brand and location.
Say in Brand : dove we have locations US,Gemany&Australia and if we add any location suppose India to it then in application service table below application service checkbox should be true:
application service: dove.us, brand-dove,location-US
application service: dove.gr, brand-dove,location-Germany
application service: dove.aus, brand-dove,location-Australia
application service: dove.india, brand-dove,location-India
below is the after BR when location changes that i have written but its not working:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var dollar = new GlideRecord('u_cmdb_ci_application_service');
dollar.addQuery(u_brand, current.u_name);
dollar.addQuery(location, current.u_billion_dollar_brand_location);
dollar.query();
while (dollar.next()) {
dollar.u_billion_dollar_brand=true;
dollar.update();
}
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2021 04:32 AM
then try this one
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var dollar = new GlideRecord('u_cmdb_ci_application_service');
dollar.addQuery('u_brand', current.sys_id);
dollar.addQuery('location','IN', current.u_billion_dollar_brand_location.toString());
dollar.query();
while (dollar.next()) {
dollar.u_billion_dollar_brand=true;
dollar.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2021 03:35 AM
Hi,
it means your query is not able to find records into the table
Are you using the correct field name for location?
Should it not be u_location as your table is custom table
Try to update as this
dollar.addQuery('u_location', current.u_billion_dollar_brand_location);
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
‎02-10-2021 04:15 AM
dollar.addQuery('u_brand', current.u_name);
I checked the log with only brand but its not giving the row count for this as well.
In Brand table we have Field "u_name" which contains the brand name and in application services table there is a reference field "u_brand" referencing to brand table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2021 04:22 AM
Hi,
So try updating as this
Use the field on the table being referred by u_brand here
dollar.addQuery('u_brand.fieldName', current.u_name);
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
‎02-10-2021 01:53 AM
Can you try this
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var dollar = new GlideRecord('u_cmdb_ci_application_service');
dollar.addQuery('u_brand', current.u_name);
dollar.addQuery('location','IN', current.u_billion_dollar_brand_location.toString());
dollar.query();
while (dollar.next()) {
dollar.u_billion_dollar_brand=true;
dollar.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2021 03:43 AM