Automatically updating state field when sending email from the record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2012 07:59 AM
Hi guys,
I was just wondering if anyone had ever had the same requirements as myself or if anyone could point me in the right direction here.
We have a requirement whereby if a user sends an email from a record using the email client the state of that record should automatically update. For example; if Analyst A is looking at a record but needs more information he can use the email client to email User B. On sending this the email we would like the state to update to 'Awaiting User'.
Does anyone have any idea if this is possible and if so, how this can be achieved?
Thanks in advance,
PW
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2012 01:54 PM
Put this in a Before Business Rule:
if (current.operation() != 'insert' && current.comments.changes() && current.active == true && gs.hasRole('itil')) {
current.incident_state = 'value';
}
Change the conditions in the IF statement to fit your needs, as well as the incident_state value to whatever the value of your 'Awaiting User' choice is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2012 01:49 AM
Hi Derek,
Thanks for providing this information. I've tried something similar to this and having also tried this I have the same issue.
The issue is that users have the ability to add information to the record using the 'Additional comments' field; if a user updates a record with information in this field then effectively the current comments have changed and so the Business Rule then kicks off and updates the state to Awaiting User. What we need is the incident state updating only when an email is sent and not when the 'Additional comments' field is updated. Do you know if this is possible at all? If not then I may need to look at removing the 'Additional comments' field from the record.
Thanks again,
PW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2012 11:31 AM
If I understand what you're trying to do correctly, this code should work. Can you show me your business rule, including when it fires?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-01-2012 07:31 AM
Hi Derek,
Thanks again for the reply. I've tested this two ways; one by adding the script to an existing Business Rule and the other way but setting up an entirely new Business Rule.
The existing business Rule is:
When: BEFORE insert and update.
if (current.operation() != 'insert' && current.comments.changes()) {
gs.eventQueue("incident.commented", current, gs.getUserID(), gs.getUserName());
}
if (current.operation() == 'insert') {
gs.eventQueue("incident.inserted", current, gs.getUserID(), gs.getUserName());
}
if (current.operation() == 'update') {
gs.eventQueue("incident.updated", current, gs.getUserID(), gs.getUserName());
}
if ((current.incident_state == 6) || (current.incident_state == 7)) {
// incident state is closed so
// 1. mark the task as inactive
// 2. set the closed by to current user if not supplied
// 3. set the closed time to now if not supplied
current.active = false;
}
if (!current.assigned_to.nil() && current.assigned_to.changes()) {
gs.eventQueue("incident.assigned", current, current.assigned_to.getDisplayValue() , previous.assigned_to.getDisplayValue());
}
if (!current.assignment_group.nil() && current.assignment_group.changes()) {
gs.eventQueue("incident.assigned.to.group", current, current.assignment_group.getDisplayValue() , previous.assignment_group.getDisplayValue());
}
if (current.incident_state.changes() && current.incident_state == 18) {
gs.eventQueue("incident.awaitingchange", current, current.incident_state, previous.incident_state);
}
if (current.priority.changes() && current.priority == 1) {
gs.eventQueue("incident.priority.1", current, current.priority, previous.priority);
}
if (current.operation() == 'update' && current.priority == 1 && current.state == "Resolved") {
gs.eventQueue("incident.updated", current, gs.getUserID(), gs.getUserName());
}
if (current.category.changes() && current.category == "TCS") {
gs.eventQueue("incident.tcs", current, current.category, previous.category);
}
if (current.severity.changes() && current.severity== 1) {
gs.eventQueue("incident.severity.1", current, current.severity, previous.severity);
}
if (current.escalation.changes() && current.escalation > previous.escalation && previous.escalation != -1) {
gs.eventQueue("incident.escalated", current, current.escalation , previous.escalation );
}
if (current.active.changesTo(false)) {
gs.eventQueue("incident.inactive", current, current.incident_state, previous.incident_state);
gs.workflowFlush(current);
}
if (current.operation() != 'insert' && current.comments.changes() && current.active == true) {
current.incident_state = '8';
}
When I use the script on its own I simply use:
When: BEFORE insert and update.
if (current.operation() != 'insert' && current.comments.changes() && current.active == true) {
current.incident_state = '8';
}
As mentioned, this works fine if I update the record through the 'Additional comment' field however this is not what we want. We want the incident state to update ONLY when the email client is used. If a user updates the record through the 'Additional comment' field we do not want the incident state to update.
Thanks again,
PW