Hello All,
I have a gallery with editable rows and my Data source is SharePoint . I have written a patch function to store the values from gallery to SP. I have a Copy Icon on each row of my gallery to copy that particular item.
Here is my copy item function looks like :
Now, I am adding another screen where on click of a button I am storing all the values of this particular gallery into a collection including this copy Icon function also .
So on my New screen I pass the collection into the items property and I am able to get all the values.
Now when I am adding patch function due to the circular reference I am not able to patch , as copy is a control in my previous screen and its not accepting in this screen .
Collection formula is : Gallery . Selected. All Items
Copy Icon is also stored in the collection as highlighted:
Question : I am able to use defaults in the patch and able to create a record as a new record but then I need to use this record as I Already have a record and I need to update it .
Please suggest me any advice to overcome this error .
Solved! Go to Solution.
So in my first screen I have a gallery : gallery1connected to a SharePoint and a similar patch function is written and its working as expected . Now I have a Main gallery upon clicking on the button I am creating a collection and getting allitems from gallery1 and on Screen 2 i have a gallery2 and I am passing the collection as items .
So these images are of my Screen 2 where copy is an Icon in my screen1 which is copying item and in the collection also its getting saved . But on my Screen 2 when I patch the collection I am getting this error shown in image 1 . So the ID :ID might not work
@Anonymous
It is difficult to see the images you have in your post as they are too small and trying to zoom on them they just get blurry.
But the one thing I can see is that with this extra collection (which again is just extra typing for no need) you are not including the ID. You should ALWAYS pass around the ID of a record as it is the primary identifier for the record and you will almost always need it.
And to follow that statement, if you set your Gallery2 Items to Gallery1.AllItems (or some filtered or derived table from that gallery) then your Gallery 2 will show everything needed - without some extra collection.
Now in your second part of your last response, you are stating that you are trying to then patch some other collection? What is the purpose of the extra column called Copy? I'm a little confused on what you are trying to do, but I think you might be over complicating it a bit. I can't tell for sure as the images are hard to see.
@Anonymous
What is the collection for in your scenario? Your gallery is already acting as a collection in this case.
There is no need for setting a varRecord and all of the extraneous typing you are doing there either.
You can simply set your formula to update your data source directly.
Patch(yourDataSource,
ForAll(yourGallery.AllItems,
{ID: ID,
Title: TextInputx.Text,
...etc...
}
)
)
Your pictures are too small for me to read the names of your controls, but the one important part of the above formula is that you utilize the ID. When you supply the ID, then Patch will know to update the record that matches that ID. If the row in your Gallery does NOT have an ID (i.e. a new row), then the ID will be blank, and Patch will know to create a record instead of update it.
I hope this is helpful for you.
So in my first screen I have a gallery : gallery1connected to a SharePoint and a similar patch function is written and its working as expected . Now I have a Main gallery upon clicking on the button I am creating a collection and getting allitems from gallery1 and on Screen 2 i have a gallery2 and I am passing the collection as items .
So these images are of my Screen 2 where copy is an Icon in my screen1 which is copying item and in the collection also its getting saved . But on my Screen 2 when I patch the collection I am getting this error shown in image 1 . So the ID :ID might not work
@Anonymous
It is difficult to see the images you have in your post as they are too small and trying to zoom on them they just get blurry.
But the one thing I can see is that with this extra collection (which again is just extra typing for no need) you are not including the ID. You should ALWAYS pass around the ID of a record as it is the primary identifier for the record and you will almost always need it.
And to follow that statement, if you set your Gallery2 Items to Gallery1.AllItems (or some filtered or derived table from that gallery) then your Gallery 2 will show everything needed - without some extra collection.
Now in your second part of your last response, you are stating that you are trying to then patch some other collection? What is the purpose of the extra column called Copy? I'm a little confused on what you are trying to do, but I think you might be over complicating it a bit. I can't tell for sure as the images are hard to see.
Thanks @RandyHayes patching with ID worked ! This solved my issue. But then when I am patching my collection to sharepoint list its throwing me an error regarding the version number as read only even though I am not changing any version number.
I have attached the image
My formula is Patch(SPlist,CollectionName)
@Anonymous
It is that your collection contains all record columns and some you might not be interested in changing/using. SO, I would omit them from the collection when you gather it, or use a ShowColumns on your collection in the patch to only expose the columns you do want to update.
User | Count |
---|---|
122 | |
87 | |
86 | |
75 | |
67 |
User | Count |
---|---|
214 | |
181 | |
137 | |
96 | |
83 |