Tuesday, October 22, 2013

Happiness Is a Warm Doggie in Your Lap

Being winter (it's late October in Seattle - don't kid yourself that there are more than two seasons here), I'm cold almost all the time.  It doesn't help that I'm an environmentalist (read: cheapskate) who keeps the heat set at 65 degrees during the day when normal people are at work. Luckily, working on programming (I own you, Google Apps Script!) and programming classes, I have two things to keep me warm: a computer and a doggie, both competing for lap space in the big chairs in the living room.

Annie wants to dominate the computer, so she licks it.  Surprisingly, dog saliva only seems to make computers work better, not worse, since whenever she licks it, I solve some other programming problem.  As that beer commercial says, It's only weird if it doesn't work.  And I didn't even have to grill a quinoa burger.

If you'd like to see exactly how I dominated Google Apps Script, please check out my code on github (jwicksnin).  Here's a quick rundown:

After creating a script to send emails with the current user address, and send responses to another spreadsheet, I now have an app that...

  • Creates a button on the spreadsheet for any user send a reminder email
  • In the background, onclick, the script compares the original spreadsheet names with the responses spreadsheet.
  • Flattening an array of both spreadsheets' names, finds those who haven't responded.
  • Sends a reminder email similar to the original email to those who haven't responded yet. 
  • Makes a very merry January for donors who receive gift baskets after confirming their mailing addresses.

Pretty awesome!  Now people at work won't even have to know about the scripts in order to use them. And that, after all, just might be the mark of a good computer program.

Tuesday, October 15, 2013

Oh No You Didn't, Google!

Yes, I am aware that I'm writing this on blogger, officially Google app/program/property/whatever.  But the attitude alluded to in the post title is good attitude - I have discovered Google's best-kept-secret.  Okay, maybe you knew about it, but I guarantee that other guy over there didn't.

If you liked Google Drive and Apps, you will love this.  They made up their own cryptic JavaScript dialect so you, yes you, can affect the functionality of your Google Docs.

For example, I was tasked with creating a Google Form to email to clients to confirm their mailing addresses so we can mail them holiday gifts.  Sounds simple enough - Google Forms as it is allows you to put the form in an email, a link to the form in an email, and embed the form in your own website.  Then the results are put into a spreadsheet of your choosing.  Wow!

But... when we decided to pre-populate the form with the addresses we had on file and clients could then either edit and submit, or approve and submit the address instead of having to enter the address all over again, well, it got complicated.  Suddenly, I needed some way to take data from the existing address spreadsheet, put those values into a form as values, then put that form into an email.  Sounds awesome, but as with many awesome things, easier said than done.

(I might mention that in the middle of this project I got a little frustrated and decided I needed a "win", however small, and so put a favicon on the website, which took about ten minutes but was worth as least an hour of feeling like I actually accomplished something).

I happen to really like JavaScript (which anyone who has visited my website, jessicawicksnin.com, can attest to) so I decided to give Google Apps Script a try.  You can now see the results at my github page (username jwicksnin)!

I want to point out the fatal flaw in my solution: the actual form is NOT embedded in the email.  I dare you to try to find a way to do this - if you do, please let me know.  However, this is the results I did come up with (as HTML in the body of the email):

Hello <client name>
<Address we have on file>
Please confirm <pre-filled URL> or change <same URL> so we can send you a gift.

Taking advantage of the pre-filled url idea, the client can see the address we're going to send to, and then go to a pre-populated form by following the link where they can easily change or simply confirm the address. Yay!