web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Patch to Sharepoint list: Parenclose w. EOF expected

(0) ShareShare
ReportReport
Posted on by Moderator

 

I'm struggling with my first Patch function.

I am tying to patch enter a new record into a Sharepointlist (Corona_Test_Lehrer_in_Klassen)

There are 3 fields:

1. Lehrer ... There I want to enter the current user's email address (stored in varUserEmail). The field is a Sharepoint person field. So it should take the e-mail. With a form that works.

 

2. Schule ... There I want to store the name of the school (selected in a dropdown box named Dropdown_Schule)

3. Klasse ... There I want to store the name of the class (selected in a combobox named ComboBox_Klasse)

 

I don't know where I'm going wrong.

 

 

 

Patch(
 Corona_Test_Lehrer_in_Klassen; 
 Defaults(Corona_Test_Lehrer_in_Klassen; 
{ 
 Lehrer: varUserEmail;
 Schule: Dropdown_Schule.Selected.Result;
 Klasse: ComboBox_Klasse.Selected.Klasse;
}
)

 

 

 

Categories:
I have the same question (0)
  • CNT Profile Picture
    10,919 Super User 2024 Season 1 on at
    Re: Patch to Sharepoint list: Parenclose w. EOF expected

    @schwibach Try this,

    Patch(
     Corona_Test_Lehrer_in_Klassen; 
     Defaults(Corona_Test_Lehrer_in_Klassen); 
    	{ 
    		Lehrer: varUserEmail;
    		Schule: Dropdown_Schule.Selected;
    		Klasse: First(ComboBox_Klasse.SelectedItems);
    	}
    )
  • schwibach Profile Picture
    Moderator on at
    Re: Patch to Sharepoint list: Parenclose w. EOF expected

    Thank you.

    Now, it gives me a different mistake.

    It says there is an invalid argument type. It's expecting a record value with a different schema.

  • CNT Profile Picture
    10,919 Super User 2024 Season 1 on at
    Re: Patch to Sharepoint list: Parenclose w. EOF expected

    @schwibach I'm don't know what datatypes you have in you SP List. You'll have to adjust the formula I gave to match that data type.

  • schwibach Profile Picture
    Moderator on at
    Re: Patch to Sharepoint list: Parenclose w. EOF expected

    Thanks!

     

    Lehrer is a person field

    The other two are lookup fields that reference one line text fields.

    I'll try to figure out how to deal with the lookup fields

  • CNT Profile Picture
    10,919 Super User 2024 Season 1 on at
    Re: Patch to Sharepoint list: Parenclose w. EOF expected

    @schwibach May I ask you why you are trying to use Patch. Having an EditForm and using SubmitForm may be very simple.

  • schwibach Profile Picture
    Moderator on at
    Re: Patch to Sharepoint list: Parenclose w. EOF expected

    I've never used Patch before. It seemed "cleaner" than using a form and making the form invisible.

     

    But I guess you are right... I'll try to do it with a form and dropdown boxes.

  • Verified answer
    RandyHayes Profile Picture
    76,291 Super User 2024 Season 1 on at
    Re: Patch to Sharepoint list: Parenclose w. EOF expected

    @schwibach 

    Agreed with @CNT on the use of a Form.  Use them as much as possible as they provide more power than you can design in and have more functionality that you don't want to be without!

     

    That said, your formula for the Patch can be:

    Patch(
     Corona_Test_Lehrer_in_Klassen; 
     Defaults(Corona_Test_Lehrer_in_Klassen); 
    	{ 
    	Lehrer: 
     { Claims:"i:0#.f|membership|" & Lower(varUserEmail); 
     Department:"";
     DisplayName: varUserEmail;
     Email: varUserEmail;
     JobTitle: "";
     Picture: ""
     };
    	Schule: Dropdown_Schule.Selected;
    	Klasse: First(ComboBox_Klasse.SelectedItems);
    	}
    )

    You need to supply a SharePoint user record for a Person column.  The above does that.

     

    I hope this is helpful for you.

  • schwibach Profile Picture
    Moderator on at
    Re: Patch to Sharepoint list: Parenclose w. EOF expected

    Thank you.

    If I may ask a followup question.

    How do I get the form to submit the current user into the person field in the form.

    I tried to write user() in the update field and using the varUserEmail in both the DataCard and the DataCardValue.

     

    I'm probably missing something really simple

  • RandyHayes Profile Picture
    76,291 Super User 2024 Season 1 on at
    Re: Patch to Sharepoint list: Parenclose w. EOF expected

    @schwibach 

    SharePoint user records are vastly different than other record types - like User() or Office365 user records.  So, you have to convert to make that happen.

     

    So, in the form you need to set the Update property of the DataCard that represents your Lehrer column (assuming this is what we are talking about, to:

    { Claims:"i:0#.f|membership|" & Lower(varUserEmail); 
     Department:"";
     DisplayName: varUserEmail;
     Email: varUserEmail;
     JobTitle: "";
     Picture: ""
    }

     

    NOW...with the above formula, your field will ALWAYS be updated to the user represented in the varUserEmail.  AND, your form will always be "Unsaved" for all other users.

     

    So, if you want to account for that, then do so with the following:

    Coalesce(
     Self.Default,
    
     { Claims:"i:0#.f|membership|" & Lower(varUserEmail); 
     Department:"";
     DisplayName: varUserEmail;
     Email: varUserEmail;
     JobTitle: "";
     Picture: ""
     }
    )

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 652 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 410 Super User 2025 Season 2

#3
developerAJ Profile Picture

developerAJ 236

Last 30 days Overall leaderboard