# Scripts, scripts, scripts!

**URL:** <https://community.glideapps.com/t/scripts-scripts-scripts/18965>\
**Category:** Ask for Help\
**Created:** [November 26, 2020, 6:15pm UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965 "2020-11-26T18:15:21Z")\
**Posts on this page:** 20\
**Page:** 7

<div class="post-metadata">

**Author:** ![Eric\_Penn](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/eric_penn/32/73888_2.png) [@Eric\_Penn](https://community.glideapps.com/u/Eric_Penn)\
**Post date:** [January 18, 2021, 10:35pm UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/122 "2021-01-18T22:35:17Z")

</div>

The following produces a date with timestamp

`var time = new Date();`

What could I use to create just a date i.e. 2020/1/18 (Without time stamp) ?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [January 18, 2021, 11:53pm UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/124 "2021-01-18T23:53:53Z")

</div>

> [@Eric\_Penn](#):
>
> What could I use to create just a date i.e. 2020/1/18 (Without time stamp) ?

Here you go…

```
function get_today() {
  var date = new Date();
  var str =
      date.getFullYear() + "/" +
      (date.getMonth() + 1) + "/" +
      date.getDate();
  return str;
}

```

Called as:

```
function moo() {
  console.log("Today is %s", get_today());
}

```

Produces:

```
7:48:48 AM Notice Execution started
7:48:46 AM Info Today is 2021/1/19
7:48:49 AM Notice Execution completed

```

PS. [Why you should always use yyyy-mm-dd for dates.](https://thetechnicalgeekery.com/2013/06/yyyy-mm-dd-the-best-way-to-write-dates/)

---

<div class="post-metadata">

**Author:** ![Eric\_Penn](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/eric_penn/32/73888_2.png) [@Eric\_Penn](https://community.glideapps.com/u/Eric_Penn)\
**Post date:** [January 19, 2021, 1:12am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/125 "2021-01-19T01:12:02Z")

</div>

Thank you @Darren_Murphy . You are a gentleman and a scholar.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [January 19, 2021, 1:26am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/126 "2021-01-19T01:26:10Z")

</div>

@ehdubya @Wiz.Wazeer - I found a bug in this script. I fixed it, see the edit in my original post.

> [@Darren\_Murphy](#):
>
> EDIT: There was a bug in the original version of this script that would cause it to convert empty rows to `1970-01-01` . I’ve modified it so that it won’t do that anymore. It could be made more robust, but it serves my purpose as it is.

---

<div class="post-metadata">

**Author:** ![Wiz.Wazeer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/wiz.wazeer/32/72423_2.png) [@Wiz.Wazeer](https://community.glideapps.com/u/Wiz.Wazeer)\
**Post date:** [January 19, 2021, 1:28am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/127 "2021-01-19T01:28:59Z")

</div>

Im going to be testing this on the glide countdown timer…I am sure this could help me unlock something (fingers crossed)!

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [January 19, 2021, 1:34am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/128 "2021-01-19T01:34:44Z")

</div>

Just out of curiosity, what is the problem that you’re hoping this might solve?

---

<div class="post-metadata">

**Author:** ![Eric\_Penn](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/eric_penn/32/73888_2.png) [@Eric\_Penn](https://community.glideapps.com/u/Eric_Penn)\
**Post date:** [January 19, 2021, 1:37am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/129 "2021-01-19T01:37:14Z")

</div>

Thank you! I’l give it a go now

---

<div class="post-metadata">

**Author:** ![Wiz.Wazeer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/wiz.wazeer/32/72423_2.png) [@Wiz.Wazeer](https://community.glideapps.com/u/Wiz.Wazeer)\
**Post date:** [January 19, 2021, 1:45am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/130 "2021-01-19T01:45:43Z")

</div>

Currently its a combination of numbers and texts. Yours generates numbers only. Glide instantly recognizes that and therefore I can play around with duration cell in the sheet. At present the moment you press pause it all disappears. With yours I want to see if I can keep it in the cell. Then I can truly play around with the countdown timer.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [January 19, 2021, 1:54am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/131 "2021-01-19T01:54:20Z")

</div>

Not sure I understand, but okay…  
Let me know if I can help in any way.

---

<div class="post-metadata">

**Author:** ![Wiz.Wazeer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/wiz.wazeer/32/72423_2.png) [@Wiz.Wazeer](https://community.glideapps.com/u/Wiz.Wazeer)\
**Post date:** [January 19, 2021, 1:56am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/132 "2021-01-19T01:56:34Z")

</div>

Its just me and my weird ways …But I know you will be able to assist…If you can’t then I have no hope lol

---

<div class="post-metadata">

**Author:** ![Drearystate](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drearystate/32/49605_2.png) [@Drearystate](https://community.glideapps.com/u/Drearystate)\
**Post date:** [January 25, 2021, 3:17pm UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/133 "2021-01-25T15:17:37Z")

</div>

@Wiz.Wazeer sorry man, I haven’t been on a ton this past week. What are you trying to do in scripts again?

---

<div class="post-metadata">

**Author:** ![Wiz.Wazeer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/wiz.wazeer/32/72423_2.png) [@Wiz.Wazeer](https://community.glideapps.com/u/Wiz.Wazeer)\
**Post date:** [January 25, 2021, 4:14pm UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/134 "2021-01-25T16:14:55Z")

</div>

Solved for now! I am working on something …I have managed to create a dynamic calendar using sheet formulas. when x types in 1-12, it will show the corresponding month and all slots for that particular month. I was looking for a script to send bulk emails to several contract workers (cleaning industry)…on selection. Found the script. But if I get stuck I will let you guys know.

Thanks and take it easy on yourself (saw you on CNN with a capitol C, i think–you know what I mean 🤣)

---

<div class="post-metadata">

**Author:** ![abe.sherman](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/abe.sherman/32/11260_2.png) [@abe.sherman](https://community.glideapps.com/u/abe.sherman)\
**Post date:** [February 23, 2021, 3:39am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/135 "2021-02-23T03:39:52Z")

</div>

> [@Drearystate](#):
>
> ```auto
> function onEmailEdit(e) {
> var spreadsheet = SpreadsheetApp.getActive();
> var sheet = SpreadsheetApp.getActiveSheet();
> var range = e.range;
> var cell = range.getA1Notation();
> Logger.log(cell);
> if (cell=='A1' && sheet.getName()=='Sheet1') {
> if (range.getValue()=='Y'||range.getValue()=='y') {
> emailNotifications(sheet);
> }
> }
> }
> 
> ```
> 
> Here is the second script
> 
> ```auto
> function emailNotifications(sheet) {
> Logger.log("Sending emails...");
> var send = sheet.getRange('A1').getValue();
> var subject = sheet.getRange('B1').getValue();
> var text = sheet.getRange('C1').getValue();
> var lastRowEN = sheet.getLastRow();
> var emails = sheet.getRange('D2:D'+lastRowEN).getValues();
> for (i=0; i<emails.length;i++) {
> var email = emails[i][0];
> if (email!="") {
> GmailApp.sendEmail(email, subject, text);
> Logger.log("Email sent");
> }
> }
> }
> 
> ```
> 
> In this script you can see that it first checks to see if A1 has a " Y " as its value. The reason for this is allow the user to simply toggle the ability to send emails or not. When this value is changed to anything else other than " Y " its telling the script to not automatically send emails. The " Y " can be any word or phrase or number I just chose " Y " to be short for the word yes.
> 
> The Subject is l

It would be cool if we can send a email based on event, Like reminder a day before then 1 Hour before. Or in the morning everyday at 9:00 If date is today. you get the point.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/d/8d5b8d3eae3ba5d159baa66af7efdeca11e12eb4.png)

Example can be, IF(Job Completed) = Never Remind me.  
else, If Start is (Today) Then Reminder & set col + 1 ( for first reminder) , then Repeat hour before, So on.  
we can even add to script. If End is past. (Was the job Done col) will be checked. If a user unchecked it will reset and resend email. Any thoutes about this?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [February 23, 2021, 4:01am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/136 "2021-02-23T04:01:04Z")

</div>

Yes, all possible and fairly straight forward.

- Scenario 1: Send an email on a regular schedule (once per day, per hour, etc)

- Scenario 2: Send an email as a result of an event - ie. when something significant changes

I use both scenarios. Horses for courses 🙂

---

<div class="post-metadata">

**Author:** ![abe.sherman](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/abe.sherman/32/11260_2.png) [@abe.sherman](https://community.glideapps.com/u/abe.sherman)\
**Post date:** [February 23, 2021, 5:50am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/137 "2021-02-23T05:50:50Z")

</div>

OK need help convert this to

1. Instead of HardCoded Col, Lets change it to read headers Instead.

2. Email Send email to 10 Col, (Allow to read 10 Col collect all emails and send it that way. )

3. Allow 1 header (Col) To trigger upon Edit (For Glide.)

4. Allow a header (col) If true Continue Script. For user to select if they want to be notified in advance.

5. Add If start TimeStamp ( Something like we discussed. Above, I will add hourly trigger. )

6. Col with time stamp, For some reasons also shows GMT-5 Easter Stander time text. Lets avoid that By stripping it?

@ThinhDinh @Darren_Murphy

@Darren_Murphy I would take your script that you have and try to work with it first and let you know if i can do it on my own.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [February 23, 2021, 6:20am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/138 "2021-02-23T06:20:25Z")

</div>

@abe.sherman this is a classic example of why I don’t use App Scripts to send emails. Having all those hard-coded references to specific columns is way too fragile and subject to breakage. It’s also going to be _really_ slow because of the multiple getRange() calls.

A much better approach (IMO, as I said in my earlier post) is to use a trigger to fire a webhook to Integromat, and then let Integromat do all the heavy lifting for you.

Is there are reason why you don’t want to use something like Integromat or Zapier?

---

<div class="post-metadata">

**Author:** ![abe.sherman](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/abe.sherman/32/11260_2.png) [@abe.sherman](https://community.glideapps.com/u/abe.sherman)\
**Post date:** [February 23, 2021, 6:25am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/139 "2021-02-23T06:25:47Z")

</div>

For this particular app i am not paying for yet besides the extra edits. For my other app. I can differently try using it in the future as i am paying for it. The webhook cost money and i dont have it for this app set up, Plus it wont give me everything i want to do with the webhook, Will it?

Even thou its planned in the very long run to pay for it. as of now. i dont have much clients using it besides a handfull. When the app is complete and i can intruduse it. then things will be different.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [February 23, 2021, 6:29am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/140 "2021-02-23T06:29:41Z")

</div>

Integromat give you 1000 operations per month for free.

I’ll have a closer look later when I have a bit more free time. In the meantime, can you provide a sheet with some sample data?

---

<div class="post-metadata">

**Author:** ![abe.sherman](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/abe.sherman/32/11260_2.png) [@abe.sherman](https://community.glideapps.com/u/abe.sherman)\
**Post date:** [February 23, 2021, 6:32am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/141 "2021-02-23T06:32:24Z")

</div>

Same one we used last time

> **[Copy of Glide NOIP Sample](https://docs.google.com/spreadsheets/d/14n3zSCNdywMg0yeUK1-F5S1nPwx5ir8IiRmCL_rK4lc/edit#gid=1812311831)**
>
> NoIP
> 
> DDNS Update Time,2021-02-19 16:42:25,HTTP,MOBILE,RTSP,HTTPS,ROUTER,HTTP\_up,Mobile\_up,RTSP\_up,HTTPS\_up,Router\_up,Ports correct?,Private DDNS
> NOIP INFO WARNING DO NOT CHANGE USER OR PASSWORD EVER!!!,02/19/2021 04:42 PM
> DDNS URL,2/19/2021...

---

<div class="post-metadata">

**Author:** ![Antonoff](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/antonoff/32/22045_2.png) [@Antonoff](https://community.glideapps.com/u/Antonoff)\
**Post date:** [February 25, 2021, 9:10am UTC](https://community.glideapps.com/t/scripts-scripts-scripts/18965/142 "2021-02-25T09:10:49Z")

</div>

Hi there  
I look for an example script: need to compare two tables and if it finds a match, copy the row to the third table.  
Now I have it:  
function Alarm ()  
{  
var sheet = SpreadsheetApp.openById (“id”);  
var Data1 = sheet.getSheetByName (‘Feed’);  
var Data2 = sheet.getSheetByName (‘Alarm-list’);  
var Data3 = sheet.getSheetByName (‘Notifications’);  
}  
Already suggested (thanks @ThinhDinh ) that it should be the expression “When I add to table A, if the input info matches a row in table B, write both to table A and table C, and show an in-app notification. If no, only write to table A.  
Same for table B, if the input info matches a row in table A, write both to table B and table C, and show a notification. If no, only write to table B. "  
But how to express it in the code - I don’t know.  
Help, please.

[Previous page](https://community.glideapps.com/t/scripts-scripts-scripts/18965.md?page=6)

[Next page](https://community.glideapps.com/t/scripts-scripts-scripts/18965.md?page=8)
