cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper IV
Helper IV

Patching then send multiple emails

Hi,

 

I'm working on a project, a part of this project is patch some fields then send emails to multiple recipients 

 

this is a demo I'm trying to solve my issue on it 

 

I'm working on SharePoint list, after submitting the form it should change the status to "Mail Sent" and field name "Sc1ModifiedBy" to insert the current Editor name but this is not happing exactly, the strange point after I submit the item number 5 the status and ScrNotificationTo patched in item number 3 !

the same thing after submitting item number 8 the item number 6 status and ScrNotificationTo are patched! 

 

Patch-Emails1.png

 

and this is the Gallery Screen

 

Patch-Emails2.png

Screen 2 - the form

Button.OnSelect : Submit(Form) 

 

Patch-Emails3.PNG

 

Form.OnSucsess :

 

Patch(
    'Demo - Collect',
    First(
        Filter(
            'Demo - Collect',
            ID = GalleryMain.Selected.ID
        )
    ),
    {
        Scr1ModifiedBy: CurrentUserName,
        Status: {
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
            Value: "Mail Sent",
            Id: GalleryMain.Selected.ID
        }
    }
);//send email to Author
Office365.SendEmail(
    "my-email@abcxyz.com";
    GalleryMain.Selected.Author.Email;
    DCMgrNameDD.Selected.Email,
    "Your Request Sending mails now",
    "<p>Hi!</p>
<p><br />Test Mail</p>
<p><br />
<a href= 'www.abcxyz.com' target='_blank'>User ID Preferences</a></p>",
    {Cc: "my-email@abcxyz.com",
        IsHtml: true
    });RequestHide()

 

 

I'm receiving the email to my email "my-email@abcxyz.com" in To: and Cc: , but PA can't send emails to the other fields values: GalleryMain.Selected.Author.Email;
DCMgrNameDD.Selected.Email

 

I checked the values by inserting label and they are correct, but I don't know why PA can't send emails to them 

 

also, the patching not working correctly!

 

Thanks 

13 REPLIES 13
Helper IV
Helper IV

 

Dears, any suggestions? 

Community Support
Community Support

Hi @ElMeSaFeR,

 

Do you custom a form for your SP list using PowerApps?

 

I have made a test on my side, and don't have the issue that you mentioned.

 

For your first issue, it seems to tell that there is something wrong with the Filter function within your Patch function that you provided. 

 

Please take a try to modify your Patch function as below:

Patch(
    'Demo - Collect',
    SharePointForm1.LastSubmit,   /* <--- modify here */
    {
        Sc1ModifiedBy:CurrentUserName,
        Status:{
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
             Value: "Mail Sent",
Id: GalleryMain.Selected.ID } } )

Note: The SharePointForm1 represents the Edit form control within the Edit screen.

 

then check if the issue is solved.

 

For your second issue, I think there is something wrong with the Office365.SendEmail() function that you provided. Please modify your Office365.SendEmail() function as below:

Office365.SendEmail(
    "my-email@abcxyz.com"&";"&
     GalleryMain.Selected.Author.Email&";"&
     DCMgrNameDD.Selected.Email,
    "Your Request Sending mails now",
    "<p>Hi!</p>
     <p><br />Test Mail</p>
     <p><br />
     <a href= 'www.abcxyz.com' target='_blank'>User ID Preferences</a></p>",
    {
Cc: "my-email@abcxyz.com", IsHtml: true }
)

then check if the issue is solved.

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-xida-msft

 

yes it's working fine now , many thanks 

 

but do you think this code

 

SharePointForm1.LastSubmit,   

is the best practice in this case ... what about if there's many users working and submitting the form in same time ?

Hi @ElMeSaFeR,

 

In order to avoid many users submitting the form, please take a try with the following workaround:

 

Set the OnSelect property of the "Submit" button to following formula:

Set(SubmittedItem,EditForm1.Updates);SubmitForm(EditForm1)

Note: The EditForm1 represents the Edit form control within your app.

 

Modify the Patch function within the OnSuccess property of the Edit form control as below:

Patch(
    'Demo - Collect',
    SubmittedItem,   /* <--- modify here */
    {
        Sc1ModifiedBy:CurrentUserName,
        Status:{
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
             Value: "Mail Sent",
Id: GalleryMain.Selected.ID } } )

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-xida-msft

Hi Kris, 

 

Thanks so much, I think it will work .. I'll check it by tomorrow and will feedback to you 

 

I'd like to ask about this code 

 

    First(
        Filter(
            'Demo - Collect',
            ID = GalleryMain.Selected.ID
        )
    )

why you advise me to delete it, or when I have to use it? 

 

Regards;

@v-xida-msft

sorry Kris it's not working 

 

it's double the times - each time I submit the form it creating tow items in SP list - and the only 2nd item the values changes!

I check also 

 

    First(
        Filter(
            'Demo - Collect',
            ID = GalleryMain.Selected.ID
        )
    )

and

    First(
        Filter(
            'Demo - Collect',
            ID = SubmittedItem.ID
        )
    )

and many tries but no luck 

 

now my project is working  fine with sending emails except changing some the values 

I wish we can find a solution for this case soon

 

Regards

Anonymous
Not applicable

@ElMeSaFeR We will esclate this for you, @Audrie-MSFT

Hi @ElMeSaFeR,

 

I actually agree with @v-xida-msft post on Saturday. Were you able to try with those changes? I believe that would work well. Let me know if you received errors when you changed the formula patch in that way.

 

Thank you,

Audrie

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Check out the Power Apps Community Call for January 2021

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (11,044)