- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 09:25 AM
I have a Business Rule set to run before update. The trigger is working, but I cannot get the 'work_start' field to clear out. Any help is appreciated!
(function executeRule(current, previous /*null when async*/ ) {
// Check if the 'Assigned to' field changed
if (current.assigned_to != previous.assigned_to) {
// Check if the 'State' field changed from 'Work In Progress' (Value 18) to 'Accepted' (Value 17)
if (current.state == 17 && previous.state == 18) {
// Wipe out the 'Actual work start' field
current.work_start.setDisplayValue('');
}
}
})(current, previous);
I've also tried:
current.work_start = ''
current.work_start = null
Field Information:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 10:50 AM
I tried this in my mostly OOB PDI. current.work_start.setDisplayValue(''); and current.work_start = ''; are both working for me in a Business Rule on the wm_task table without the other lines. Add a gs.addInfoMessage line in the if block right before this one to see if it is getting reached. If not, keep logging until you see where it's going wrong. If this line is reached and you are still seeing a value on the updated record, perhaps you have another Business Rule that is also affecting this field value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 10:35 AM
Your screenshot shows that the work_start field is being displayed from the wm_task table. If you are not running this rule on the wm_task table, then you will need to do a GlideRecord query to return the related wm_task record, then set the value of the work_start field on that table and be sure to use your GR var name.update() to save the update to this related record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 10:40 AM
Hi Brad,
I am running the business rule on the wm_task table. Any ideas why my current script isn't clearing the field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 10:50 AM
I tried this in my mostly OOB PDI. current.work_start.setDisplayValue(''); and current.work_start = ''; are both working for me in a Business Rule on the wm_task table without the other lines. Add a gs.addInfoMessage line in the if block right before this one to see if it is getting reached. If not, keep logging until you see where it's going wrong. If this line is reached and you are still seeing a value on the updated record, perhaps you have another Business Rule that is also affecting this field value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 06:57 AM
Hi Brad,
Just wanted to follow up and let you know that you were correct. Both current.work_start.setDisplayValue(''); and current.work_start = ''; are working. While the triggers in my Business Rule were working as identified in a logging statement, for some reason the script did not work with the trigger and the action all together.
The script I was using with trigger and Action together:
However, once I separated the triggers from the action, it all worked.
Final BR looked like this: