How can we configure Business Rule so that the data in expiring date field gets updated on template
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2024 12:25 AM
I have added a field as Expiring date(u_expiring_date) on a standard change proposal (std_change_proposal) whenever a request is submitted to modify or create a change template expiring date field is getting updated on Standard Change Proposal (std_change_proposal), how can we configure Business Rule so that the data in expiring date field gets updated on Standard Change template (std_change_record_producer).
Business Rule I have written on std_change_proposal table :
(function executeRule(current, previous /*null when async*/ ) {
var c = current.current_version;
var recordp = new GlideRecord('std_change_record_producer');
recordp.addQuery('sys_id', c);
recordp.query();
if (recordp.next()) {
recordp.u_expiring_date = current.u_expiring_date;
recordp.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2024 03:19 AM
Hi @divyal09 Try below code
(function executeRule(current, previous /*null when async*/ ) {
if (current.current_version) {
var recordp = new GlideRecord('std_change_record_producer');
recordp.addQuery('sys_id', current.current_version);
recordp.query();
if (recordp.next()) {
recordp.u_expiring_date = current.u_expiring_date;
recordp.update();
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2024 04:52 AM
The data in expiring date field is not getting updated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2024 04:04 AM
I think my partner's Sid_Takali script is the correct one, have you been able to test it?
(function executeRule(current, previous /*null when async*/) {
if (!current.current_version.nil()) {
var recordp = new GlideRecord('std_change_record_producer');
recordp.addQuery('sys_id', current.current_version);
recordp.query();
if (recordp.next()) {
recordp.u_expiring_date = current.u_expiring_date;
recordp.update();
}
}
})(current, previous);
If it doesn't work, try the following one, which is very similar. Best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2024 04:53 AM
I tried but data is not updating in the field