Assign change task from Outlook

RC19
Tera Expert

we send notifications whenever change task is created, users want a button in email similar to Approve/Button buttons in approval emails. which ever user clicks on that button, change task needs to get assign to him if it is still unassigned . is this possible ?

1 REPLY 1

HasanM
Tera Guru

Hi @RC19 ,

Yes, this is possible. There are two ways to do it.

Approach 1: Email reply button (like Approve/Reject)

The approval buttons are mailto links that create a reply, and an inbound email action processes the reply.

  1. Create an email template, for example named mailto.assign_to_me, on change_task:
    Subject: Re: ${number} - Assign to me
    Message: Click send to assign ${number} to yourself.

  2. Add ${mailto:mailto.assign_to_me} to your change task notification's message HTML. Keep the watermark on the notification, because it's how the reply is matched back to the task.

  3. Create an inbound email action:
    Target table: Change Task [change_task]
    Action type: Record action
    Type: Reply
    Condition: email.subject.toLowerCase().indexOf('assign to me') > -1

Script:

(function runAction(current, event, email, logger, classifier) {
if (!current.assigned_to.nil()) {
return;
}
var userId = email.from_sys_id;
var gm = new GlideRecord('sys_user_grmember');
gm.addQuery('group', current.assignment_group);
gm.addQuery('user', userId);
gm.query();
if (gm.hasNext()) {
current.assigned_to = userId;
current.update();
}
})(current, event, email, logger, classifier);

Approach 2: Outlook Actionable Messages (OAM)

With OAM, the user clicks "Assign to me" inside Outlook, and the task is assigned without the user sending an email or logging in.

  1. Register your sender in Microsoft's Actionable Email Developer Dashboard and get it approved for your tenant.
  2. Create a Scripted REST API in ServiceNow that takes the change task sys_id and assigns the task to the calling user if it's still unassigned (with the same group membership check as above).
  3. In the notification, embed an Adaptive Card with an Action.Http button that calls that REST endpoint.
  4. In the REST API, validate the token Microsoft sends with each request. This confirms the call came from Microsoft and tells you which user clicked. Don't skip this step, or anyone could call the endpoint.

Which to choose:
Approach 1 is quick to build and fully configurable in ServiceNow, but the user has to press Send. The sender's email must match an active sys_user record.
Approach 2 gives a one-click experience inside Outlook, but it needs Microsoft-side registration, a custom secured endpoint and Outlook clients that support actionable messages. It's more effort to build and support.

With either approach, if several people click at once, the first one wins, because the task is only assigned while it's still unassigned.

Please test in a sub-production instance first.

Hope this helps. If it does, please mark it as helpful or accept it as the solution.