Showing results for 
Search instead for 
Did you mean: 
Impactful Individual
Impactful Individual

Problem with Patch and createdby


Please be so kind as to read my full post before responding.
Thank you for your consideration.

I am trying to make the PowerApp for CDS that I am working on capable of being used offline.
Hence, I usually collect local copies from my Data Sources, add some custom PowerApps columns for things like thumbnails or temporary results.
Before syncinc back to CDS using Patch (inside ForAll or AddColumns (to get proper GUIDs back)) I would drop the additional custom offline columns.

I just started getting a weird nondescript error with my Sync Button containing Patch/ForAll.
PowerApps 3.19061.14, DataBase Version
Upon a Sync attempt I got the nondescript "Value mus be a data entity record error".
I did some tests and first found that just using patch with something simple like

ClearCollect(TmpPatched, AddColumns(LocalToSubmit, "real_id", Patch([@'PowerFair-Leads'],
        kk_messeapp_leadid: If(submitted, kk_messeapp_leadid, Blank())
        kk_notes: "Test"

worked, but didn't with "full entities" from forms or galleries etc.
With some systematic trial and error using ShowColumns/DropColumns going through all the fields in my entity, I could narrow down my problem to the "createdby" column.
Dropping this column (in addition to my custom offline non-CDS columns) seems to alleviate this problem.
So my current code looks like this:
Did something change with "createdby"?
It's easily possible I missed an annoucement or something, maybe related to new CDS features etc.
Or is this just some kind of "freak accident"?

Thank you,
    Sa Wu.

Community Support
Community Support

Hi @SaWu ,

I've made a smilar test but not met the same problem like your description.

As far as I know, created by is a read-only look-up field in CDS.

It's automatically genereted by system.

You could only display it in PowerApps.

It's not supported to update the field inside the app.

So, maybe your issue is a "freak accident".

Could you show me more settings about created by field?


Best regards,

Community Support Team _ Phoebe Liu

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.
Impactful Individual
Impactful Individual

Hello @v-yutliu-msft 


Thank you for your response.
My error only shows up when updating (actually patching) an exisiting element, not with new record submissions.
My guess is that CDS/Dynamics doesn't like me patching with full records from local collections because of my offline considerations instead of using SubmitForm/Form.Updates, which, as far as I understand, don't modify columns like createdby or modifiedon.

As for my actual "code"/formulas, please find the signifcant/abridged parts of it here:


ClearCollect(LocalLeads, Filter('PowerFair-Leads', createdby.systemuserid=userId, statuscode=leadStatusActive));
ClearCollect(LocalExhibitionLeads, AddColumns(LocalLeads,
    "new_front", false,
    "new_extra", false,
    "submitted", true,
    "new_thumbnails", []
If(!isBrowser, SaveData(LocalExhibitionLeads, "LocalExhibitionLeads"))


    RemoveIf(LocalExhibitionLeads, kk_messeapp_leadid = oldId)
RemoveIf(LocalToSubmit, kk_messeapp_leadid = oldId);
ClearCollect(NewTmp, selectedItem);
UpdateContext({newItem: Patch(
        kk_messeapp_leadid: GUID(),
        submitted: false
    }, {}),
        kk_address1_city: Left(InputFieldsEditAddress1City.Text, fieldLimit),
        kk_address1_country: Left(InputFieldsEditAddress1Country.Text, fieldLimit),
        kk_address1_line1: Left(InputFieldsEditAddress1Line1.Text, fieldLimit),
        kk_address1_postalcode: Left(InputFieldsEditAddress1PostalCode.Text, fieldLimit),
        kk_address1_stateorprovince: Left(InputFieldsEditAddress1StateOrProvince.Text, fieldLimit),
        kk_name1_firstname: Left(InputFieldsEditName1FirstName.Text, fieldLimit),
        kk_name1_lastname: Left(InputFieldsEditName1LastName.Text, fieldLimit)
    selectedItem: newItem,
    newLead: false
Collect(LocalExhibitionLeads, selectedItem);
Collect(LocalToSubmit, selectedItem);
    SaveData(LocalExhibitionLeads, "LocalExhibitionLeads");
    SaveData(LocalToSubmit, "LocalToSubmit")


ClearCollect(TmpSubmit, DropColumns(LocalToSubmit, "new_front", "new_extra", "submitted", "new_thumbnails", "createdby", "modifiedon"));
ClearCollect(TmpPatched, AddColumns(LocalToSubmit, "real_id", Patch([@'PowerFair-Leads'],
        kk_messeapp_leadid: If(submitted, kk_messeapp_leadid, Blank())
        LookUp(TmpSubmit, TmpSubmit[@kk_messeapp_leadid] = LocalToSubmit[@kk_messeapp_leadid]),
            kk_messeapp_leadid: If(submitted, kk_messeapp_leadid, Blank())
ForAll(TmpPatched, Patch(LocalExhibitionLeads, 
        kk_messeapp_leadid: kk_messeapp_leadid
        kk_messeapp_leadid: real_id,
        submitted: true
    If(!isBrowser, SaveData(LocalToSubmit, "LocalToSubmit")),
    If(!isBrowser, SaveData(LocalExhibitionLeads, "LocalExhibitionLeads"))

Thank you,
    Sa Wu.

Helpful resources

PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

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.

Top Solution Authors
Top Kudoed Authors
Users online (1,083)