Setting null values in the target table

kshitishchodank
Mega Contributor

Hi All,

I am very new to Service Now and using REST API. I am trying to update a particular field in the target table to null (e.g. : email), but it is not getting set. The problem is that I am sending only some columns in the REST request and other fields are not sent.   If I want to set any field as NULL or empty than the request is ignored. I enabled 'Copy empty fields' in the transform map but if the request does not contain all the fields, then the fields which are not sent in the request are set as empty. I tried using scripts but I wasn't successful and I think the values should be handled before they are inserted in the import table (I am likely to be wrong). Any help is highly appreciated as this issue is very urgent.

I went through this link How to clear out the field on target table via Web Service + Transform Map

Thanks in advance.

1 ACCEPTED SOLUTION

kshitishchodank
Mega Contributor

I am using onBefore script type and setting target value , instead I should have set source value. Changing that solved the problem. Thanks for all your help.


View solution in original post

9 REPLIES 9

srinivasthelu
Tera Guru

Hi,



Could you please share the script details that did not work?



Thanks


Srini


Hi Srinivas,



Unfortunately I deleted the scripts, but I was trying to get the values of all the fields that were present in the map using source, which I realized wouldn't work. I was expecting the source.fieldname to fetch me a NULL value if it was not passed in the REST request. I was using onBefore script


I appreciate the quick response.


kshitishchodank
Mega Contributor

Can anyone please guide me as to whether writing scripts for transform map will solve this issue?