node-google-spreadsheet icon indicating copy to clipboard operation
node-google-spreadsheet copied to clipboard

setDataValidation data validation

Open josephchan91 opened this issue 2 years ago • 2 comments

Hi, can I use this package to set data validation rules for a range of cells? I've tried sheet._makeSingleUpdateRequest and sheet.setDataValidation without success. Thanks!

values =[
{userEnteredValue: 'Emeli Studs (18K Gold Vermeil)=>6552666341465'},
{userEnteredValue: 'Shilo Teeny-Tiny Hoops (24K Gold Vermeil)=>6578911641689'},
{userEnteredValue: 'Hira CZ Earrings (18K Gold Vermeil)=>6913437761625'}
];
 const response = await sheet.setDataValidation({
            range: {
              sheetId: sheet.sheetId,
              startRowIndex: row.rowNumber - 1,
              endRowIndex: row.rowNumber,
              startColumnIndex: ALL_PRODUCTS_COLUMN_INDEX,
              endColumnIndex: ALL_PRODUCTS_COLUMN_INDEX+1,
            },
            rule: {
              condition: {
                type: "ONE_OF_LIST",
                values,
              },
              inputMessage: "Product must match customer's order history",
              strict: true,
            },
          });

josephchan91 avatar Jun 09 '22 10:06 josephchan91

it is not implemented but should be relatively straightforward to add. Open to PRs!

theoephraim avatar Jun 17 '22 16:06 theoephraim