- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2020 03:47 PM
Hello All,
I have a catalog item workflow that creates a standard change using a script. This catalog item also has a reference variable pointed at the change table. I would like to update this value to reference the change I created from this script, but am completely lost on how to do it.
I think there is a fundamental issue with my approach. I don't need a specific fix, but from a high level view, what is the best way to accomplish this?
Thanks in advance for the advice!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2020 04:08 PM
When you are creating change record, get the sysId of the record as below
var chgSysId = chgObj.insert(); // chgSysId will contain the sysId of new record created
Now add this to the variable as below.
current.variables.NAME_OF_VARIABLE = chgSysId ;
current.update();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2020 03:59 PM
Hi,
It would have been easy for us to directly help you with the script if you would have posted the one which you are referring to, however In reference field you can update the sys_id of the created change.
Kindly mark my answer as Correct and helpful based on the Impact.
Regards,
Alok

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2020 04:08 PM
To update a reference field you need to use the method setValue and the sys_id of the record or use the method setDisplayValue and then the text display value of the record. sys_id's are probably the better way but it depends on what you are doing and the data you have on hand at the time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2020 04:08 PM
When you are creating change record, get the sysId of the record as below
var chgSysId = chgObj.insert(); // chgSysId will contain the sysId of new record created
Now add this to the variable as below.
current.variables.NAME_OF_VARIABLE = chgSysId ;
current.update();