Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get Current user and current user Domain in transfrom Script

ursnani
Giga Guru

Hi All,

I have transform map in which I have a script for Reference field.

If the user is X domain and Trying to Load the data for Y domain it should not accept. It should must accept the Data of X domain and transform the data to target Table.

I tried using the below code :

var DID = gs.getUser().getDomainID();
gs.log('Domain ID is ==',DID);
var Domain = current.sys_domain;

gs.log('Current Domain is',Domain):

 

The first log returning as Empty and the second log is not identify its saying that sys_domain is not defined or null.

 

Can someone please help me with this Transform map.

 

1 ACCEPTED SOLUTION

ARG645
Tera Guru

Problem is with your Log statements. You are passing in a second parader to the gs.log function by using comma, use a concatenation operator(+)

gs.log("message","source"); 

Change to this: 

var DID = gs.getUser().getDomainID();
gs.log('Domain ID is =='+DID); // changed comma to plus
var Domain = current.sys_domain;// Current in Transform Map?  Are you sure ?

gs.log('Current Domain is'+Domain); // changed comma to plus

View solution in original post

6 REPLIES 6

While Loading the Data we will select the Import set table and the File to be loaded into that Importset table

 

I have a transform map which imports data from Import table to Target Table.

And I will be in that particular domain while loading the data.

 

We have the Domain picker where we can select the Domain we want.

Jim Coyne
Kilo Patron

Did you find a solution to your issue?  If yes, please remember to tag the correct answer and any that were helpful.