Send Email Only Once
Hi Team,
See attached screenshot, I have a field called "contract renewal date" and a formula on the "contract renewal status" as per the below. How can I ensure the email only sends once? I was trying to update my "contract email sent" toggle field but appears I cannot update this from within the formula
let Date2 := 'Contract Renewal Date';
let Date1 := today();
let daysBetween := days(Date2, Date1) * -1;
if daysBetween = 90 then
let userEmail := "david@platform81.com";
sendEmail({
from: "gary@platform81.com",
to: userEmail,
subject: "Thank you for your email",
text: "We received your request to get another copy of your invoice",
html: "Some text with markup"
});
end;
if daysBetween <= 0 then
styled("", "#cb2010", "")
else
if daysBetween <= 90 then
styled("", "#ffb452", "")
else
styled("", "#43d682", "")
end
end
5 replies
-
Hi david
Where is your code? Buttons and triggers will allow you to update fields but my guess is that it's in the Contract Renewal Status formula field. This will only run the last bit
if daysBetween <= 0 then styled("", "#cb2010", "") else if daysBetween <= 90 then styled("", "#ffb452", "") else styled("", "#43d682", "") end end
and ignore the rest.
Regards John
-
Hi david
Unfortunately a formula field can't trigger a button. You will need to press the button to execute its code. You could get the button to run the code for all your records, not just the record it's on. There is also a Trigger after open, in the options of the app which would run every time you open the app.
Let me know if you need a hand implementing it all.
Regards John
-
Hi david. There’s nothing in your code currently to prevent it sending ann email each time. I’ll post some code later tomorrow to show you how to put this right.
Content aside
- 5 hrs agoLast active
- 5Replies
- 24Views
-
2
Following