Alternative email addresses lookup on approvals

KB15
Giga Guru

It's time I tackle this so I have a question. We have users with different email addresses (due to domain relationships). So when certain users attempt to approve a request, it'll reject them since their primary is not valid. I have a custom secondary email address field and just want to have ServiceNow check if the second email address matches.

I checked the inbound action called "Update Approval Request" and looking at this line:

function validUser() {
if (current.approver == email.from_sys_id)
return true;

Would it just be a simple addition of a condition or would I have to add a query?

10 REPLIES 10

KB15
Giga Guru

Great. That worked. Though before I say this is the perfect solution, I noticed that the approval shows up as a guest and not the me, the user, in the approval activity.

Would I have to place another change in the inbound action for emails to figure out who the user is?

Brian Dailey1
Kilo Sage

Hi kkim,

Please take a look at a blog I posted here a while back on handling multiple email addresses per user.  It uses the built-in Notification Devices to track multiple addresses per user, and works by catching/updating the email record before it gets written to the table.  So I think it should work on your Approval IEA without modifications, although I have not tested this.

It would solve your issue of updates getting recorded as by "guest".

Thanks,

-Brian

Hi Brian, I looked at this solution a few days ago and I don't know if it would be exactly what I'm looking for. I did try it out in a sub-prod instance. I already had the custom field filled in for the most users and I don't see an automatic method to do this. It's just the way that the organization prioritizes their addresses.

I may re-evaluate it at a later time.

I may have missed this but with our AD sync, would there be any issues?

No, we sync with AD and have no issues. This method simply relies on automatically populating a record in the Notification Device table whenever a user's email address changes. You could run a one-off fix script pretty quickly to create these records based on your existing secondary address field data. I would suggest populating the devices this way and trying it again in sub-prod to see how your IEA handles approvals. It should use the devices table as a lookup and change the Created By user for those email messages to the correct user. Then your downstream processes (like IEAs) don't know the difference... it treats it the same as if it was sent from a user's primary address. If you have questions, please feel free to post back here. -Brian

I forgot to mention, I was getting cross scope errors trying your scripts. Where would I fix that? I checked the application scopes and seems to be ok. I'm currently on Jakarta.

Access to api 'setWorkflow' from scope 'x_application' has been refused due to the api's cross-scope access policy

Would I also be able to check if the script worked by looking at a device entry?