- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-01-2015 06:07 PM
Hi All
Im trying to highlight all newly updated calls (non itil role) in light blue, so that they are easy to spot by our users that have the itil role. Then once updated by a itli role user the call should immediately remove the blue background.
I've seen something quite close to what I want in a blog by MB Incident updates - colouring in the number, but I need the update to be triggered from a caller sending return update via email.
The table name I'm going to use as an e.g. is u_special.
I'd appreciate some help with the BR script. I want it simply to run after an update to the call and write a string into a field.
The business rule
name will be brHighlight
Active, Advanced, insert, update, query are all ticked
When: After
Condition: none
Script:
\\ i want to highlight new calls and calls updated by a caller and script should set string value "Special Caller" into a field called 'Update Type' on the u_special table that will be hidden. The Assign to should not trigger as their updates never need to be highlighted.
if (current.operation() == 'insert' && current.comments.changes() != 'current.assigned_to') {
setDisplayValue('Special Caller', current.u_update_type);
}
Style Module
Value: javascript:current.u_update_type == "Special Caller"
Style: background-color:lightblue
Field Name: Updated
Table Name: u_special
Table
Table Name: u_special
Field Column Name: u_update_type
Field Label Name: Update Type
Thanks TC
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2015 05:51 PM
Hi Tony,
All right, lthat clarifies things.
This form is for the table "u_special" and u_special extends Task. Incident (literally the table named incident) has no part in this.
You want the value of u_update_type on the u_special table to change as stuff happens.
The Caller is stored in the u_caller field, the Assigned to person is in the assigned_to field.
To clarify some of my earlier comments: sys_updated_by exists on the record, whether you show it on the form or not. It's a base system field, and is on every table. We can ignore that though, and use the gs.getUserName() call if this will be updated interactively (not via an import or integration, but by a person actually filling in a form and clicking a button to submit it).
Similarly, assigned_to is on the Task table, which is why your u_special inherits it. The caller_id field I mentioned in an earlier post is on the Incident table, which is why you don't have that on your u_special table- you don't inherit it, because you extend Task, not Incident.
Given your answers, you need a condition like this:
current.u_caller.hasValue()
All that condition does is make sure the Business Rule runs only if the Caller is actually populated. This should be a Before Insert/Update rule on the u_special table.
To make your script work, we use the more complicated version I posted before, adjust for the understanding that this not on the Incident table (or an extension of it) but instead is for this totally different u_special table which extends Task.
//who is making this update right now
var updater = gs.getUserName();
//reset the update type - this makes the value blank unless the
//updater is the Assigned to user or the Caller
current.u_update_type = "";
//do the assigned_to logic
if(current.assigned_to.hasValue() && current.assigned_to.user_name == updater)
current.u_update_type = "Commented";
//do the Special Caller logic
if(current.u_caller.hasValue() && current.u_caller.user_name == updater)
current.u_update_type = "Special Caller";
If you leave this as-is, then the u_update_type will have 3 possible values:
- Empty because the person doing the update or insert is neither the Caller nor the Assigned to user
- Commented because the person doing the update is the Assigned to user
- Special Caller because the person doing the update is the Caller
If you want there to be only two possible values- Commented and Special Caller, then remove line 06 and Line 09. Then it will always be either Commented or Special Caller, so long as the Caller field is actually populated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2015 06:55 AM
Condition:
(current.caller == current.updated_by) || (current.assigned_to == current.updated_by)
Script Section:
if(current.caller == current.updated_by){
current.u_update_type = "Special caller";
}
else{
current.u_update_type = "";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2015 08:39 AM
Thanks Deepak
problem is still that when the Assigned to user (which is generally a different user) updates the call the 'Special Caller' value still remains and is not cleared.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2015 09:17 AM
Could you please share screenshot of the code you have written.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2015 09:25 AM
Hi Tony,
Deepak's last version of the script is supposed to address exactly that issue.
This condition says "if the update is being made by the caller or the assigned_to person" (assuming you have a custom field named "updated_by" on the record, since that isn't an out-of-box field). I am assuming, of course, that this rule is run on Insert or Update on the Incident table, as a Before rule.
(current.caller == current.updated_by) || (current.assigned_to == current.updated_by)
If your condition matches, then the Business Rule script sets the value of the "u_update_type" field to either an empty string or to "Special Caller", depending on which half of the condition above matched:
if (current.caller == current.updated_by) {
current.u_update_type = "Special caller";
} else {
current.u_update_type = "";
}
If this isn't working for you, then either the condition isn't matching, or some other rule is changing the u_update_type later on.
The first thing to check is your condition. Is "updated_by" a valid field on this table, and is it a reference to sys_user? The default field for tracking the "updated by" person on a Task is "sys_updated_by" and it holds a user_name- it's not a reference to the sys_user table. It's a string.
If you mean to use the OOB field, then you need to compare the user_name of the person doing the update against the value in sys_updated_by. We can simplify our condition:
current.caller.hasValue()
In the script, we need to get the user_name of the person making this update, and then compare that to the caller. If it's true, the value in u_update_type will end up as "Special caller". In all other cases, it will be blanked out.
//who is making this update right now
var updater = gs.getUserName();
//reset the update type
current.u_update_type = "";
//now actually do the Special Caller logic
if(current.caller.user_name == updater)
current.u_update_type = "Special caller";
There is no need to compare against assigned_to if you only care about two cases:
- The person making the update is the same person as the caller
- The person making the update is not the same person as the caller
If that's all you care about, then assume that the person making the update isn't the caller, and then do a check to verify.
If you actually have 3 cases:
- The person making the update is the same person as the caller.
- The person making the update is the same person as the assigned_to user.
- Anything else
Then your condition and script will be slightly more complicated, bit still pretty easy:
current.caller.hasValue() || current.assigned_to.hasValue()
Script:
//who is making this update right now
var updater = gs.getUserName();
//reset the update type
current.u_update_type = "";
//do the assigned_to logic
if(current.assigned_to.hasValue() && current.assigned_to.user_name == updater)
current.u_update_type = "Assigned to";
//do the Special Caller logic
if(current.caller.hasValue() && current.caller.user_name == updater)
current.u_update_type = "Special caller";
Here you are setting the u_update_type to "Assigned to" if the person doing the update is the same as the assigned_to user. If the person doing the update is the caller, than the value will be "Special caller". In all other cases, the value will be empty.
You need to validate that you are looking at the correct fields and that those fields have the values you think they do. The above scripts are examples of you can accomplish what you want using the OOB "sys_updated_by" field. If you really do have a field named "updated_by" then you need to verify that the values you get out of it are what you expect, or adjust your scripts accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2015 09:29 AM
Nice info Cory.