Copy field from one task to another

mattrom1
Giga Expert

I have 2 custom tables: u_worker_download and u_worker_download_task   both extending to the task table.

I am trying to do 1 of 2 things, not sure what is the best way and i tried BR and workflow scripts, nothing is working(I deleted them out of frustration).

u_worker_download is getting fed data via a web service from an outside site. once that gets inserted, the workflow will create tasks to certain teams. the first one is our net admin team to create the user. They have a field on the u_worker_download_task table called u_network_id, which they are mandatory to type in.

Now for the part I need.

Scenario 1:

After the task is closed with the u_network_id field filled in, write the value to the u_network_id field created on the u_worker_download table. Then the workflow with the other tasks, will just use that field for me to write the details in the description.

 

Scenario 2:

Once the field is written on the task table, have that field stay written in the same field on the other tasks. 

 

Both ways, i have tried, none have worked for me

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

So are the tasks associated to the "parent" u_worker_download somehow? Through some sort of custom parent reference field or something? like sc_tasks are to RITMs, etc.?

If not, you should consider that to make things easier to write between.

So in that initial task that gets created, go to the advanced section and place this line there:

workflow.scratchpad.taskID = task.setNewGuid();

Then, create a run script activity after that task in the workflow with script such as:

var gr = new GlideRecord('u_worker_download_task');
gr.addQuery('sys_id', workflow.scratchpad.taskID);
gr.query();
if (gr.next()) {
current.u_network_id = gr.u_network_id;
}

So this takes the network id from the task and copies it up to the parent.

Then in the other tasks in the workflow, in the create task activity, you can go to the advanced section and do:

task.u_network_id = current.u_network_id;

So I'm assuming this workflow is running on the worker_download table? This will simply copy the network id field from the current parent record and set it as the network id on the task record. And just repeat that in any other task that is created along the workflow where you want that network id to continue in.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

2 REPLIES 2

Allen Andreas
Administrator
Administrator

Hi,

So are the tasks associated to the "parent" u_worker_download somehow? Through some sort of custom parent reference field or something? like sc_tasks are to RITMs, etc.?

If not, you should consider that to make things easier to write between.

So in that initial task that gets created, go to the advanced section and place this line there:

workflow.scratchpad.taskID = task.setNewGuid();

Then, create a run script activity after that task in the workflow with script such as:

var gr = new GlideRecord('u_worker_download_task');
gr.addQuery('sys_id', workflow.scratchpad.taskID);
gr.query();
if (gr.next()) {
current.u_network_id = gr.u_network_id;
}

So this takes the network id from the task and copies it up to the parent.

Then in the other tasks in the workflow, in the create task activity, you can go to the advanced section and do:

task.u_network_id = current.u_network_id;

So I'm assuming this workflow is running on the worker_download table? This will simply copy the network id field from the current parent record and set it as the network id on the task record. And just repeat that in any other task that is created along the workflow where you want that network id to continue in.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Milind Gharte
Kilo Guru

Hi,

Here is link will help you 

https://community.servicenow.com/community?id=community_question&sys_id=b2498725db5cdbc01dcaf3231f96...

 

If it Helps,mark it as Correct and Helpful.


Warm Regards,


Milind Gharte