Transform Map - Active Users only

Vengeful
Mega Sage

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 @Vengeful , 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

Sohail Khilji
Kilo Patron
Kilo Patron

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


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Tai Vu
Kilo Patron
Kilo Patron

Hi @Vengeful 

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

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

Merza_0-1702887595800.png

 

Merza_1-1702887627938.png