- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2025 03:27 AM - edited 01-24-2025 03:31 AM
Hi All,
We have two service offerings as below.
Candidate Hotel
Hotel Active
If any location is listed on both offerings ('service_subscribe_location' table), the location should be removed from the "Candidate Hotel" service offering.
And in future also, if any new location is added for "Hotel Active" service offering, it should check "Candidate Hotel" service offering and remove from there.
Could you please help me on this?
Thanks & Regards.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2025 04:01 AM
We can use of following script in After BR when record is created/update on service_subscribe_location' table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2025 04:01 AM
We can use of following script in After BR when record is created/update on service_subscribe_location' table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2025 04:08 AM
you may write the Async business rule to acheive this.
Name: remove location for CandidateHotel
Table: service_subscribe_location
Advanced: true
Active: true
When to run:
When: Async
insert -- true
update -- true
Filter conditions:
Service offering is Hotel Active [OR]
Service offering is Candidate Hotel
Advanced:
Script:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideAggregate('service_subscribe_location');
gr.addQuery('service_offering=SYSIDOFCANDIDATEHOTEL^ORservice_offering=SYSIDOFHOTELACTIVE^cmn_location='+current.getValue('cmn_location'));
gr.addAggregate('COUNT');
gr.query();
if(gr.next())
{
if(gr.getAggregate('COUNT') >=2)
{
var gr2= new GlideRecord('service_subscribe_location');
gr2.addEncodedQuery('service_offering=SYSIDOFCANDIDATEHOTEL^cmn_location='+current.getValue('cmn_location'));
gr2.query();
if(gr2.next())
{
gr2.deleteRecord();
}
}
}
})(current, previous);