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 change value of reference field from some value to blank.

d_kush
Giga Contributor

Hi ,

I am trying to populate a reference field from transform map using field map script. I need to clear out this reference field value sometimes, through field script. so i have given value ='NULL' in the else condition of script.. but it is creating below problems

1. first of all it was not clearing the field value at all.

2. when i have created a null value in the referenced table, then it is clearing field value but it is not making it null, means in the filter it is showing it has empty value, but i want to make this value as blank.

here is my questing is it possible to make reference field value as blank? or

To change reference field value to blank always we need to create an empty field in referenced table?

Thanks

13 REPLIES 13

geomathew
Giga Contributor

your first line in the script should be like below...



      var managedBy = 'NULL';



pls try and   confrim.


d_kush
Giga Contributor

'NULL' and 'null' are working in same way..


geomathew
Giga Contributor

Below code I am using in one of my scheduled job...which properly setting empty value in "assigned_to" which is a ref field....can you share ur code where you setting the value into ur glide record field.


-------------------------------------------------------------------------------------------------------------------------------------------------------------------


  var B= new GlideRecord('incident');


    B.addQuery('sys_id',A.u_ticket_id);


    B.query();


    if(B.next())


          {


                if (arrSplit[0].toString() == 'undefined')


                      B.assigned_to = 'NULL';


                else


                      B.assigned_to = arrSplit[0].toString();


                B.update();


d_kush
Giga Contributor

find_real_file.png


I am using above script in filed map script of transform map (assigning result to answer which is managed by field of business service table) and it is working fine , but it is setting an empty value to reference field in place of setting null value.