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

Create SharePoint List *Choice* Column on a Schedule

Hello, 

 

I am building a flow the intention of which is to create a Choice column in a SharePoint list on the 1st of each month. The Column should be called YYYYMM relative to the current data, and the default choice should be Not Started. The other choices will be Waiting On OpsWaiting On Analyst, and Submitted.

I am struggling with the final step - Send an HTTPS Request to SharePoint. I can't see how to list the default choices for the column, and I am getting an error message I can't understand.

Flow as-is:

TomTomTom_0-1645538333745.png

Error:

 

TomTomTom_1-1645538397148.png


Any guidance?

I am new to this level of work (JSON, HTTPS, etc) but eager to learn and apply in many contexts - help much appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @TomTomTom,

 

I think you are missing a couple of things. First of all you are using the verbose headers. So, that would require you to specify metadata in the body of the request.

 

Secondly, I would add a couple of additional properties to your choice field. I have added properties like StaticName and Choices.

 

Below is an example of a new request which should work. Can you try that instead?

 

 

 

{
  "__metadata": {
    "type": "SP.FieldChoice"
  },
  "FieldTypeKind": 6,
  "Title": "@{variables('YYYYMM.Str')}",
  "Required": "false",
  "EnforceUniqueValues": "false",
  "StaticName": "@{variables('YYYYMM.Str')}",
  "Choices": { 'results': ['Not Started', 'Waiting On Ops', 'Waiting On Analyst', 'Submitted.'] },
  "DefaultValue": "Not Started"
}

 

 

 

 

createchoicefield.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


View solution in original post

7 REPLIES 7
Expiscornovus
Super User
Super User

Hi @TomTomTom,

 

I think you are missing a couple of things. First of all you are using the verbose headers. So, that would require you to specify metadata in the body of the request.

 

Secondly, I would add a couple of additional properties to your choice field. I have added properties like StaticName and Choices.

 

Below is an example of a new request which should work. Can you try that instead?

 

 

 

{
  "__metadata": {
    "type": "SP.FieldChoice"
  },
  "FieldTypeKind": 6,
  "Title": "@{variables('YYYYMM.Str')}",
  "Required": "false",
  "EnforceUniqueValues": "false",
  "StaticName": "@{variables('YYYYMM.Str')}",
  "Choices": { 'results': ['Not Started', 'Waiting On Ops', 'Waiting On Analyst', 'Submitted.'] },
  "DefaultValue": "Not Started"
}

 

 

 

 

createchoicefield.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


That's excellent! Thank you.

 

I think I must have misunderstood the meaning of DefaultValue though as the values are blank in each item. I was expecting them to use DefaultValue instead.

 

I am wondering if I can't do that in this step, and need to Get Items / Update Items instead for this final step.

Expiscornovus
Super User
Super User

Hi @TomTomTom,

 

DefaultValue means that whenever you create a new item a choice is already selected in that field for the user. Which makes the data entry experience a bit user friendlier.

 

However, the user can still select a different choice when creating the item. This column setting only affects new items, existing items won't be updated.

 

If you want to update the data of existing items you might want to have a look at the different REST API Method. Do you need an example for that?



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


An example would be great, if you have one!

Expiscornovus
Super User
Super User

Hi @TomTomTom,

 

Yes, no problem.

 

Below is an example how you can update the selected value of a choice field of an existing list item with the validateUpdateListItem method, in this case item with ID 1.

 

Normally you could do these kind of updates also with a Update Item action. However, since you are storing the column name in a variable I thought a Send an HTTP action is a bit more flexible and useful in your setup 😁

 

updatesingleitem.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Ah this is so close!


I have combined it with Get Items to apply your work to both.

TomTomTom_0-1645552436326.png

 



But I get an error that the Column is not found ...

TomTomTom_1-1645552496633.png

(YYYYMM is wrong, but this is just because I have created a lot of test columns.)

I am wondering if the best solution is just two flows say six hours apart? The first flow provisions the column; it is ready (after the delay) to be filled.

But I would be curious to know if I am missing something in this flow ...

TomTomTom
Frequent Visitor

Hi Expiscornovus 

You've been so helpful - thanks.
 
Going to close this and accept the solution.

I think 2 flows with a bit of time between them is the way to go, with the same date-based logic creating the names in each case.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,897)