0
votes

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)})````
1
You may want to consider using the Monitor (docs.microsoft.com/powerapps/maker/monitor-overview) to see if the request is going to SharePoint, and some response being sent back. - carlosfigueira

1 Answers

0
votes

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.