Transform script to exclude based on condition

KB15
Giga Guru

I'm trying to write this transform script but I'm not sure if this is correct.

The goal is to restrict inserts for accounts that contain "Mail Accounts" in AD.

if((source.u_distinguishedName.toLowerCase().indexOf('Mail Accounts') > -1 && action == 'insert'))

ignore = true;

1 ACCEPTED SOLUTION

OK,


So I was able to re-verify this after multiple runs. I wasn't accounting for that fact that it was working when I saw zero inserts when I was expecting a few hundred. There were records already accounted for which I did not delete.



The script I first used was close and but failed to realize that the distinguished name field in the import table is all lowercase.



Run onBefore


if (source.u_distinguishedname.toString().indexOf('OU=Mail Accounts') > -1) {


  ignore = true;}


View solution in original post

3 REPLIES 3

Kalaiarasan Pus
Giga Sage

Since you have converted the string to lowercase already, the comparison string should be specified in lower case


if((source.u_distinguishedName.toLowerCase().indexOf('mail accounts') > -1 && action == 'insert'))  


ignore = true;  


Weirdly, this doesn't seem to work. I re-ran the transform and it still pulled the accounts in.


I've tried a few variations but my changes don't seem to work.



My current iteration is


if (source.u_distinguishedname.toString().indexOf('OU=Mail') != -1) {


  ignore = true;}


OK,


So I was able to re-verify this after multiple runs. I wasn't accounting for that fact that it was working when I saw zero inserts when I was expecting a few hundred. There were records already accounted for which I did not delete.



The script I first used was close and but failed to realize that the distinguished name field in the import table is all lowercase.



Run onBefore


if (source.u_distinguishedname.toString().indexOf('OU=Mail Accounts') > -1) {


  ignore = true;}