3

I'm trying to set a data validation for one cell A1 using a "List from a range" to B1:B5

From this page, https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#booleancondition

It seems to be ONE_OF_RANGE, but can't get the code to work. Not sure where to put the specified range for list B1:B5

There is no example of ONE_OF_RANGE and how to use it.

{
  "requests": [
    {
      "setDataValidation": {
        "range": {
          "sheetId": sheetId,
          "startRowIndex": 0,
          "endRowIndex": 0,
          "startColumnIndex": 0,
          "endColumnIndex": 0
        },
        "rule": {
          "condition": {
            "type": "ONE_OF_RANGE",
            "values": [
              {

              }
            ]
          },
          ,
          "strict": true
        }
      }
    }
  ]
}

I have tried:

"type": "ONE_OF_RANGE",

          "values": [{
             "userEnteredValue": "=Sheet1!B1:B5"}

I don't get an error when running it, but nothing happens.

1 Answer 1

8

Got it to work.

data={
  "requests": [
    {
      "setDataValidation": {
        "range": {
          "sheetId": sheetId,
          "startRowIndex": 0,
          "endRowIndex": 1,
          "startColumnIndex": 0,
          "endColumnIndex": 1
        },
        "rule": {
          "condition": {
            "type": "ONE_OF_RANGE",

          "values": [{
             "userEnteredValue": "=Sheet5!B1:B5"}
         ]
          },

          "strict": 'true'
        }
      }
    }
  ]
}
Sign up to request clarification or add additional context in comments.

1 Comment

I have table name like "Table Name" (with white space and It cause 500 error. Solution was add doublequotes "userEnteredValue" => "='Table Name'!CK3:CK990"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.