Send email to business owner who owns multiple applications

JuniorDev82
Tera Contributor

Hi,

I need to send email notification to a group of business owners to certify data for business applications on yearly basis. 1 business owner may own multiple business apps, hence i need to make sure the email is send only once to every business owner even though they own multiple business apps. I was wondering if anyone has done this before in Flow designer? If so, how did you configure this?

 

Thanks

Junior Developer

1 ACCEPTED SOLUTION

Hi @JuniorDev82 ,

 

I had given a solution for sending single email to respective owner, you had not mentioned that you need to include list of apps as well. No worry.

 

you can do like below.

var appGr = new GlideRecord('business_application');
appGr.addActiveQuery();  
appGr.query();

var businessOwners = {};

while (appGr.next()) {
   var owner = appGr.business_owner;  // Replace with actual business owner field
   var appName = appGr.application_name;  // Replace with actual application name field

   if (!businessOwners[owner]) {
      businessOwners[owner] = [];
   }
   // Add the application name to the owner's list
   businessOwners[owner].push(appName);
}

// Send email notification to each business owner
for (var owner in businessOwners) {
   var appsList = businessOwners[owner].join(', ');  // Combine application names

   gs.eventQueue('business.app', null, owner, appsList);
}

Create one event based notification and content like below.

Dear ${recipient},

You are the owner of the following business applications:
${event.parm2}  // This will be replaced with the list of applications 

Please certify the data for these applications by [Due Date].

Best regards,
Your Team

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
LinkedIn: https://www.linkedin.com/in/runjay
YouTube: https://www.youtube.com/@RunjayP

-------------------------------------------------------------------------

View solution in original post

9 REPLIES 9

AndersBGS
Tera Patron
Tera Patron

Hi @JuniorDev82 ,

 

have you considered utilizing data certification through the CMDB workspace?

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

Anders

 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

Hi @AndersBGS 

Unfortunately not implementing this through CMDB Workspace at this moment. I need to setup email notification from Flow and provide a link to the business owner to certify the business owner and IT owner.

Runjay Patel
Giga Sage

Hi @JuniorDev82 ,

 

You can do using schedule job, follow below steps.

1. create one event based notifictaion.

2. create one job schedule and run yearly once.

3. use below code to send email.

var uniqueOwners = [];
var appGR = new GlideRecord('cmdb_ci_business_app'); 
appGR.query();

while (appGR.next()) {
    var ownerEmail = appGR.owned_by.email;
	
    if (ownerEmail && uniqueOwners.indexOf(ownerEmail) === -1) {
        uniqueOwners.push(ownerEmail);
		gs.eventQueue('business.app',appGR,appGR.owned_by,'');
		
		
    }
}

 

 

Hi @Runjay Patel ,

 

Thanks runjay, i was having similar requirement and it works for me.