- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2019 11:24 AM
Hello there ,
We have a catalog item with 2 Variables Variable1 will be displayed on the form and Variable 2 is hidden but available on catalog task when the request is raised the variable1 value entered by the user should be populate in the variable 2 on catalog task ,
I tried Below scenarios : used the On submit client script (its populating the values on catalog task but when ever i save the task all the values are clearing /deleting )
is there a way i can copy values form Variable A to Variable B on catalog Task ?
I also tried on catalog task advance script
task.variable1= current.variable2
and
task.current.variable1= current.variable2
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2019 04:37 AM
kam,
Since you're using a Client script, your values aren't saved to the DB when the page reloads. So, when you add notes to the record, the previous values from the Client script disappear. You'll need to run a Server-side script if you want the values to persist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2019 01:36 PM
So i need to create a run script before my task got generated ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2019 02:44 PM
kam,
You were on the right track with your workflow solution. Looks like you were having the same issue as the client script though. I don't think the value assigned to variable_2 was saving.
I ran this in a background script and it worked:
**this code is only provided to show that you can assign/reassign variable from a script**
var sys_id = '22ce78f61b85c8104f548622dd4bcbe5';
var ritmGR = new GlideRecord('sc_req_item');
ritmGR.get(sys_id);
ritmGR.query();
if (ritmGR.next()) {
//outputs user from form
gs.info(ritmGR.variables.initial_questions.ITRP_OG_Approv.getDisplayValue());
//my variable is in a variable set so I have to add 'initial_questions' to grab it
//this successfully reassigns RITM variable to different user
ritmGR.variables.initial_questions.ITRP_OG_Approv = '4b77bd43db34238044791bfa4b961970';
//outputs different user
gs.info(ritmGR.variables.initial_questions.ITRP_OG_Approv.getDisplayValue());
//you must update the record!
ritmGR.update();
}
I'm using a hard-coded value but you can use another variable from the form and use that value for reassignment:
var whoFor = reqItm.variables.initial_questions.who_is_this_request_for;
ritmGR.variables.initial_questions.ITRP_OG_Approv = whoFor;
ritmGR.update();
I'm calling a Script Include (appendPONumber) from the Catalog task activity but you should be able to insert your code into the 'Advanced script' field directly.
Hope this helped!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2019 06:16 AM
I created a run script and set the current.variables.variable1 =current.variables.variable2 and it worked