- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2024 12:53 AM
Hi,
We have a need to clear a variable value (social security number) in the sc_task table and the sc_req_item, when a SCTASK is completed and closed (Closed Complete, Closed Incomplete and Closed skipped). Reason is that we should not store social security number values in these tables in Servicenow.
The value needs to be cleared before the Request completed, Request Cancelled etc notification is sent out since we include variables in the notification.
I assume that this could be done using a Business rule, but how should I write the script?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2024 01:44 AM
you can use before update BR on sc_task and have this script
Condition: current.request_item.cat_item.name == 'Your Item Name Here' && State [IS ONE OF] Closed Complete, Closed Incomplete, Closed skipped
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.variables.variableName = '';
var ritm = current.request_item.getRefRecord();
ritm.variables.variableName = '';
ritm.update();
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2024 01:44 AM
you can use before update BR on sc_task and have this script
Condition: current.request_item.cat_item.name == 'Your Item Name Here' && State [IS ONE OF] Closed Complete, Closed Incomplete, Closed skipped
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.variables.variableName = '';
var ritm = current.request_item.getRefRecord();
ritm.variables.variableName = '';
ritm.update();
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2024 02:40 AM
Thank you Ankur your response were very helpful!