cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rajkumar88
Post Partisan
Post Partisan

send an email when from powerApps submit button to manager

is there a way to send an email from "submit button" to "user→ Manager" ? And also when a user clicks on "submit" then my "edit button" should not be visible for that user.

 

1. on edit button "visible" property:  //I already have one function, but I want to have one where ifuser hits submit it should hide edit button. Not sure how to add one more condition depending up on "emailTriggered" choice column. If it is yes, then I want to hide the button

if(

Today()<Date(2019,07,25),true,false

)

 

Note: once the user hit submit, the data will be saved to sharepoint and user willbe navigated to landing screen, Here it will show his/her submitted request. When they click on that it should show display only of this requestbased up on the validation of "submit button" (because user may have alerady slected submit previously). which means if user selected submit then there should not be edit button. However if user selected "save", then edit should show up to edit the submitted request.

 

2. when user hit submit, then an email should trigger to the submitted manager.

 

something like to get user.manager email and send an email to them or can my submit button trigger FLow to send an email?

 

3. as of now I have added below formula. I thought "emailTriggered" choice column can be used whether to make "edit button" visible or not visible.

Patch(Employee,Defaults(Employee),Form1_1.Updates,Form2_1.Updates,Form2_5.Updates,
{
ManagerStatus:{Value:"Pending"},
emailTriggered:{Value:"Yes"}


}
);Navigate(EmpLandingScreen,ScreenTransition.None)

15 REPLIES 15
yshariff
Advocate I
Advocate I

Hi

 

ASSUMPTIONS: I'm assuming you're using a form and people can add an item and save, then submit later. 

 

QUESTION 1: Edit Button

 

I'm using a dropdown for my "Email Triggered" column which I've labeled in Powerapps as "EmailTriggeredField". For the edit button, I made the visible property:

 

If(And(EmailTriggeredField.Selected.Value = "No",Today()<Date(2019,07,25)),true, false)

 

QUESTION 2: Email to Manager & Update Status

 

First make sure you have the Office 365 Users datasource added to your PowerApp.

 

To send an email to the manager and update the status, you can just use Flow. You would create a flow with the following items in this order:

 

  1. PowerApps (This triggers the action from them clicking submit)
  2. Sharepoint Update Item
  3. Outlook Send an Email

For the Sharepoint Update Item it will ask for ID which you can select "Ask in Powerapps". For the Outlook send to email, you can also select "Ask in Powerapps. 

 

Then in Powerapps, click on your submit buttons on select property. Then go to Actions>Flows and select the flow you created. It will say in the onselect property:

 

FlowName.Run(

 

You will see hint text that adds GetItemID, SendanEmailTo

 

So you will update the property to:

 

FlowName.Run(FormName.LastSubmit.ID, Office365Users.ManagerV2(User().Email).mail)

 

The above pulls the user logged in Manager.

 

Now in the On Select property of the submit button you just need to add the Form Submit code in front of the above so it's something like this:

 

SubmitForm(FormName);FlowName.Run(FormName.LastSubmit.ID, Office365Users.ManagerV2(User().Email).mail)

@yshariff,

 

thanks for all your sugggestions. I am getting an error while tryign to attach that flow to powerapp.  "Failed to register service"

 

Quick question with respect to sending an email through flow. using this method, it will only trigger when user clicks on "submit" right? The reason why I asked is that I have another button called "save" and it will also save the content to sharepoint list, but it won't triger any email.

@rajkumar88 When you setup the flow the way I mentioned, it will only trigger based on it being triggered by the submit button. It's because it's setup to only trigger when that specific button is selected.

 

For the error message you're receiving, try removing the flow from the button, save & close the app, then reopen and add. See if that works. If not, can you send a screenshot of the error message and the formula you have on the submits on select property?

 

Thanks!

 

Yusuf

@yshariff,

 

Hi ,

 

Please find the code that has on my "onselect property". The below function is used to save content to sharepoint list along with some column updates.

If(IsBlank(LookUp(EmployeePerformance, Lower('Created By'.Email) =Lower(userinfo) )),Patch(EmployeePerformance,Defaults(EmployeePerformance),Form1.Updates,Form2.Updates,Form2_4.Updates,Form3.Updates,
{
ManagerStatus:{Value:"Pending"},emailTriggered:{Value:"Yes"}

}
);Navigate(ManagerLandingscreen,ScreenTransition.None),Patch(EmployeePerformance,LookUp(EmployeePerformance, Lower('Created By'.Email) =Lower(userinfo)),Form1.Updates,Form2.Updates,Form3.Updates,Form2_4.Updates,
{
ManagerStatus:{Value:"Pending"},emailTriggered:{Value:"Yes"}

}
);Navigate(ManagerLandingscreen,ScreenTransition.None))

 

 

flow.PNG

 

 

FYI → I tried creating it directly from the App and was able to connect it to Onselect property. However I lost abovce code that I mentioned here. How can I patch above code along side with this flow  code "PowerAppsbutton.Run(Form3.LastSubmit.ID,Office365Users.ManagerV2(userinfo).mail)"

@yshariff,

 

and  also for question 1. I think in my case it should be different. Sorry I haven't added complete information.

 

1. I have two buttons, one for save and one for Submit. If user clicks on SAVE then they should be able to edit the content. Due to which I ma updated "EmailTriggered" column.

2. if user clicks on "SUBMIT" then user should not be able to edit the content. on "submit" button I am updated "emailTriggered" column with "yes". Based up on this "Yes", "EDIT" should be set to hide.

 

Just to confirm → will below formula  works?

If(And(DataCardValue14.Selected.Value = "Yes",Today()<Date(2019,07,25)),false, true)

You can add you code back by just separating it with ; after or before it 

correct!

@yshariff,

 

I have several froms in this app. DO I need to add all the forms into the "RUN" function or the last form name to it?

 

 

If(IsBlank(LookUp(EmployeePerformance, Lower('Created By'.Email) =Lower(userinfo) )),Patch(EmployeePerformance,Defaults(EmployeePerformance),Form1.Updates,Form2.Updates,Form2_4.Updates,Form3.Updates,
{
ManagerStatus:{Value:"Pending"},emailTriggered:{Value:"Yes"}

}
);Navigate(ManagerLandingscreen,ScreenTransition.None);PowerAppsbutton.Run(Form2_5.LastSubmit.ID, Office365Users.ManagerV2(User().Email).mail),Patch(EmployeePerformance,LookUp(EmployeePerformance, Lower('Created By'.Email) =Lower(userinfo)),Form1.Updates,Form2.Updates,Form3.Updates,Form2_4.Updates,
{
ManagerStatus:{Value:"Pending"},emailTriggered:{Value:"Yes"}

}
);Navigate(ManagerLandingscreen,ScreenTransition.None);PowerAppsbutton.Run(Form2_5.LastSubmit.ID, Office365Users.ManagerV2(User().Email).mail))

 

And also I am getting below error after making changes.

 

flowerror.PNG

@yshariff          @yashag2255, @RandyHayes  sorry guys I always tend to reach out to you. Any suggestion on how to use submit button to send an email to Manager?

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,479)