cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jezter12
Advocate I
Advocate I

Add a drop down list to a document library

Hi,

 

I have a flow that will create a document library, using Rest API,. whenever an item is added to a sharepoint list, update the sharepoint list with the URL and email the creator the link to that library. Another flow then picks up the any documentation attached to that list and deposits it in the document Library.

 

What i would like to be able to do is to create a drop down column in that document library during the creation flow. This is so we can start to set up standard categorisation, and get people out of the habit of using folders.

 

I have tried various combinations of the below. But no joy. 

 

Jezter12_0-1642077237152.png

The error I get,

Jezter12_1-1642077499984.png

and when i put the full url into edge it says that the xml has not style information associated with it.

 

Jezter12_2-1642077650375.png

Could it be that i need to do something different when i create the document library?

Jezter12_3-1642077806610.png

Any help would be much appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @Jezter12,

 

You can use the CreateFieldAsXml method for this.

 

Below is an example.

 

_api/web/lists/getbytitle('Initiative')/Fields/CreateFieldAsXml

 

{"parameters":{"__metadata":{"type":"SP.XmlSchemaFieldCreationInformation"},"SchemaXml":"<Field CustomFormatter='' DisplayName='Category' FillInChoice='FALSE' Format='Dropdown' IsModern='TRUE' Name='Category' Required='TRUE' Title='Category' Type='Choice'><CHOICES><CHOICE>Pipeline</CHOICE><CHOICE>Project</CHOICE><CHOICE>BAU</CHOICE></CHOICES></Field>","Options":12}}

 

createfieldasxml_02.png

View solution in original post

6 REPLIES 6
Expiscornovus
Super User
Super User

Hi @Jezter12,

 

You can use the CreateFieldAsXml method for this.

 

Below is an example.

 

_api/web/lists/getbytitle('Initiative')/Fields/CreateFieldAsXml

 

{"parameters":{"__metadata":{"type":"SP.XmlSchemaFieldCreationInformation"},"SchemaXml":"<Field CustomFormatter='' DisplayName='Category' FillInChoice='FALSE' Format='Dropdown' IsModern='TRUE' Name='Category' Required='TRUE' Title='Category' Type='Choice'><CHOICES><CHOICE>Pipeline</CHOICE><CHOICE>Project</CHOICE><CHOICE>BAU</CHOICE></CHOICES></Field>","Options":12}}

 

createfieldasxml_02.png

Unfortunately that is also failing with the following error

{
  "status"400,
  "message""The expression \"web/lists/getbytitle(Tentth)/Fields/CreateFieldAsXml\" is not valid.\r\nclientRequestId: 37c56efc-cc66-47e1-b0b8-b293d440945c\r\nserviceRequestId: 655d16a0-7060-3000-698f-38a61ec6215b",
  "errors": [
    "-1",
    "Microsoft.SharePoint.Client.InvalidClientQueryException"
  ]
}

 

 

 

Expiscornovus
Super User
Super User

Hi @Jezter12,

 

Can you make sure you have single quotes around Tentth. It should be getbytitle('Tentth') instead of getbytitle(Tentth) in the URI field.

Still not working, it says the document library doesnt exist, does the fact that i am trying to perform this step in the same flow as the one the document library is created in, just a later step, present an issue?

 

Expiscornovus
Super User
Super User

Hi @Jezter12,


No, I think it shouldn't be an issue. As long as you use the same title for the library in both HTTP requests.

 

createlib_createchoicefield.png

 

createlib_createchoicefield_result.png

 

 

Resolved, your code worked perfectly. The problem was my end the document library creation step had an erroneous space after the dynamic content and before the quotation marks.

Jezter12_0-1642088712162.png

 

Thank you for your help. It was that last post of yours that helped me find it.

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (3,137)