cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver I
Resolver I

Collect Record instead of text

Hello,

          I have a quick question regarding the collect statement. 

I have my code 

Collect(col1,{Department: "Administration",Division: "Executive", Email: "Test@test.com"})

However i get an error saying that  The Division column in the data source i am updating expects a record and i am using text. 

What am i missing to update the division column with the record value ? 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Collect Record instead of text

Hi @stephenJames ,

Please try this formula:

Collect(
    col1,
    {
        Department: "Administration",
        Division: {Value:"Executive"},
        Email: "Test4@test.com"
    }
)

The reason why you met this problem is that Choice column's structure is a column named Value inside a column.

So when you update it, you need to update with the same structure.

 

 

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

8 REPLIES 8
Highlighted
Super User
Super User

Re: Collect Record instead of text

You need to do something like this with the Department section within your collection:

Department: Lookup(Department, Name = "Administration")

I assumed that Department is the name of the lookup entity and Name is the column name that defines the name as Administration.

Try this out. You should be good. If not, let me know.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
Highlighted
Resolver I
Resolver I

Re: Collect Record instead of text

Hi @PowerAddict  thanks for your suggestion. Your suggestion unfortunately didn't work. I believe i need to give a little more context to understand what i am trying to accomplish. 

 

The data source i am using is a collection (col1) which already contains data. 

 

I am trying to add a new record to the collection manually by defining the data to be entered. 

The three columns in the collection are Department, Division and Email. 

Department and Email hold simple text, whereas the Division column holds a value(i believe thats the correct term)

Heres an image of the collection layout

 collectionlayout.PNG  divisionlayout.PNG

 

So my code is simply to add a new record to the existing collection data source

 

Collect(
    col1,
    {
        Department: "Administration",
        Division: "Executive",
        Email: "Test4@test.com"
    }
)

 

 

Im not sure if you meant to use Department, but there is no lookup on that column. 

 

Thanks

Highlighted
Super User
Super User

Re: Collect Record instead of text

My bad. Your Division column is the one that stores records not just text fields. So when you are adding those Divisions in your collection for the 1st time, how are you adding them. Are you looking them up somewhere? Can you share the columns that exist within a Divison record?

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
Highlighted
Resolver I
Resolver I

Re: Collect Record instead of text

@PowerAddict 

 

So to get them into the collection for the first time i am importing a sharepoint list using this code

ClearCollect(col1,ShowColumns(sharepointlist,"Email","Department","Division"));

The sharepoint list settings are

sharepointcolumns.PNG

and the available choices for the Division are

Executive

HR

Payroll

 

 

 

Highlighted
Super User
Super User

Re: Collect Record instead of text

Apologies for the delay. Ok so try something like this:

Division: sharepointlist.Division.Executive

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
Highlighted
Community Support
Community Support

Re: Collect Record instead of text

Hi @stephenJames ,

Please try this formula:

Collect(
    col1,
    {
        Department: "Administration",
        Division: {Value:"Executive"},
        Email: "Test4@test.com"
    }
)

The reason why you met this problem is that Choice column's structure is a column named Value inside a column.

So when you update it, you need to update with the same structure.

 

 

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

Highlighted
Resolver I
Resolver I

Re: Collect Record instead of text

Hello @v-yutliu-msft thanks for your suggestion.

 

Unfortunately i am still getting the error message.

division error.PNG

 

Highlighted
Resolver I
Resolver I

Re: Collect Record instead of text

Hi @v-yutliu-msft . So you suggestion did work in the end. At first it did not and was still causing the same issue. However I deleted all my code from with PowerApps and retyped it, and it worked. 

 

Thank you for everyone's help on this.

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,795)