The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Can we use target.field in source script?

SD40
Tera Contributor

I have a requirement that is- 

If the target field value is empty then only return the source.field value to the target field.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can try to access it; if it doesn't work then don't use field map for that target field

instead use onBefore transform script

if(target.fieldName.nil()){

target.fieldName = source.u_fieldName;

}

Regards
Ankur

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

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can try to access it; if it doesn't work then don't use field map for that target field

instead use onBefore transform script

if(target.fieldName.nil()){

target.fieldName = source.u_fieldName;

}

Regards
Ankur

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

Hi,

I am using if(target.fieldName=='') ..because I am trying to find out if the dropdown is --None-- then only return else ignore or do nothing.

Should be fine

Thank you for marking my response as helpful.

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

Regards
Ankur

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

sawyan3
Tera Contributor

Hi ED,

For None the backend value is blank so you can mention

if(target.custom_field==''){

target.custom_field=source.field;

}

For your help

https://community.servicenow.com/community?id=community_question&sys_id=894917bedbd4e3882be0a851ca961957#:~:text=%2D%2DNone%2D%2D%20is%20blank.,-You%20can%20select