- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2017 08:21 AM
Hi All,
I was asked to make a pretty simple business rule but it turns out I need to script in order to get it to work.
Could anyone help me with the following? (Don't worry, we just hired a resource and I will be sharing this as an example so we can write our own soon)
I have added a field to our LOCATIONS table (cmn_location) called "Stock Control". It's a reference field to users. The plan is to use the field to assign hardware requests when the Assignment group is changed to "Stock Control".
Here's the pseudo script on the REQUEST TABLE.
Before
Insert/Update
IF 'Assignment Group' changes to "ITSM - StockRoom", Set the "Assigned to" to Same as 'location.u_stock_control_ref'
Please help if you can.
Thank you,
Carl
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2017 09:16 AM
Hello Carl,
Create the Before business rule with filter condition i.e assignment group | changes to | ITSM - StockRoom with scripts as
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.assigned_to = current.location.u_stock_control_ref;
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2017 10:42 AM
This is working but the asset manager asked if I could clear the assigned to when it changes back.
So if Assignment Group is Stock Room, and it changes to Purchasing, I want the assigned to be cleared

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2017 11:19 AM
Yes, you can do this as
if(current.assignment_group.changesTo('ITSM - StockRoom')) //Assuming ITSM - StockRoom is the group name
{
current.assigned_to = current.location.u_stock_control_ref;
}
else
{
current.assigned_to = '';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2017 02:00 AM
This wouldn't be specific to logs changing from "ITSM - StockRoom" to *something else*.
The 'assigned_to' will be cleared, if the assignment group changes, on all records in the table that has this business rule.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2017 08:53 AM
You are right Lee. We need to define condition filter to trigger this BR only when Assignment group | Changes to | ITSM- StockRoom OR Assignment group | Changes From | ITSM_ StockRoom.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2017 12:57 PM
Thanks to all who replied. Pradeep was able to send me something I could use right away so he get's the correct answer!