web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Conditional Push Notif...
Power Apps
Answered

Conditional Push Notification - Difficulty in invoking it at the right time!

(0) ShareShare
ReportReport
Posted on by 24

Hi All,

 

I think I may have got the code right for this one (maaaaaybe!) but I can't get it to work at the right time as I don't think I understand PowerApp form logic well enough yet. Any help would be super appreciated!

 

I'm using a canvas app connected to an Excel file in OneDrive, which tracks referrals coming in to our service. The admin team input the data into a form, and then a card is created (for the teams to see) and a push notification sent to logged in users. The content of the push notification is/should be conditional on the selected text value of one of the DataCard drop downs (in this case, it's the status of the job, is it unallocated/allocated to a particular team or is it 'not accepted' in which case no notification is sent).

 

I've written the code that seems to work, but if I put it in the "OnSuccess" of the form or after 'SubmitForm...' on the "OnSelect" of the tick in the top right of the form, it doesn't invoke the Switch function until after the form has been submitted, so the contents of that Data Card has already been patched and reset to its default, so the system sends out the wrong push notification.

 

If I put it before the 'Submit Form...' in "OnSelect" it sends the notification correctly but before the form has been validated for required fields, so the form may not submit but the notification is still sent!


Is there anywhere I can put it where it will both be able to call the existing value from the Data Card as well as after the form has been validated? - If not, what modification could I make to the formula to get that value after the form has been submitted?

 

Here's the code so far:

Switch(DataCardValue23_1.SelectedText.Value, "Unallocated", PowerAppsNotification.SendPushNotification(
	{
		recipients:RenameColumns(ActiveUsers.EmailAddress, "EmailAddress","Value"),
		message: "New Unallocated Job Added",
		openApp: true
 	}
), "Allocated PR60", PowerAppsNotification.SendPushNotification(
	{
		recipients:RenameColumns(ActiveUsers.EmailAddress, "EmailAddress","Value"),
		message: "New Job Added for PR60",
		openApp: true
 	}
), "Allocated PR61", PowerAppsNotification.SendPushNotification(
	{
		recipients:RenameColumns(ActiveUsers.EmailAddress, "EmailAddress","Value"),
		message: "New Job Added for PR61",
		openApp: true
 	}
))

 

Thanks in advance!


Rich

Categories:
I have the same question (0)
  • Verified answer
    RusselThomas Profile Picture
    4,014 on at

    Hi @richmus ,

    Just a quick guess, but can you not wrap this in 

    If(myForm.Valid, ....

     ?

     

    Kind regards,

    RT

  • richmus Profile Picture
    24 on at

    @RusselThomas 

     

    Thanks so much - works perfectly 🙂

     

    For anyone else who was using that function for the first time, here it is in my code; it wasn't happy until I put something in the else value:

     

    If(EditForm1_2.Valid, Switch(DataCardValue23_1.SelectedText.Value, "Unallocated", PowerAppsNotification.SendPushNotification(
    	{
    		recipients:RenameColumns(ActiveUsers.EmailAddress, "EmailAddress","Value"),
    		message: "New Unallocated Job Added",
    		openApp: true
     	}
    ), "Allocated PR60", PowerAppsNotification.SendPushNotification(
    	{
    		recipients:RenameColumns(ActiveUsers.EmailAddress, "EmailAddress","Value"),
    		message: "New Job Added for PR60",
    		openApp: true
     	}
    ), "Allocated PR61", PowerAppsNotification.SendPushNotification(
    	{
    		recipients:RenameColumns(ActiveUsers.EmailAddress, "EmailAddress","Value"),
    		message: "New Job Added for PR61",
    		openApp: true
     	}
    )),Notify("Please Ensure the form is filled correctly", NotificationType.Error))
    ;
    SubmitForm(EditForm1_2)

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard