The CreatorCon Call for Content is officially open! Get started here.

Fetch email address from Compose Email page and Validate with User ID field on sys_user table

02rahul02
Tera Contributor

Hi,

 

I have a requirement to validate the email addresses we put on the compose email page from HR cases. Once the agent sends email, I want to fetch the email addresses and validate them with the User ID field on the sys_user table as this field contains the correct addresses. I want to send emails only if the data matches with User ID field, else abort sending. We can allow partial sending of emails for correct addresses.

Thanks,

Rahul

@ankurbawisk 

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@02rahul02 

but why to validate it?

If they select the user then it means that user is present in sys_user and should have correct email address.

You should ensure your sys_user table is accurate and that's it.

AnkurBawiskar_0-1759993062066.png

 

The OOTB script include already fetches the email from sys_user

AnkurBawiskar_2-1759993190543.png

AnkurBawiskar_3-1759993213585.png

 

AnkurBawiskar_1-1759993176197.png

 

💡 If my response helped, please mark it as correct ✔️ and close the thread 🔒 — this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

Actually we have some vendor/group/store email addresses on the email field on user profiles. When we put user names on the compose email page, by default if picks the addresses available on the Email field of that profile. The User ID field of the user profile contains the correct email addresses which is why we want to put this validation.

Since data correction is a big task, it will be planned in future.

@02rahul02 

so you have vendor/group/store email addresses stored on sys_user USER ID field?

If yes then not a good idea.

In that case you can use before insert business rule on sys_email table and check for your subject and then remove the unwanted recipients from the To field

-> query sys_user with these emails

-> see which user records to remove

-> remove it from this string field and set that field again

AnkurBawiskar_0-1759995225416.png

 

💡 If my response helped, please mark it as correct ✔️ and close the thread 🔒 — this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Yes I was also thinking same to put a BR on the sys_email table. But will it not impact the instance performance? I mean currently we are targeting HR table, but if more tables require same functionality then would this be recommended?

Is it possible to put some validation on the Compose email Page itself?