In transform map check errors/warnings before import(transformation)? How do that using onStart/onBefore transform script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2022 07:32 AM
Currently when you import excel file even it contains/gives error while importing data it imports data. It should not import any record and show warning/error message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2022 08:11 AM
Hi,
Without visibility of the errors or warnings, it's a little hard to be specific, but there's a few area's and best practices you can follow.
Firstly, ensure you have the 'Coalesce' flag set to true for the unique key of the record you're inserting/updating. For example, coalesce on the employee number when inserting/updating new users/employees for instance.
This ensures that you don't inadvertently duplicate records that already exist
Secondly, on the fields that you've mapped, ensure the 'Choice Action' field is set to 'Ignore'.
Additionally (and to address your question regarding onBefore scripts) you have the ability to implement an On Before script which allows you to effectively preview the data before importing and importantly allow you ignore certain records. This is scripted using a key word of 'ignore' as shown below.
This is typically written as below with some logic (as per the required use case).
Here's an example lifted form the community where we only want to insert if the employee is a new record and doesn't already exist (please also see the point above re coalesce):
var empId = source.u_employee_id;
var grEmp = new GlideRecord('sys_user');
grEmp.addQuery('employee_number', empId);
grEmp.query();
if(grEmp.next()){
if(action == "insert"){
ignore = true;
}
}
To help others, please mark correct and/or helpful
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2022 09:36 AM
May I know if we get some errors/warnings I need to show on client side. Without actually transforming data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2022 03:32 AM
Hi Harshal,
I'll happily try and help, but unfortunately, your explanation of the issue is too high level to provide specifics.
Which environment are you performing the transform on? Assume non-Prod such as 'Dev'.
Ensure you've exported the Prod data from the table you're wishing to run the transform map on and import this onto Dev. (Export the xml for example).
Use the Dev environment for exactly this use case. Test different scenario's and logic against this data on Dev against this data to overcome errors.
To answer your question directly, any errors should not actually perform an update/insert. You can view these errors in the import log after you've ran the transform.
To help others, please mark correct and/or helpful
Thanks,
Robbie