Transform map script to extract email ID from Description
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2024 12:21 AM
Hello Community,
I have a requirement to extract Email ID from Description field. I have added a field called origin mail to store the extracted email id value(u_origin_mail). I have written a script however it is not working. Can anyone help me with the script to extract the email id from description using onAfter script? Your response would be appreciated.
Here is the code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2024 06:21 AM
Did you debug if you are able to extract email or not? If this is working then check next points
2 options to achieve your requirement
1) you can use onBefore transform script for this instead of onAfter
OR
2) If you use onAfter then you need to use target.update() to actually update the record after setting the value
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2024 06:26 AM - edited 08-05-2024 06:26 AM
@JaganN971616731 The regex used in returnEmail has a slight mistake. The {2,} part in the regex should be replaced with \w{2,} to properly match domain parts of the email.
Make sure your script is used in an appropriate onAfter script context where source and target are correctly defined.
Please mark my response as helpful 👍and accept the solution ✅if it helped you