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 / Use patch to create a ...
Power Apps
Unanswered

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

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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?

Categories:
I have the same question (0)
  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    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

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

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

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    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

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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.

     

     

  • guillem95 Profile Picture
    on at

    I tried something similar. I've used "Patch" to create the document set as you described:

     

    Patch(
     Documentos;
     {
     '{ContentType}': {
     Id: "0x0120D5200092EDA8E2EAF2634CA7246F2A56CF1A2B";
     Name: "Carpeta V2"
     };
     Nombre: "Test Name"
     }
    )

     

     

    There is no schema error, but the server returns the following error: "The column 'Nombre' must be generated by the server and cannot be specified".

     

    So it looks there is no way to create it through Power Apps...

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard