cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Building the recipient list for PowerAppsNotifications

Hi,

I'm having trouble building the list of recipients for a PowerAppsNotification action. If I add them manually in like this -

 

 

PowerAppsNotification.SendPushNotification(
		{
			recipients:["email.address@example.com","email.address2@exmaple.com"],
			message: "This is a test message",
			params: Table({key: "NotificationTripID", value: editItem.ID}),
			openApp: true
		}
)

 

This works fine. If I use "set" to assign it via variables this works as well -

 

Set(TripLeaderEmail,editItem.'Trip Leader'.Email);
Set(TripMemberEmails, Concat(editItem.'Trip Members', Email, ","));
Set(TripExpertEmail, editItem.'Trip Expert'.Email);

PowerAppsNotification.SendPushNotification(
		{
			recipients:[TripLeaderEmail,TripExpertEmail,TripMemberEmails],
			message: "This is a test message",
			params: Table({key: "NotificationTripID", value: editItem.ID}),
			openApp: true
		}
)

 

However, if I try and add all 2 or 3 variables as a string like

 

Set(TripLeaderEmail,editItem.'Trip Leader'.Email);
Set(TripExpertEmail, editItem.'Trip Expert'.Email);

Set(NotificationList, TripLeaderEmail & "," & TripExpertEmail);

PowerAppsNotification.SendPushNotification(
		{
			recipients:[NotificationList],
			message: "This is a test message",
			params: Table({key: "NotificationTripID", value: editItem.ID}),
			openApp: true
		}
)

 

 

I receive the following error
"code": "InvalidPrincipalIdOrMail",
"message": "The recipient 'email.address@example.com,email.address2@example.com' is not a recognized email address or object identifier in the directory."

If I try and add a char(34) to it like so

 

Set(NotificationList, Char(34) & TripLeaderEmail & Char(34) &  "," & Char(34) & TripExpertEmail & Char(34));

PowerAppsNotification.SendPushNotification(
		{
			recipients:[NotificationList],
			message: "This is a test message",
			params: Table({key: "NotificationTripID", value: editItem.ID}),
			openApp: true
		}
)

 

 

I receive the following error

"code": "InvalidPrincipalIdOrMail",
"message": "The recipient '\"email.address@example.com\",\"email.address2@example.com\"' is not a recognized email address or object identifier in the directory."

How can I build the "NotificationList" variable such that it can be used in the PowerAppsNotification command?

 

Thanks!
Dylan

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @baarsd :

Please try this code:

Set(TripLeaderEmail,editItem.'Trip Leader'.Email);
Set(TripExpertEmail, editItem.'Trip Expert'.Email);
ClearCollect(NotificationList, [TripLeaderEmail,TripExpertEmail]);
RemoveIf(NotificationList,IsBlank(Value));
PowerAppsNotification.SendPushNotification(
		{
			recipients:NotificationList,
			message: "This is a test message",
			params: Table({key: "NotificationTripID", value: editItem.ID}),
			openApp: true
		}
)

Best Regards,

Bof

View solution in original post

4 REPLIES 4
Community Support
Community Support

Hi @baarsd :

Firstly,let me explain why you encounted this problem.

The key is that [NotificationList] can not parse the code in the variable NotificationList, but use it as a value (string).

Secondly,please try this code:

 

Set(TripLeaderEmail,editItem.'Trip Leader'.Email);
Set(TripExpertEmail, editItem.'Trip Expert'.Email);

Set(NotificationList, [TripLeaderEmail,TripExpertEmail]);

PowerAppsNotification.SendPushNotification(
		{
			recipients:NotificationList,
			message: "This is a test message",
			params: Table({key: "NotificationTripID", value: editItem.ID}),
			openApp: true
		}
)

 

Best Regards,

Bof

Hi @v-bofeng-msft 

That works. One question - if any of the variables are empty (e.g. TripExpertEmail) it errors with "InvalidNotificationRecipients"

 

Other than some if IsEmpty statements to build the NotificationList variable, do you see anything else that could be done?


Thanks!
Dylan

Hi @baarsd :

Please try this code:

Set(TripLeaderEmail,editItem.'Trip Leader'.Email);
Set(TripExpertEmail, editItem.'Trip Expert'.Email);
ClearCollect(NotificationList, [TripLeaderEmail,TripExpertEmail]);
RemoveIf(NotificationList,IsBlank(Value));
PowerAppsNotification.SendPushNotification(
		{
			recipients:NotificationList,
			message: "This is a test message",
			params: Table({key: "NotificationTripID", value: editItem.ID}),
			openApp: true
		}
)

Best Regards,

Bof

View solution in original post

Thanks @v-bofeng-msft! Works a treat.

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (11,138)