Disclaimer
This is a quick and dirty way to pass data from a UI action to a Business rule.
It’s just a proof of concept. Don’t use it. It might break at any point.
If you think you need to use this, you are probably dealing with a poor design. Review the process and why you want to do this.
I’ve used it only once in 10 years and I couldn’t sleep well until that script disappeared from the production instance.
The (weird) requirements
You have a UI action in the Problem form that updates its related incidents.
You have a Business rule in the Incident that adds a comment when the Incident is updated.
The comment will indicate if the update was either triggered by that UI Action or by something else.
In the UI Action (Problem)
Add a temporary property to the GlideRecord object.
Notice that there is no need to create a new field in the table.
You are modifying the object in runtime.
var incident = new GlideRecord('incident');
incident.addQuery('problem_id', current.sys_id);
incident.query();
while (incident.next()) {
incident.work_notes = 'Updating from the custom UI action';
incident.dontDoThis = true; //Dirty workaround!!!
incident.update();
}
Code language: JavaScript (javascript)
In the Business Rule (Incident)
Check the temporary property in your business rule and add a different comment depending on the trigger.
(function executeRule(current, previous /*null when async*/ ) {
if(current.dontDoThis){
current.comment = 'Updating from custom UI Action';
}else{
current.comment = 'Updating from somewhere else';
}
})(current, previous);
Code language: JavaScript (javascript)
Updating the Incident using the UI Action in the Problem form

Updating the Incident directly in the Incident form

Conclusions
- This is a weird workaround and can be confusing for somebody else and even for your future self.
- Try other approaches if possible.
- If you ignore my warnings and implement it, at least comment the code and document it very clearly.