How to clear out the field on target table via Web Service + Transform Map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2015 11:32 AM
I have a web service with fields: "assigned_to", "assignment_group" and "task_id".
And transform map where target table is Task[task].
Transform map has field map:
task_id -> sys_id
assigned_to - > assigned_to
assignment_group -> assignment_group
Transform map has "Copy empty fields" set to "false".
Lets say I have an incident with assigned_to field set to some user.
According to wiki page Creating New Transform Maps - ServiceNow Wiki it should be possible to clear out the field by passing "NULL" string.
The POST data looks like:
{"task_id": "d48ec9460fd70240197f0cbce1050e42", "assigned_to": "NULL"}
Then response contains:
...
"status": "ignored",
"status_message": "No field values changed",
...
The field "assigned_to" gets updated(cleared) If "Copy empty fields" is "true". So, now "Copy empty fields" options is "true".
Lets say I have an incident with "assignment_group=Database", "assigned_to=''".
I want to update "assigned_to" field. POST data is:
{'task_id': 'd48ec9460fd70240197f0cbce1050e42', 'assigned_to': 'ee826bf03710200044e0bfc8bcbe5de6'}
The target record is updated, it has correct "assigned_to", but now "assignment_group=''" is empty, it was cleared.
So, if I want to clear out the field, I have to use "NULL"+"Copy empty fields". In that case all the fields that were not passed in POST data will be cleared on target record.
Without "Copy empty fields" option, fields that are not passed in POST data are not updated, but setting of "NULL" does not clear out the field.
What magic combination of checkboxes in transorm map will give me desired functionality/behaviour?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2015 11:50 AM
Per that article it states that "It should not be used as a field value in import set transform maps..." Do not pass the NULL value and just leave it empty. Leaving the Copy empty fields value should be all you need to not relay empty values. Check it to relay the empty values, but this will do it for all fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2015 12:08 PM
Mike, thank you for the reply. It does not work. If "Copy empty fields" option is false, passing of "" empty string does not clear out the field's value.
If "Copy empty fields" is true, all fields that are in transform map, but not in POST data are cleared.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2015 12:13 PM
Not sure I understand your reply. If you are posting data to an import table to be transformed, then the data should go in there no matter what. The "Copy empty fields" is telling it what to do when transforming the data to the target table. The data coming from POST shouldn't be touched at all unless there is something on the source (import) table.
Are you only trying to populate identified values into the fields or are you wanting to clear fields based on the result of the values coming from the web service? If the latter, then you want a source script as mentioned by Ravindrareddy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2015 12:07 PM