cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
schwibach
Resolver I
Resolver I

Patch to Sharepoint list: Parenclose w. EOF expected

 

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;
}
)

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

9 REPLIES 9
CNT
Super User
Super User

@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);
	}
)

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.

@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.

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

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

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.

RandyHayes
Super User
Super User

@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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

schwibach
Resolver I
Resolver I

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
Super User
Super User

@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: ""
    }
)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,446)