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