Unable to populate fields on Location(cmn_location) table using transform maps and data load or even with a background script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2022 09:56 AM
Hi all,
I am unable to populate two fields on Location (cmn_location) table using a Data Source and a transform map.
These fields on Location(Cmn_location) are
- Life Cycle Stage
- Life Cycle Stage Status
The transform is running perfectly fine for other fields such as Name and Correlation ID . But for the above two fields values are set but not displayed on the form on the (i) icon is visible.
The two fields -Life Cycle Stage and Life Cycle Stage Status are referenced on the Location form form table life_cycle_stage and life_cycle_stage_status table.
Please note :
- The headers in excel sheet used are correct.
- Tried with sys_id and Display Value for the above fields during transform but no luck.
- After every transform it appears as if the data is there in the field as (i) is visible but actuall no data is there. When I open the record with the help of (i) icon on the field it opens a new form for life_cycle_stage table.
- I have even tried background scripts just to simply update the Location(cmn_location) record with the below script but it does not update the two fields mentioned above.
var getRecord = '9098f3a187b8d110c9804336cebb35db';
var life_cycle_stage = '53584655b7620010ee0d3177ee11a97f';
var life_cycle_stage_status = 'e4990295b7620010ee0d3177ee11a9db';var targetRec = new GlideRecord('cmn_location');
targetRec.get(getRecord);
//gs.print(targetRec.name);
targetRec.life_cycle_stage = life_cycle_stage;
targetRec.life_cycle_stage_status = life_cycle_stage_status;
targetRec.update(); - Attaching screenshots and excel used - please let me know if you have any recommendation or solution for the above. Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2022 10:09 AM
Hi
on a similar Community question Scott Lemm - ServiceNow Product Manager for CSDM - answered as follows:
ServiceNow does not want the new Life Cycle Stage and Status objects modified. These objects were locked in order to maintain consistency for current/future products that rely on knowing the status of critical data and effecting its life cycle process.
The values provided for End of Life on locations have the following meaning:
- Obsolete - no longer needed
- Sold - no longer owned
- Lease Return - no longer leased
So that means, you only can use the pre-defined values and not your own ones.
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2022 10:54 AM
Hi
Field : Life Cycle Stage -------->value : Operational -----> sys_id : 53584655b7620010ee0d3177ee11a97f
Field : Life Cycle Stage Status -------->value : In Use-----> sys_id : e4990295b7620010ee0d3177ee11a9db
The above-mentioned are OOB values of choices by ServiceNow - i am just trying to set these via script on the Location table which is not getting set as expected. Is this also considered an expected behavior?
Just wanted to know you thoughts !
Thanks for the above clarification .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 03:02 PM
Hi SJ,
I've been hitting the same problem as you - neither of the following work for me:
- Straight-up supplying the values via Field Maps (with or without populating the 'Referenced value field name' field on the Field Map) - this works for literally every other reference field except the Life Cycle Stage and Life Cycle Stage Status fields.
- Using a GlideRecord lookup in the Transform script to get the sys_ids of the the LC Stage records and providing those e.g. target.life_cycle_stage = grSourceLifeCycleStage.getValue("sys_id")
Weirdly though, when I use the following in the Transform script, it works:
var sourceLifeCycleStage = source.u_life_cycle_stage;
var grSourceLifeCycleStage = new GlideRecord("life_cycle_stage");
grSourceLifeCycleStage.addQuery("name",sourceLifeCycleStage);
grSourceLifeCycleStage.query();
if (grSourceLifeCycleStage.hasNext()) {
grSourceLifeCycleStage.next();
target.life_cycle_stage = grSourceLifeCycleStage.getValue("name");
}
else {
//handle the error as you see fit
}
I wish I had an answer for why this is behaving differently to just providing the name in a Field Map. It makes no sense to me.