- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 04:13 AM
We create Demand [dmn_demand] record, then create enhancement [rm_enhancement] record from the demand record. the demand state changes to Approved once enhancement is created.
My request is when we close enhancement record, update the demand state to Complete.
Any help/thoughts is be appreciated!
Regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 12:39 AM
The flow should look like this:
And if you insist on using a BR, why not make it simple? Trigger it after update of the enhancement with state = closed and use this:
var demand = new GlideRecord('dmn_demand');
demand.addQuery('enhancement',current.getUniqueValue());
demand.addActiveQuery();
demand.query();
while(demand.next()){
demand.setValue('state', 9); // completed
demand.update();
}
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 05:53 AM
Thanks Sohail for your help i appreciated
I don't have demand field in enhancement form. i created after update BR on enhancement table [rm_enhancement]. I think still something is missing in my script! if you can take a look at it.
(function executeRule(current, previous /*null when async*/ ) {
if (current.state.changesTo('Closed Complete')) {
var enhState = new GlideRecord('dmn_demand');
enhState.addQuery('dmn_demand', current.sys_id);
enhState.addQuery('active', true);
enhState.query();
if (!enhState.next()) {
var demState = current.dmn_demand.getRefRecord();
demState.state = 'Complete';
demState.update();
}
}
})(current, previous);
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 12:39 AM
The flow should look like this:
And if you insist on using a BR, why not make it simple? Trigger it after update of the enhancement with state = closed and use this:
var demand = new GlideRecord('dmn_demand');
demand.addQuery('enhancement',current.getUniqueValue());
demand.addActiveQuery();
demand.query();
while(demand.next()){
demand.setValue('state', 9); // completed
demand.update();
}
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 04:49 AM
The BR worked perfect...
Thanks Mark!