Dear community,
I have the following formula by selecting a Button:
Patch(MitarbeiterdatenTasks;First(Filter(MitarbeiterdatenTasks;Title=Label3.Text));{Task: 1});;
I want to send an E-Mail if all values in column Task are set to 1, which I do by this:
If(CountRows(Distinct(MitarbeiterdatenTasks;Task="1"))=1;
Office365Outlook.SendEmail("xxxxx@xxx.com";"Tasks Completed"; "I finished my tasks");
false);;
My Problem is that if the user clicks the button again another E-Mail is sent. I would like to send the E-Mail only once.
Can anybody help me?
Thank you!
Solved! Go to Solution.
This really depends, do you want it to only happen once forever, or only once while they are using the App?
If its only while they are currently using the App:
If(CountRows(Distinct(MitarbeiterdatenTasks;Task="1"))=1 && EmailSent=false;
Office365Outlook.SendEmail("xxxxx@xxx.com";"Tasks Completed"; "I finished my tasks");
false);;
Set(EmailSent; true)
If you want it to only send one forever, then you'll want to create a new list or have a column in your parent list called 'EmailSent', which you can set to true by patching it when you send the email, then make the email only send if that is false..
Also be careful using Distinct - I'm not sure what your datasource is, but Distinct could eventually stop working if its susceptible to delegation limits, as it will only work within the delegable limit (the max of which is currently 2000 when set in the settings of your App)
@iAm_ManCat |
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you! |
Thanks! |
Hey @noobi,
I think that an easy way to fix this would be to add a variable. On the app "OnStart" property you can set a var like that:
Set(EmailSent, 0);
Then on your If you can add a second condition:
If((CountRows(Distinct(MitarbeiterdatenTasks;Task="1"))=1) && (EmailSent = 0);
Office365Outlook.SendEmail("xxxxx@xxx.com";"Tasks Completed"; "I finished my tasks");;Set(EmailSent,1);false);;
The first time a user click on the button the email will be sent if the conditions are met, but after that it shouldn't send any more emails since the variable won't be equal to 0 anymore.
This really depends, do you want it to only happen once forever, or only once while they are using the App?
If its only while they are currently using the App:
If(CountRows(Distinct(MitarbeiterdatenTasks;Task="1"))=1 && EmailSent=false;
Office365Outlook.SendEmail("xxxxx@xxx.com";"Tasks Completed"; "I finished my tasks");
false);;
Set(EmailSent; true)
If you want it to only send one forever, then you'll want to create a new list or have a column in your parent list called 'EmailSent', which you can set to true by patching it when you send the email, then make the email only send if that is false..
Also be careful using Distinct - I'm not sure what your datasource is, but Distinct could eventually stop working if its susceptible to delegation limits, as it will only work within the delegable limit (the max of which is currently 2000 when set in the settings of your App)
@iAm_ManCat |
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you! |
Thanks! |
Hello Mr. iAm_ManCat,
thank you for the answer. Your descripted solution is exactly how I solved the issue.
Sorry for the inconvenience.
Best Regards
No worries! Happy you got it solved! 🙂
@iAm_ManCat |
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you! |
Thanks! |
User | Count |
---|---|
258 | |
109 | |
93 | |
57 | |
41 |