Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
546 views
in Technique[技术] by (71.8m points)

powerapps - Patch function doesn't send items to my sharepoint list ( Power Apps)

please, I have a problem with the Patch function, it shows me no error but it sends nothing to the sharepoint list, here are the columns I have: Country, Project_Customer, Project_Category, Project_Type, are comboboxes of choice, project_site is a search column, project manager is a person type column, project description and project name are text lines and project amount is a number (currency type) , and project_status is a dropdown. here is the patch function:

{Country: ComboBoxCOUNTRY.Selected;
Project_Customer: ComboBoxCustomer.Selected;
Project_site: ComboBoxSite.Selected;
Project_Category: ComboBoxCATEGORY.Selected;
Project_Type: ComboBoxPROJECTTYPE.Selected;
Project_Name: Text (TextInputProjectName);
Project_Amount: TextInputProjectAmount;
Project_status: DropdownSTATUS;
Project_manager: ComboBoxmanager;
'Project_Description': Text (TextInputDETAIL)})````
question from:https://stackoverflow.com/questions/65919975/patch-function-doesnt-send-items-to-my-sharepoint-list-power-apps

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Different SharePoint fields have different requirements for patching.

For a Person field you have to send an object with Claims, Department, DisplayName, Email, Jobtitle and Picture fields, but only the Claims, displayname and email address seem to be required (you may want to experiment with which fields actually need a value, but all of them have to be present). Below is an example from one of my powerapps

AssignedTo: {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    Claims:Concatenate("i:0#.f|membership|",Assignee.UserPrincipalName),
    Department:"",
    DisplayName:Assignee.DisplayName,
    Email:Assignee.Mail,
    JobTitle:"",
    Picture:""
}

For SharePoint choice fields, you have to send an object with a value property

mychoicefield: {Value: "some value" }

For lookup fields, you have to send an ID and value, where ID is the ID from the lookup list item and Value is the Title

MyLookupField: { ID:1,Value:"Some title"}

Patch doesn't throw an error when you send the wrong information. YOu can capture and output your patch by setting a variable or checking for errors. I typically do both

Set(PatchResults,Patch(datasource,defaults(datasource),{
  Title: "Hello"
};

If(Not(IsEmpty(Errors(datasource))),Notify(First(Errors(datasource)).Message,NotificationType.Error))

The above check if the datasource to which you patched has any errors and if there are, creates a message at the top with a red background.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...