cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dbigel
New Member

unable to pass variable in for all when patching collection

I have a simple patch statement that inserts a record into sharepoint.  At the time of patching I return the unique record id to a variable.

 

then I have a collection and I want to pass that variable with all the records in the collection to another sharepoint list.

 

like this:

record 123 gets added to table A

 

My Variable VRID gets set to 123

 

My collection has three rows 

Name: Age: Alias

John, 15, jb

Mary, 11, mr

Sam, 22, sk

 

I want to write the rows to sharepoint like this

refid: Name: Age: Alias

123, John, 15, jb

123, Mary, 11, mr

123, Sam, 22, sk

 

I have the following statement forall(mycol, patch(mysp, defaults(mysp, {refid: vRID, Name: mycolName, Age: mycolAge, Alias: mycolAlias})

 

But it throws an error of the type of argument does not match the expected type table returned number on the vRID field.

How can I pass a static variable when I am patching multiple records to my sharepoint list?

 

Thanks

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

Hi @dbigel ,

Do you mean that when you updating, this part will have error message "refid: vRID"?

Could you tell me:

1)the data type of refid field?

2)the formula about how you setting vRID?

I've made a similar test and found that if refid filed is number typr and  vRID is number value then there should be no problem.

Here's my test for your reference:

1)set variable:

Set(vara,1)

2)create collection:

ClearCollect(test,{aaa:"a",bbb:4},{aaa:"b",bbb:5})

3)update:

ForAll(test,Patch(fruit1234,Defaults(fruit1234),{Title:aaa,amount:bbb,price:vara}))

//in my test, price column is number type. Vara is number value. I updated successfully.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

turns out the field in sharepoint was set up as a lookup field.  I changed it to numeric and then this worked fine.  

View solution in original post

4 REPLIES 4
sayyed007amir
Resolver II
Resolver II

Can you please share your code here

 

this is all it is

forall(mycol, patch(mysp, defaults(mysp, {refid: vRID, Name: mycolName, Age: mycolAge, Alias: mycolAlias})

Hi @dbigel ,

Do you mean that when you updating, this part will have error message "refid: vRID"?

Could you tell me:

1)the data type of refid field?

2)the formula about how you setting vRID?

I've made a similar test and found that if refid filed is number typr and  vRID is number value then there should be no problem.

Here's my test for your reference:

1)set variable:

Set(vara,1)

2)create collection:

ClearCollect(test,{aaa:"a",bbb:4},{aaa:"b",bbb:5})

3)update:

ForAll(test,Patch(fruit1234,Defaults(fruit1234),{Title:aaa,amount:bbb,price:vara}))

//in my test, price column is number type. Vara is number value. I updated successfully.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

turns out the field in sharepoint was set up as a lookup field.  I changed it to numeric and then this worked fine.  

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,766)