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.

Make active filed as true in target table while importing data through data source(excel)

Devi D
Tera Expert

Hi Everyone ,

When we are importing data into user table through data source .

Currently when "Active" field is not filled in the excel sheet for a record , the value in the active field is populated a "False" for that record. During new record creation , ensure that default value of active field is taken as "True".

For this i have written code in 2 way as below and both are on before transform and not working.

option1 : not working

{

if (action=='insert'){

target.active =true;

}

 

option2 : not working

 

{

if (action=='insert'){

var gr=new GlideRecord('sys_user');

gr.addQuery('user_name',source.u_user_id);

gr.query();

if(gr.next()){

gr.active =true;

gr.update();

}

Kindly help me on this .

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Devi D 

please share your complete field mapping screenshot, transform map screenshot and transform script screenshot

this should work in onBefore transform script

{
if (action=='insert'){
target.active =true;
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

9 REPLIES 9

Not working

Keshav72
Tera Contributor

Hi @Devi D 
You can write onBefore transform map event script,

if (action == 'insert') {
    target.active = true;
}

 
If my answer helful and related to the question asked. Please mark it as correct and helpful.
Thank you,

I have already tried this and not working.

Ankur Bawiskar
Tera Patron
Tera Patron

@Devi D 

please share your complete field mapping screenshot, transform map screenshot and transform script screenshot

this should work in onBefore transform script

{
if (action=='insert'){
target.active =true;
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I have already tried this , but it is not working . Kindly check the attached screen shots .