Good Morning
I am trying to patch a new record from a "Create New' button on a Form
I am currently using
Patch('Suggested Travel', Defaults('Suggested Travel'), {BookingRef: DataCardValue9})
The BookinRef field in my SharePoint list is a lookup column from another table.
When I click submit it creates the record but does no update the BookingRef field in my sharepoint list
Since it is a lookup do I need to add something to my patch.
Thank you
Solved! Go to Solution.
Hello @Sn3l ,
Thank you for catching that error ! I created a test case and the above formula seems to be working for me, Most probably something else is going wrong. Can you add the following in the on success property
Patch(
'Suggested Travel',
LookUp(
'Suggested Travel',
ID = LastSubmitID
),
{BookingRef: {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id: DataCardValue9.Selected.Id,
Value: DataCardValue9.Selected.Value
}
}
);
Notify("Data was patched successfully",NotificationType.Success,5000);
Now when you submit the form are you seeing the above message ? if yes then it means that your form submit is working correctly. If no then your submit form might have some issues
Check your actual data source and see if any data is getting updated ? Also look if the variable lastformsubit has a value in it, all of this should give you clues into why it is not working
Hello @Sn3l ,
Can you try this
On the button for Submit/save for the form add this (replace with your form name)
SubmitForm(FormName);
Set(
LastSubmitID,
FormName.LastSubmit.ID
);
On your Form's OnSuccess Property add this
Patch(
'Suggested Travel',
LookUp(
'Suggested Travel',
ID = LastSubmitID
),
{
BookingRef: DataCardValue9 //Here i think you need to add DatacardValue9.Text if it is a text field or DatacardValue9.Selected.Value if a combobox
})
Please note that Defaults is used to create a new record . Use patch to update an existing record
Hope this helps 🙂
Hi.
Thank you for the response and help
On the Form on Success Property
Patch(
'Suggested Travel',
LookUp(
'Suggested Travel',
ID = LastSubmitID
),
{BookingRef:DataCardValue9})
If I add .value since this is a combobox
I get the following error
GetRef it is refering to is BookingRef ( I renamed the column in SharePoint but it kept this name in the List
If I remove the .value There is no error, but if I select and submit. Nothing happens
Hello @Sn3l ,
Can you Try
{BookingRef:DataCardValue9.Selected.Value})
If you are seeing an error then select the combobox and go to its advanced property and look at the DisplayField if the value in that square bracket is not ["Value"] then replace with whatever value that you see. For example in the below case i will replace my formula with
{BookingRef:DataCardValue9.Selected.Country})
Cheers !
Thank you so much for the help.
Can confirm that it is indeed a value field. It does however not trigger anything and still does not like the .value.
I have also tried
Patch(
'Suggested Travel',
LookUp(
'Suggested Travel',
ID = LastSubmitID
),
{BookingRef: {Value:DataCardValue9})
With no luck - No event on "OnSelect"
Hello @Sn3l ,
I missed the fact that this is a lookup column . Dummy me !
Lookup columns are special columns and have a particular schema. Therefore can you please try this
Patch(
'Suggested Travel',
LookUp(
'Suggested Travel',
ID = LastSubmitID
),{
BookingRef: {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id: DataCardValue9.Selected.Id,
Value: DataCardValue9.Selected.Value
}}
)
THis should definetly work ! Else please post the error that you are seeing
Thank you so much for your help.
I get Invalid Argument error.
With the following no error. But nothing happens
Patch(
'Suggested Travel',
LookUp(
'Suggested Travel',
ID = LastSubmitID
),
{BookingRef: {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id: DataCardValue9.Selected.Id,
Value: DataCardValue9.Selected.Value
}
}
)
Hello @Sn3l ,
Thank you for catching that error ! I created a test case and the above formula seems to be working for me, Most probably something else is going wrong. Can you add the following in the on success property
Patch(
'Suggested Travel',
LookUp(
'Suggested Travel',
ID = LastSubmitID
),
{BookingRef: {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id: DataCardValue9.Selected.Id,
Value: DataCardValue9.Selected.Value
}
}
);
Notify("Data was patched successfully",NotificationType.Success,5000);
Now when you submit the form are you seeing the above message ? if yes then it means that your form submit is working correctly. If no then your submit form might have some issues
Check your actual data source and see if any data is getting updated ? Also look if the variable lastformsubit has a value in it, all of this should give you clues into why it is not working
User | Count |
---|---|
252 | |
104 | |
94 | |
50 | |
39 |