- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2023 05:33 PM
Hi Team,
I have 2 HR Tasks, I want to copy all the variables present in the HR Task 1 to HR Task 2. In HR Task 2 there are no variables, so ideally these variables are to be inserted from HRT1. Can someone suggest how to achieve this?
(These HR Tasks are created from Record producer & HR Template)
Johnny
Please mark this response as correct or helpful if it assisted you with your question.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2023 10:03 PM
Hi All,
var sourceTask = new GlideRecord('sn_hr_core_task');
sourceTask.get('sys_id', '7f1f56b81b80fr10ff7b76ebdc4bcbd9');
var targetTask = new GlideRecord('sn_hr_core_task');
targetTask.get('sys_id', '21ae12781b80f510wf7b76ebdc4bcb7d');
var newID = '';
var ans = new GlideRecord('question_answer');
var gr = new GlideRecord('question_answer');
gr.addEncodedQuery('table_sys_id=' + sourceTask.getUniqueValue());
gr.query();
while (gr.next()) {
ans.initialize();
ans.table_sys_id = targetTask.getUniqueValue();
ans.order = gr.order;
ans.value = gr.value;
ans.question = gr.question;
ans.table_name = targetTask.getTableName();
newID = ans.insert();
gs.info("aj: the new sys id " + newID);
}
I achieved it with the above code.
Johnny
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2023 09:25 PM
Hey @JohnnySnow
Greetings!
Could you please elaborate the requirement.
What is the relationship between task1 and task 2.
If the second tasks are there already in the system, you have to use fix script.
if the second tasks are to be generated at the time of creation of first task, then you can use after insert business rule.
Please hit the thumb and Mark as correct based on Impact!!
Kind Regards,
Ravi Chandra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2023 10:03 PM
Hi All,
var sourceTask = new GlideRecord('sn_hr_core_task');
sourceTask.get('sys_id', '7f1f56b81b80fr10ff7b76ebdc4bcbd9');
var targetTask = new GlideRecord('sn_hr_core_task');
targetTask.get('sys_id', '21ae12781b80f510wf7b76ebdc4bcb7d');
var newID = '';
var ans = new GlideRecord('question_answer');
var gr = new GlideRecord('question_answer');
gr.addEncodedQuery('table_sys_id=' + sourceTask.getUniqueValue());
gr.query();
while (gr.next()) {
ans.initialize();
ans.table_sys_id = targetTask.getUniqueValue();
ans.order = gr.order;
ans.value = gr.value;
ans.question = gr.question;
ans.table_name = targetTask.getTableName();
newID = ans.insert();
gs.info("aj: the new sys id " + newID);
}
I achieved it with the above code.
Johnny
Please mark this response as correct or helpful if it assisted you with your question.