How to copy variables from one record to another
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2019 04:02 PM
I need to be able to copy variables along with there values from one table to another. Both tables are extended from Task and the records in the tables are created from Record Producers.
So far I have only found 1 article which provides some hints but no examples of how to script this within a workflow run script.
Basically, I need a run script for the copying the variable on a record in one table to a new record in another table.
The first part is easy enough:
var gr = new GlideRecord('u_treasury_operations_services');
gr.initialize();
gr.u_cat_item = '7acbf02fdb27f380b38b80c74b96190e'; // Table Administration
gr.assignment_group = '767b427ddb61f740e14ad92b5e961915'; // Treasury Operations Administration
gr.short_description = 'Table Administration - Open/Close Account - Bank Services Request: ' + current.number.getDisplayValue();
gr.insert();
// Now I need to create variables in the new record which match the variables in the current record (obviously the lines below don't work)
// gr.variables.request_type = 'open_close_account';
// gr.variables.account = current.variables.account
//
I found one article which talks about this, but it doesn't contain any details:
Can anyone help with this?
- Labels:
-
Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2019 06:14 PM
Hi
It is not enough to try to copy the variables like you tried.
The variables are stored in a separate table, as mentioned in the article, you linked in your post.
You need to query the values of that table for your source record, and copy them record by record, by inserting them in the same table, but linked to the current record, you created and inserted above.
To make the business rules fire, also insert a record in the table, as described in your linked article.
Do you know, how to script that, or do you need some assistance?
Let me know if that answered your question and mark my answer as correct and helpful, please.
BR Dirk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2019 05:58 PM
Hi Dirk,
Thanks for your response. I did script this but found it still won't work. The problem is the target table also has variables which are populated by another record producer, so even if I copy the variables and redirect to the new record and table the variable editor that was created for that table won't display them.
I think the only solution would be for all the variables to be part of a variable set which is attached to both record producers. I haven't tested this because I was running out of time on my deliverable.
Instead I just scripted adding the variable names and values to be included in the description of the target table, although it's not what I wanted, it meets the business requirement.
I will play with this more when I have some time and if successful, I will post my complete solution here for others.