Hello,
I've an app where users submit some info about their profile and save.
I need to place on save button an if condition to differentiate the patch command, because first-time people will save their profile the patch will create a new item on a sharepoint list, but then if the user wants to edit some field and save again the patch will update.
Patch to create a new item:
Patch(Users, Defaults(Users),
{ Name:
{
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:"i:0#.f|membership|" & Lower(User().Email),
Department:"",
DisplayName:User().FullName,
Email:User().Email,
JobTitle:".",
Picture:User().Image
},
InternalNumber:Value(txtNInterno.Text),
PhoneNumber:Value(txtContacto.Text),
CostCenter:Value(txtCC.Text),
Company:drpEmpresa.SelectedText,
Manager:cmbChefia});
UpdateContext({varViewMode:true})
Patch to edit existing item based on if the user already exists on the list:
Patch(Users, LookUp(Users,Name.DisplayName = User().FullName), {
InternalNumber:Value(txtNInterno.Text),
PhoneNumber:Value(txtContacto.Text),
CostCenter:Value(txtCC.Text),
Company:drpEmpresa.SelectedText,
Manager:cmbChefia})
___
I've tried this on two different buttons and it worked, now I Need to join both on save button with the following logic:
If the User().Fullname already exists on sharepoint list, field name perform patch to create, otherwise patch to edit.
Someone can help me?