cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Feibien
Level: Power Up

create new choice column to sharepoint library using flow

Hi,
 
As stated in subject I'm trying to create a choice field in a library but also need to add this column to default view. So far I managed to create the field but I cant display this column in the default view. The purpose of this flow is help the users to replicate a column to multiple sites using a list in which the user will type the url and the name of the library that requires the new column.
 
This is the code to create a choice column I'm using in the action "sent http request to sharepoint" in flow
 

 

{ '__metadata':
{ 'type': 'SP.FieldChoice', 'addToDefaultView': 'true' },
'Title': 'NewColumn',
'FieldTypeKind': 6,
'Required': 'false',
'Choices': { 'results': ['A', 'B', 'C' ] }
}

 

 
I tried to add the column usingt the addtodefaultview part following some documents of microsoft, but doesn't work. The link used is https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-json-schema
 
Thanks beforehand for any help
3 REPLIES 3
Community Support Team
Community Support Team

Re: create new choice column to sharepoint library using flow

Hi @Feibien 

 

The JSON for addSiteColumn should as below:

 {
    "verb": "addSiteColumn",
    "internalName": "siteColumnUser",
    "addToDefaultView": true
 }

 

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Feibien
Level: Power Up

Re: create new choice column to sharepoint library using flow

Thanks for your reply.

 

I tried to add that code in my flow, but it gaves me this error 

"Microsoft.SharePoint.Client.InvalidClientQueryException".
 
Searching other Microsoft documents, found this one https://docs.microsoft.com/en-us/sharepoint/dev/schema/field-element-field
According to that article, there's a property called "viewable", but when I use it in my code, Microsoft flow throws an error saying that the property doesn't exists...
 
Screenshot_2.png

 

I really don't know what I'm doing wrong...
 
Feibien
Level: Power Up

Re: create new choice column to sharepoint library using flow

I gave out on Flow and solved the problem using on Powershell the command add-pnpfield https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/add-pnpfield?view=sharepoint-ps

 

 

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Speakers, submit your sessions now! Call for speakers ends Feb. 10!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,284)