- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2017 06:30 AM
I have seen several comments about not running background scripts in a production environment.
With that in mind can anyone give me a sample script to run that would parse an email address and from the results update a field in sys_user called country.
Example, say I have an email address joe@de.domain.com I need to extract the de, capitalise it and then populate the country field with that information.
Thanks
Solved! Go to Solution.
- Labels:
-
Instance Configuration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2017 02:21 AM
Allright reason is, since you are running the script on all the records, which also contains email with null value so the script fails after reaching it.
So in the gliderecord query you can include the line..
usr.addEncodedQuery('email!=NULL^emailLIKE@');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2017 01:56 AM
Thanks Shariq with both of those it seemed to take me a bit further, now I'm getting the following:-
org.mozilla.javascript.EcmaError: Cannot read property "0" from undefined Caused by error in <refname> at line 8 5: var emailAddr = usr.getDisplayValue('email').toString(); 6: var arr = emailAddr.split("@"); 7: var arr1 = arr[1].split("."); ==> 8: var count = arr1[0].toUpperCase(); 9: usr.country = count; 10: usr.update(); 11: } |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2017 02:21 AM
Allright reason is, since you are running the script on all the records, which also contains email with null value so the script fails after reaching it.
So in the gliderecord query you can include the line..
usr.addEncodedQuery('email!=NULL^emailLIKE@');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2017 02:37 AM