cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

ClearCollect error with forms

Good day,

 

I'm receiving an odd error when trying to use ClearCollect. This code works:

 

ClearCollect(
    colFormLinks,
    {
        Name: "JobEdit",
        FormName: frmJobEdit
    }
);

 

Or this code works:

 

ClearCollect(
    colFormLinks,
    {
        Name: "JobAdd",
        FormName: frmJobAdd
    }
);

 

 

But this code does not:

 

ClearCollect(
    colFormLinks,
    {
        Name: "JobEdit",
        FormName: frmJobEdit
    },
    {
        Name: "JobAdd",
        FormName: frmJobAdd
    }
);

 

 

Both objects frmJobEdit and frmJobAdd are valid objects in my Power App. I have another collection already that has multiple entries that works fine. Can anyone help me understand why I can only have on item in the collection? 

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User
Super User

@Anonymous 

The reason this doesn't work is because frmJobEdit and frmJobAdd are different object types, and the value that we store in a field must be of the exact same type (eg, number, string, date, etc).
Therefore, the following beneath is valid syntax, but invalid when FormName references different forms.

ClearCollect(
    colFormLinks,
    {
        Name: "JobEdit",
        FormName: frmJobEdit
    },
    {
        Name: "JobEdit 2",
        FormName: frmJobEdit
    }
);

 

View solution in original post

5 REPLIES 5
Nogueira1306
Super User
Super User

https://docs.microsoft.com/en-US/powerapps/maker/canvas-apps/functions/function-clear-collect-clearc...

 

Check that link but I think your code is ok

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Check my LinkedIn!

Check my User Group (pt-PT)!

Last Post on Community

My website!

timl
Super User
Super User

@Anonymous 

The reason this doesn't work is because frmJobEdit and frmJobAdd are different object types, and the value that we store in a field must be of the exact same type (eg, number, string, date, etc).
Therefore, the following beneath is valid syntax, but invalid when FormName references different forms.

ClearCollect(
    colFormLinks,
    {
        Name: "JobEdit",
        FormName: frmJobEdit
    },
    {
        Name: "JobEdit 2",
        FormName: frmJobEdit
    }
);

 

RandyHayes
Super User
Super User

@Anonymous 

Form objects will all be different based on their setup.  Therefore you cannot add them to the same column name in your table as they will be different types.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Anonymous
Not applicable

Thank you, this makes sense. I assumed because both objects were "forms" that they could be saved to the same field.

Anonymous
Not applicable

Thank you. This makes sense. I'll see if I can come up with a different way to handle what I'm trying to accomplish!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,129)