cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Pinguito
Helper I
Helper I

Convert collection register to entity type

Hi all,

 

I need to insert an item in a Collection "X" who have a column type "Product" entity.

 

Example:

ClearCollect(X,    
    {
        Product: First(Product)
    }
)

 

This item is a register of a Collection "Y" origined by Product entity too, but i'm using "ShowColumns" function and this broken the Product type

 

Example:

ClearCollect(Y;
     ShowColumns(
        Produtos;"name";"hierarchypath";"productstructure";"price";"standardcost"
     )
);

 

I try to add a register of Collection Y to Product column of Collection X but is given me error like "Waiting Record from another type".

 

I can't bring all my product table to collection Y because i'm working in offline mode and I think this is consuming so much memory.

3 REPLIES 3
BCLS776
Super User
Super User

Hi Pinguito,

 

I'm not 100% sure what you want to do, but I'll give it a try.

 

Your first piece of code:

BCLS776_0-1627851840706.png

is creating a new collection 'X', and it is storing a single record with a single column called "Product". Within that record's column is the first record from another data source called "Product", which we don't know much about.

Your second piece of code:

BCLS776_1-1627851980327.png

is creating a new collection 'Y', that contains all the records and five of the columns from another data source called "Produtos". We can presume this uses less storage than the original Produtos since you are using ShowColumns to select specific columns.

Even if Produtos (from your second statement) and Product (from your first statement) are the same data source, you will have difficulty matching up the records. Produtos and Produce likely have different column names, so a record from collection X is not the same thing as a record from collection Y especially after a ShowColumns operation. In other words, you can do a direct comparison or you'll get a "Waiting Record from another type" type of error. Make sense?

 

This probably doesn't answer your question, so can you help us understand what you want to do with collection 'X'?

 

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Hi @BCLS776 ,

 

Thank very much for your response,

 

First of all, I’m so sorry. I forgot to translate “Produtos” to “Product”. Produtos in Portuguese means Product.

 

Basically, I have one column of a Collection “X” that receive one type specific of record, for example a column who have relationship with another entity “Z”.

 

And, in this other Collection “Y”, I list all the registers (products) of entity “Z” and save this in device cache, to work offline. With this, I could add a product in the first Collection “X”, because this record is type Entity “Z”, right?

My problem is, when I use ShowColumns() to have less memory cache, the record of this collection lost the type Entity “Z”.


@Pinguito wrote:

 

My problem is, when I use ShowColumns() to have less memory cache, the record of this collection lost the type Entity “Z”.


I think you see the issue - ShowColumns modifies the structure of the records within the collection, so a record from collection X is no longer the same thing as a record from collection Y or Z.

 

To get around this issue, consider using a lookup value. It is a unique identifier column that you keep with your collection, which gives you the ability to find specific values in the table later. Consider this example of two collections, Products and OrderItems, with a column called SKU that is common to both of them:

 

Products

SKU

ItemName

Description

UnitPrice

 

OrderItems

SKU

Quantity

CustomerName

 

There is no need to store the details of the products in the OrderItems collection because we can use the common SKU column to look up the details of the products from the Products collection. This reduces data volume and helps organize our work. It is also much easier to compare a single value from a column to another single value from a different column.

 

Does that make sense?

 

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Users online (2,406)