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

Use patch to create a custom Document Type in a Document Library from a Canvas App

Hi,

I'm having trouble trying to create a custom document type inside a library from a Canvas App (in this case, the custom doc. type is a Document Set).

I'm trying with patch like:

 

Patch('libraryName', {
    'Content type': {
        Id: "0x0120D52000122E02AFA3FA904F8B1226EDDC75829D09008A45DAB2BE418549A69FAE20AE822442",
        Name: "doc. type name"
    },
    //rest of metadata
})

 

However, I get an obscure error telling me: "invalid argument type. expecting Record, but of a different schema"

Which schema? I can't see any documentation related to this. The closest I've come is to this article:

https://docs.microsoft.com/en-us/sharepoint/dev/schema/contenttype-element-contenttype

 

Any ideas?

5 REPLIES 5
Highlighted
Community Support
Community Support

Hi @abiarge ,

 

The Content type should be around with curly braces {}.

Please try this:

Collect('libraryName', {
    '{Content type}': {
        Id: "0x0120D52000122E02AFA3FA904F8B1226EDDC75829D09008A45DAB2BE418549A69FAE20AE822442",
        Name: "doc. type name"
    },
    //rest of metadata
})

Hope this helps,

Sik

Highlighted

Hi, @v-siky-msft ,

 

Thanks for your answer, but I already tried that syntax and get the following error:

"The specified column '{Content type}' does not exist"

 

It's quite odd that 'Content type' is suggested by the Canvas editor, but doesn't accept the "id" and "name" parameters as a child object...

Highlighted

Hi @abiarge ,

 

I made a test, and it worked properly with the following code:

Collect('SP list',{'{ContentType}':{
Id:"...",
Name:"..."},
Title:DataCardValue1.Text});

It seems to must be {ContentType}, rather than {Content type}.

Sik

 

Highlighted

Hi, @v-siky-msft ,

 

If tried exactly what you just suggested  and I get no error, but the document set is not created in the document library either:

 

 
Collect('Expedientes Abiertos IT', {
  '{ContentType}': {
      '{id}': "0x0120D52000122E02AFA3FA904F8B1226EDDC75829D09008A45DAB2BE418549A69FAE20AE822442",
      '{Name}': "8 - Expedientes IT"
  },
  Title: "prueba canvas"
});

 

Also, why "collect" instead of "patch"?

PS: could it be that it doesn't work with document sets? I can't see what's wrong

Highlighted

Hi, @v-siky-msft ,

 

I've managed to create a Document Set from a Canvas PowerApp, but not using Patch or Collect at all, as I've come across multiple errors related to the sharepoint api that makes me thing that it's actually not possible right now. Although I find this completely necessary to automate things on SharePoint Online.

 

1- Use Power Automate "copy folder" to copy an empty document set into the desired location

2- change the name of the copied document set and the contentType if necessary via the "http request to sharepoint" action from power automate (these attributes cannot be changed via powerapps' Patch nor Collect/Update....

3- Change the rest of attributes that can be modified from powerapps using Patch/Update

 

I find it quite obscure being forced to do this. I'd normally do a https request to an Azure Function to achieve this, but in my scenario, I need all the users to be able to execute these kind of canvas applications with Microsoft 365 Business Basic accounts (4.20€) only.

 

PS: If anybody needs implementation instructions, just let me know and I'll post what I've done.

 

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (12,950)