- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2022 05:06 PM
I want to import Incident records from a remote environment to a local environment.
I created a DataSource based on the following document and ran the import.
I was able to import it, but there are some problems.
- If the Group information is different between remote and local, the business rule "Abort changes on group" will be executed and it will not be possible to import.(If the group information does not match, I want to empty Assignment Group and Assigned to)
- I created a Transform Script in the above document, but because of that Script, it is the same as the remote sys_id when importing, so I can not import the record once imported. (I want to import the updated part as well)
- Newly added related records such as Incident Task should not be imported.
How can I solve these problems with Transform Script?
Thank you!
Business Rule:Abort changes on group(Incident)
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var assigned_to = current.assigned_to;
var assignment_group = current.assignment_group;
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('group.sys_id', assignment_group);
grp.addQuery('user', assigned_to);
grp.query();
if(!grp.hasNext())
{
gs.addErrorMessage(gs.getMessage("Assigned to user {0} must be member of Assignment group {1} ",[assigned_to.getDisplayValue(),assignment_group.getDisplayValue()]));
current.setAbortAction(true);
}
})(current, previous);
Transform Script:OnBefore
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
if(action == "insert"){
target.setNewGuidValue(source.u_sys_id);
}
})(source, map, log, target);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 04:48 AM
Got it. There is a concept known as "Coalesce" which means below:
The coalesce option allows you to update existing target table records when transforming import data.
The coalesce option on a field map allows you to specify if the selected Target field should be used to coalesce on when import set records are transformed. If the field map Coalesce checkbox is selected, when the import set row is transformed the instance checks for an existing record in the target table that has the same value in the Target field as the import set row Source field.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 08:33 PM
Hi
Please let me know if you have a follow up query on this, else if your query is resolved then please mark the answer as correct and close this thread for others.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 10:08 PM
Thank you for answering!!
The above answer was very helpful.
I still have a problem.
I would like to borrow some knowledge about scripts below.
Based on the above document, the process of issuing a draft locally with the same Sys ID at the time of import is described.
However, once you have created a draft, you will not be able to import it locally for updates that have been made remotely.
For the remote updates, I want to update the local ones as well after importing.
However, due to lack of knowledge about scripting, I cannot solve it by myself.
Help me!
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 12:05 AM
Hi
Sure will assist you further. The above lines mentioned by you is not clear to me on what are you trying to build here.
Can you please explain your requirement clearly and couple of screenshot will help me understand better and assist you further.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 02:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 04:48 AM
Got it. There is a concept known as "Coalesce" which means below:
The coalesce option allows you to update existing target table records when transforming import data.
The coalesce option on a field map allows you to specify if the selected Target field should be used to coalesce on when import set records are transformed. If the field map Coalesce checkbox is selected, when the import set row is transformed the instance checks for an existing record in the target table that has the same value in the Target field as the import set row Source field.
Regards,
Shloke
Regards,
Shloke