web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Create record with patch
Power Apps
Unanswered

Create record with patch

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi

I´m really suck and hope you guys can help me. I have a sharepoint list called "Elevlogg" which logs info about students. 

It has a tile and a description fiel which are both plain text, a date field and four dropdowns. Three of them gets data form the "Elevlogg" list as choices. Skoleår (School year), Klasse and Kategori. Choices([@Elevlogg].Skoleår), Choices([@Elevlogg].Klasse) and Choices([@Elevlogg].Kategori). The fourth dropdown gets its values from another list lokkup Aktive elever), wihch has Klasse (class) and Elev (student) as columns. It is populated by Filter('lookup Aktive elever'; Elev = ddKlasse.Selected.Value).Elev

So far so good. But when i try to patch this form to an new record, i run into problems. 

ive tried something like:

Patch(Elevlogg; ThisItem;{Title: CinputTitle.Text; Skole_x00e5_r: CddAar.Selected; Klasse: CddKlasse.Selected; Elev: CddElev.Selected; Kategori: CddKategori.Selected; Dato_x0020_for_x0020_hendelse: CcalDato.SelectedDate; Beskrivelse: ClblBeskrivelse.Text}))

(Cdd.... are the names of the various dropdowns) 

Also tried something to patch the Elev-field likae:

Elev: {

 '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";

  ID: LookUp('Aktive elever og foresatte'; DisplayName= CddElev.Selected.'Compliance Asset Id'; ID);

  Value: CddElev.Selected

}

But as you might see nothing wrks, i am in way over my head and any help to point me in the right direction will be appreciated. 

Categories:
  • WarrenBelz Profile Picture
    156,532 Most Valuable Professional on at

    Hi @Anonymous 
    New records need the Defaults() syntax as below.

    Patch(
     Elevlogg; 
     Defaults(Elevlogg);
     {
     Title: CinputTitle.Text; 
     Skole_x00e5_r: CddAar.Selected; 
     Klasse: CddKlasse.Selected; 
     Elev: 
     {
     '@odata.type':
     "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";
     ID: 
     LookUp(
     'Aktive elever og foresatte'; 
     DisplayName= CddElev.Selected.'Compliance Asset Id'; 
     ID 
     );
     Value: CddElev.Selected
     }
     Kategori: CddKategori.Selected; 
     Dato_x0020_for_x0020_hendelse: CcalDato.SelectedDate; 
     Beskrivelse: ClblBeskrivelse.Text
     }
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • timl Profile Picture
    37,287 Super User 2026 Season 2 on at

    Hi @Anonymous 

    I think you're on the right track here. For the lookup field, I would try something like this.

    Elev: {
     '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";
     ID: CddElev.Selected.ID;
     Value: ""
    }

    This should enable you to more directly reference the required ID field. The Value field doesn't matter and you can leave it empty. The patch function will work out the correct value from the ID value that we pass.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for replying.

    Didn´t quite work yet:

    Skjermbilde 2020-02-28 kl. 13.08.02.png

    5 errors

     

    This is the list columns:

    Skjermbilde 2020-02-28 kl. 13.15.49.png

  • WarrenBelz Profile Picture
    156,532 Most Valuable Professional on at

    Hi @Anonymous ,

    I only added the defaults to your code - also using @timl suggestion on the ID - Note I have added .Value as the fields you have shown are Choice fields

    Patch(
     Elevlogg; 
     Defaults(Elevlogg);
     {
     Title: CinputTitle.Text; 
     Skole_x00e5_r: CddAar.Selected.Value; 
     Klasse: CddKlasse.Selected.Value; 
     Elev: 
     {
     '@odata.type':
     "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";
     ID: "" ;
     Value: CddElev.Selected.Value
     }
     Kategori: CddKategori.Selected.Value; 
     Dato_x0020_for_x0020_hendelse: CcalDato.SelectedDate; 
     Beskrivelse: ClblBeskrivelse.Text
     }
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks again. Still not working. Seem the only option to select at Value: CddElev.Selected is Elev. No option to select CddElev.Selected.Value 

  • timl Profile Picture
    37,287 Super User 2026 Season 2 on at

    Hi @Anonymous 

    Just to confirm, it's the ID value that's important here. We can set value to an empty string.

    This should hopefully take you one step further. This snippet will return the ID of the Elev field that's associated with the 'lookup Aktive elever' record that's selected in CddElev.

     

     {
    '@odata.type':
    "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";
    ID: CddElev.Selected.Elev.ID ;
    Value: ""
    }

     This should hopefully resolve 1 of the 5 errors. If you could send us the details of other 4 errors, I'm sure between us we can work out the cause.

     

  • WarrenBelz Profile Picture
    156,532 Most Valuable Professional on at

    Sorry, @Anonymous mis-type on my part on the ID. I was focussing on the .Value bits. Something also new for me (thanks @timl) I have always used both items, generally in the Update of cards.
    You need to put CddElev.Elev. 
    I only used .Value as the fields you showed in your screenshot were Choice  - yours is obviously formed from a list. 

    On that subject, all the .Selected entries need a condition at the end. This can be .Value. a field name as in yours or .Result from a Distinct query.
    As you have found, you can easily find this item.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for all help so far. Sorry for delay, I have been out of business for some days. This is the code now, still with errors:

    Patch(Elevlogg,Defaults(Elevlogg),{Title:CinputTitle.Text,Skole_x00e5_r:CddAar.Selected.Value,Klasse:CddKlasse.Selected.Value,Elev:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", ID:CddElev.Selected.Elev ,Value:""},Kategori:CddKategori.Selected.Value,Dato_x0020_for_x0020_hendelse:CcalDato.SelectedDate, Beskrivelse:ClblBeskrivelse.Text})

     

    Errors 

    The function patch has some invalid arguments

    Invalid argument type, expecting a Record value, but of a different schema

    Incompatible type. The Id column in the data source you´re updating expects a 'Number' type and you´re using a 'Text' type

     

    So i'm still stuck, and still does not know where to start looking. 

     

  • timl Profile Picture
    37,287 Super User 2026 Season 2 on at

    Hi @Anonymous 

    In the code, you're missing the ID property on Elev. This should take you one step closer...

     

    Patch(Elevlogg,Defaults(Elevlogg),{Title:CinputTitle.Text,Skole_x00e5_r:CddAar.Selected.Value,Klasse:CddKlasse.Selected.Value,Elev:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", ID:CddElev.Selected.Elev.ID ,Value:""},Kategori:CddKategori.Selected.Value,Dato_x0020_for_x0020_hendelse:CcalDato.SelectedDate, Beskrivelse:ClblBeskrivelse.Text})

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Sorry, in CddElev.Selected.Elev.ID, the ID-property does not show up as an alternative and if I put it on it only introduces another error: Invalid use of '.'

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard