How to fetch list of users where email before @ is not same as UPN (User Principal Name) before @
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
How to fetch list of users where email before @ is not same as UPN (User Principal Name) before @
I want to fetch list of users where email before @ is not same as UPN before @ on user table but I am not able to achieve it by background script, it's returning all the users, please advise how I can get this data ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hi @Priya Singh 2 2 ,
This way we have fixed it .
( in our case , we are checking with lots of field in sys_user after the data analysis, you also please analyze your data and update the query and data accordingly). You can follow the same.
Create a Before insert,update BR on subscription table, which will execute at the end (highest order) ..Give proper trigger condition.
Sample screen shot.
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 and confirm whether your issue fixed or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
