how to check condition in Transform map script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-08-2022 11:28 PM
Hi,
I have excel file which contains two column sys_id1 & sys_id2
Now I am importing records in u_m2m_table where i have two fields field1 and field2. These two fields are references to table 1 and table 2 respectively. Now while importing records in u_m2m_table I want to check if sys_id1 and sys_id2 are valid and then insert else ignore.
Also I want to insert only if sys_id1 & sys_id2 these both fields are not empty.
I know to use onBefore scripts. But how can it be done? What to write the content?can anyone help with this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-09-2022 12:06 AM
Hello,
As I had mentioned earlier please do the below, also you should avoid creating duplicate post it is not a good practice.
1) Create two field maps for the two fields with coalesce as true and choice action as ignore.
Then create a onbefore transform script with the below code:-
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if(source.fieldname1==''||source.fieldname2=='')
{
ignore=true;
}
})(source, map, log, target);
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-09-2022 01:49 AM
Hello,
If my answer helped you can you also mark it as correct.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-09-2022 04:52 AM
Hi, I use your script for if any field is empty
I discovered a bug suppose in the excel
table1_sysid | table2_sysid |
a1221bdgw6svdihsdf | 12fjdcdvd89bvnsdf9b |
12fjdcdvd89bvnsdf9b |
If one of field is empty and it is not in 1st row it will create record with one of field as empty but if it is in 1st row then it will ignore
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-09-2022 04:55 AM
Hello,
onbefore will run before every row transform so it should be able to handle the empty field on any row