Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Script to see if text contains a value

I have a google form that when the user submits it will trigger my function to run which is creating a summary of what they submitted as a Google Doc. I know it can automatically send an email but I need it formatted in a way that my user can edit it later.

There are some check boxes on the form -- but the getResponse() is only populated with the items checked and I need it to show all possible choices. Then I will indicate somehow what was checked.

I can't find a way to see if a text contains a value. Like in Java with a String, I could do either .contains("9th") or .indexOf("9th") >=0 and then I would know that the String contains 9th. How can I do this with google scripts? Looked all through documentation and I feel like it must be the easiest thing ever.

var grade = itemResponse.getResponse(); 

Need to see if grade contains 9th.

like image 993
Sharon Avatar asked Dec 11 '13 18:12

Sharon


People also ask

What is === in Google script?

Strict equality (===): a === b results in true if the value a is equal to value b and their types are also the same.

How do I check if a cell is empty in Google script?

ISBLANK returns TRUE if value is empty or a reference to an empty cell, and FALSE if it contains data or a reference to data.


1 Answers

Google Apps Script is javascript, you can use all the string methods...

var grade = itemResponse.getResponse(); if(grade.indexOf("9th")>-1){do something } 

You can find doc on many sites, this one for example.

like image 129
Serge insas Avatar answered Sep 23 '22 01:09

Serge insas