Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Transform Map - Active Users only

Not applicable

I created a transform map to create bulk incidents.

But the user that gets in the incident was the locked out/inactive users.

How can I get the active users?

 

Merza_0-1702884696439.png

 

I have this transform map onBefore script

Merza_1-1702885208067.png

 

 

1 ACCEPTED SOLUTION

SunilKumar_P
Giga Sage

Hi @Community Alums , Open the field mapping and enable the 'Use source script'  check box and try with below script.

 

answer = (function transformEntry(source) {
    var grUsr = new GlideRecord("sys_user");
    grUsr.addActiveQuery();
    grUsr.addQuery('user_name', source.u_user_id); //replace the addQuery as per your data
    grUsr.query();
    if (grUsr.next()) {
        return grUsr.sys_id; // return the value to be put into the target field
    } else {
        return '';
    }
})(source);

 

 

SunilKumar_P_1-1702889043476.png

 

 

 

Regards,

Sunil

 

View solution in original post

7 REPLIES 7

Not applicable

Do you mean to ask that the incident must be created only for active users ?

Not applicable

@Community Alums 

Yes

Tai Vu
Kilo Patron

Hi @Community Alums 

You can do your custom script in your Field Map, querying to get the Active User then return the User sys_id since you're doing mapping on the reference field User.

In your Transform Map, How do you currently map the User field? What is the User value in your Source (staging table)?

 

Cheers,

Tai Vu

Not applicable

@Tai Vu 
Here's the map for user field.

Merza_0-1702887595800.png

 

Merza_1-1702887627938.png