question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Data Validation with type 'list', the formulae can't be dynamic

See original GitHub issue

How can be the formulae of data validation for the type ‘list’ dynamic? Here is my code snippet: sheet.dataValidations.add('M2:M4999', { type: 'list', allowBlank: false, formulae: [ arrayToTargetFormulae(array) ], showErrorMessage: true, errorStyle: 'error', error: 'The value Valid', }); The function arrayToTargetFormulae takes an array and covert it. Here is the code for the function arrayToTargetFormulae: function arrayToTargetFormulae(arr) { let str = '\'"'; str += arr.join(', '); str += '"\''; console.log(str); return str; }

The array values after convert will be one string like ‘“Male,Female”’

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:22

github_iconTop GitHub Comments

6reactions
linghao518commented, Mar 9, 2021

I have the same issue. Did you manage to resolve it?

Yes, I solved it by adding the dynamic content to another sheet (on one column) and set the state of that sheet to “very hidden” so no one can edit or change that hidden sheet or its content. Then, i added the “dataValidations” for the column as follows: sheetStudents.dataValidations.add('L2:L9999', { type: 'list', allowBlank: false, formulae: ['=Levels!$A$2:$A$9999'], showErrorMessage: true, errorStyle: 'error', error: 'Please select a valid value from the list', });

Note:

  • Levels in this part formulae: ['=Levels!$A$2:$A$9999'] is the hidden sheet name which contains the dynamic data. Also, A is the column name in that sheet.

this solution solve my requirement

6reactions
ahmedfarag1993commented, Jul 11, 2020

I have the same issue. Did you manage to resolve it?

Yes, I solved it by adding the dynamic content to another sheet (on one column) and set the state of that sheet to “very hidden” so no one can edit or change that hidden sheet or its content. Then, i added the “dataValidations” for the column as follows: sheetStudents.dataValidations.add('L2:L9999', { type: 'list', allowBlank: false, formulae: ['=Levels!$A$2:$A$9999'], showErrorMessage: true, errorStyle: 'error', error: 'Please select a valid value from the list', });

Note:

  • Levels in this part formulae: ['=Levels!$A$2:$A$9999'] is the hidden sheet name which contains the dynamic data. Also, A is the column name in that sheet.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Easy Steps Excel Dependent Drop Down List Data Validation
Use Dynamic Lists​​ Because the INDIRECT function only works with references, not formulas, the previous method for dependent data validation ...
Read more >
Dynamic Dropdown lists in Excel - Top Data Validation Guide
Go to the worksheet and click in the cell where you want the dynamic dropdown lists to appear. On the Data tab, in...
Read more >
How to create dynamic data validation and extend the drop ...
1. Click Formulas > Define Name, see screenshot: · 2. In the New Name dialog box, specify a name as Namelist you need,...
Read more >
How to Create a Dynamic Drop-down List that Automatically ...
The source of this dynamic data validation list has been created using the UNIQUE function. UNIQUE is a Dynamic Array Formula that returns ......
Read more >
Create a dynamic dependent drop down list in Excel an easy ...
To create the second dropdown list, configure the data validation criteria ... Or you can include a few blank cells in your formulas...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found