cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cooper01
Continued Contributor
Continued Contributor

Possible to get new records only when patching a collection?

When I create new records in a Dataverse table using Collect (based on a collection to avoid patching each), it returns all records in the table. Is there any way to store only the ones I just created? Ultimately I am trying to get the GUIDs of the records I just created.

4 REPLIES 4
v-xiaochen-msft
Community Support
Community Support

Hi @Cooper01 ,

 

You could use clear() function.

After you use collect() for the first time, you could use the clear function to clear your collection.

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

Thanks for the reply @v-xiaochen-msft . This is what my Patch statement looks like. Can you please explain where I would add the Clear? If I surround the Collect below with a ClearCollect to a new collection, I do get the entire dataset from Employees and not just my two new records

 

 

ClearCollect(
    colItemsToPatch,
    {
        cr40c_Name: "Sample item 1",
        cr40c_Company: locSelectedCompanyRow //my datasource Employees has a lookup column which points to Company table
    },
    {
        cr40c_Name: "Sample item 2",
        cr40c_Company: locSelectedCompanyRow
    }
);

Collect(
    Employees,
    DropColumns(
        AddColumns(
            colItemsToPatch,
            "companyRow",
            ShowColumns(
                Employees,
                "cr40c_Company"
            ),
            "cr40c_JobTitle",
            "Sample Title"
        ),
        "companyRow"
    )
)

 

  

v-xiaochen-msft
Community Support
Community Support

Hi @Cooper01 ,

 

The Clear() function could clear all records in the collection.

So you could first use the clear() function to clear all records in the collection.

Then add new records to the collection.

Finally, use the collect() function to add new records to your data source.

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

@v-xiaochen-msft My goal is to get the Dataverse GUIDs of the records I collected to my data source. I am having no issues with clearing the collection that is going to the data source. In your last line, use Collect() function to add new records, the results of that are all the records in the data source. Is it possible to get only the records just created?

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.

Users online (2,968)