cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Adding email to an existing formula

Hello,

 

Currently I have started testing and even created an updated version of Service Desk App. However what I would like is that the second someone creates a new ticket it sends all IT staff an email notification of that new ticket.

 

Currently I have the following code on create ticket

 

If(IsBlank(Subject.Text) || IsBlank(Description.Text) ,UpdateContext({msg_visible:true}),SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description:Description.Text})}))

 

Is there a way to add something like the following?

 

Office365.SendEmail(
          DataCardValue12.Selected.Email, // To field
           "Text",                        //  Subject Field
           "<b><font color=blue>HTML</font></b>text"           // Body Field, this could also be HtmlText1.HtmlText     
           {IsHtml:true}                  // the record elements for other parameter          
       )

 

I am a real novice when it comes down to these things.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Adding email to an existing formula

Hi @GC87

In theory, you should be able to add your call to the SendMail function after the calls to SubmitForm and Patch. The formula would look something like this:

 

 

If(
    IsBlank(Subject.Text) || IsBlank(Description.Text),
    UpdateContext({msg_visible: true}),
    SubmitForm(NewTicketForm);
    UpdateContext(
        {
            New: Patch(
                Tickets,
                LookUp(
                    Tickets,
                    ID = Text(Max(Tickets,ID))
                ),
                {
                    Subject: Subject.Text,
                    Description: Description.Text
                }
            )
        }
    );
Office365.SendEmail(
          DataCardValue12.Selected.Email, // To field
           "Text",                        //  Subject Field
           "<b><font color=blue>HTML</font></b>text"           // Body Field, this could also be HtmlText1.HtmlText     
           {IsHtml:true}                  // the record elements for other parameter          
    ) )

 

View solution in original post

14 REPLIES 14
Highlighted
Super User III
Super User III

Re: Adding email to an existing formula

Hi @GC87

In theory, you should be able to add your call to the SendMail function after the calls to SubmitForm and Patch. The formula would look something like this:

 

 

If(
    IsBlank(Subject.Text) || IsBlank(Description.Text),
    UpdateContext({msg_visible: true}),
    SubmitForm(NewTicketForm);
    UpdateContext(
        {
            New: Patch(
                Tickets,
                LookUp(
                    Tickets,
                    ID = Text(Max(Tickets,ID))
                ),
                {
                    Subject: Subject.Text,
                    Description: Description.Text
                }
            )
        }
    );
Office365.SendEmail(
          DataCardValue12.Selected.Email, // To field
           "Text",                        //  Subject Field
           "<b><font color=blue>HTML</font></b>text"           // Body Field, this could also be HtmlText1.HtmlText     
           {IsHtml:true}                  // the record elements for other parameter          
    ) )

 

View solution in original post

Highlighted
Frequent Visitor

Re: Adding email to an existing formula

Thank you timl for the response I had another question if I wanted to specific the emails instead of DataCardValue12.Selected.Email do I just place the email addresses I want? Im not sure exactly how that portion works or do I need to create a flow for that value to know where it needs to go?

Super User III
Super User III

Re: Adding email to an existing formula

Hi @GC87

Yes, you can just replace DataCardValue12.Selected.Email with your desired email address (enclosed within double quotes).

Highlighted
Frequent Visitor

Re: Adding email to an existing formula

If(
    IsBlank(Subject.Text) || IsBlank(Description.Text),
    UpdateContext({msg_visible: true}),
    SubmitForm(NewTicketForm);
    UpdateContext(
        {
            New: Patch(
                Tickets,
                LookUp(
                    Tickets,
                    ID = Text(Max(Tickets,ID))
                ),
                {
                    Subject: Subject.Text,
                    Description: Description.Text
                }
            )
        }
    );
Office365.SendEmail(
          "email1@company.com", "email2@company.com", "email3@company.com", // To field
           "Text",                        //  Subject Field
           "<b><font color=blue>HTML</font></b>text"           // Body Field, this could also be HtmlText1.HtmlText     
           {IsHtml:true}                  // the record elements for other parameter          
    ) )

I have legit email addresses instead of email#@company.com

 

This is what I have currently placed and so far it is giving me an error.

 

Unexpected characters. The formula contains 'ParenClose' where 'CurlyOpen' is expected. This error occurs, if for example, a formula contains '{Val@7}' instead of '{Val:7}'. When you set a variable, the syntax requires a colon instead of an "at" symbol.

Highlighted
Super User III
Super User III

Re: Adding email to an existing formula

Can you try comma separating the email addresses into a single string to see if that works?

"email1@company.com,email2@company.com,email3@company.com"

 

Highlighted
Frequent Visitor

Re: Adding email to an existing formula

If(IsBlank(Subject.Text) || IsBlank(Description.Text) ,UpdateContext({msg_visible:true}),SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description:Description.Text})});
Office365.SendEmail(
"cramsey@antunovich.com, gcordova@antunovich.com, blane@antunovich.com", // To field
"Text", // Subject Field
"<b><font color=blue>HTML</font></b>text" // Body Field, this could also be HtmlText1.HtmlText
{IsHtml:true} // the record elements for other parameter
))

 

 

The areas highlighted in red are where errors are located. For some reason it has the an error with the semi colon after (new ticket form), not sure whats going on between SendEmail and the bracket, as well as infront of the curly bracket from IsHtml:True.

 

If I remove the whole portion of the email my previous code works without any errors.

Highlighted
Frequent Visitor

Re: Adding email to an existing formula

I just fixed the SendEmail and NewTicket Form errors. Apparently I forgot to place Outlook into the data source.....whoops. However I get {IsHtml:true} with an error, is this because for the curly brackets?

Highlighted
Super User III
Super User III

Re: Adding email to an existing formula

Perhaps you're just missing a comma after the previous line?

"<b><font color=blue>HTML</font></b>text" ,
Highlighted
Frequent Visitor

Re: Adding email to an existing formula

Thank you again timl looks like that did the trick. Going to test and see if I can get an email response. Thank you

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,840)