cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lauracook6
Frequent Visitor

Submit record to SharePoint list with ContentType

I have a problem which i thought was going to be simple to fix at first but after a couple of attempts to gain the desired result I am still stumped. I am just trying to submit an item to a sharepoint list with a variable definition of the content type. 

Currently I have a global variable which stores the content type dependant on a user selection on the previous page and it is stored like so. 

Set(contenttype,{Id:"0x01000....", Name:"A"})

I have then tried to collect some information from a form to send it to the list. 

Collect(Audit, 
{
    '{ContentType}': contenttype,
    System: DataCardValue27.Selected,
    Date: Today(),
    Title: DataCardValue18.Text,
    Auditors: DataCardValue23.SelectedItems,
    Attendees: DataCardValue24.SelectedItems
});

I have also tried to set the content type as if it was a lookup column but this still didnt work.

Collect (Audit,
{
'{ContentType}':{'@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:contenttype.Id, Name:contenttype.Name}
....
})

(It works fine with the default content type if i delete the content type line) 

I have also tried to set a default property of the content type data card to the variable but this returns an error "A value must be provided for item".

Is this possible or should I post this request to the powerapps ideas?

 

Edit: I have been playing about with a control that I have linked to the '{ContentType}' column and i have locally collected what the selected control submits and the value I have been trying to patch to the list and they are both identical. I have also tried setting the default of this control (as you would for a lookup column) but it will be ignored so i am going to assume that this is a limitation.

2 REPLIES 2
Sienna
Memorable Member
Memorable Member

Have you thought about simply not to use datacards whatsoever. Patching a database with variables is a common thing without datacards forms and other useless things in powerapps.

I have tried to add the controls without datacards but the same thing happens, it will work without the ContentType declaration so:  

 

Patch([list], {ID:Blank(), Title:"textinput1.text"})

 would work with the default content type of the list however

Patch([list], {ID:Blank(), '{ContentType}':variable, Title:"textinput1.text"})

would not work and it would return the error "value required for item". 

 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (37,875)