We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Microsoft 365 SaaS Integration - Why is Software Usage mapped using UPN instead of Email Address?

Tejaswini Morey
Tera Contributor

Hello everyone,

We are using the Microsoft 365 SaaS Integration with ServiceNow SAM Pro and have observed that user records in the Software Usage table appear to be matched based on the User Principal Name (UPN).

In our Azure environment, some users have a different UPN and email address. Because of this, we are seeing cases where user information is not mapped correctly in ServiceNow.

Could you please clarify:

  1. Why does the Microsoft 365 SaaS Integration use UPN for user matching instead of the email address?
  2. Is there a specific reason email addresses are not used as the primary identifier?
  3. Can ServiceNow be configured to use the email address for matching users, or to match using both UPN and email address?
  4. What is the recommended approach when UPN and email address are different in Azure?

Any guidance would be appreciated.

Thank you.

1 REPLY 1

Tanushree Maiti
Tera Patron

Hi @Tejaswini Morey 

 

1 & 2. At O365 end , UPN is unique field but Email is not mandatory one which means Email could be empty.

3. On Software Usage table - you can not do anything

4. Workaround :

Do following customization to solve the issue

 

Create a Before insert,update BR on subscription table, which will  execute at the end (highest order) ..Give proper trigger condition.

Sample screen shot.

TanushreeMaiti_0-1784644083683.png

 

 

 

Sample code (if any modification is required ,do it):

 

(function executeRule(current, previous /*null when async*/ ) {
var op = current.operation();

if (op == "update") {
if (current.user_principal_name && current.user == '') {
var upnp = current.user_principal_name;

var userGrp = new GlideRecord('sys_user');
userGrp.addEncodedQuery('email=' + upnp + '^ORuser_nameSTARTSWITH' + upnp );
userGrp.orderByDesc('sys_created_on');
userGrp.query();

if (userGrp.next()) {
current.user = userGrp.sys_id.toString();
}
} else {

var upn = current.user_principal_name;

var userGr = new GlideRecord('sys_user');
userGr.addEncodedQuery('email=' + upn + '^ORuser_nameSTARTSWITH' + upn );
userGr.orderByDesc('sys_created_on');
userGr.query();

if (userGr.next()) {
current.user = userGr.sys_id.toString();
}
}
}
})(current, previous);

 

Once done, Run the O365 job (OOB scheduled job  and  confirm whether your issue fixed or not.

 

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti