Script to Pull Data from Sheets to Google Docs.

314 views
Skip to first unread message

Joshua Geeting

unread,
Mar 3, 2022, 3:39:39 PM3/3/22
to Google Apps Script Community
Hello, I am trying pull data from multiple cells to create a google doc. Looking at the screenshot, I would like to have it so if the checkbox under email column is checked, then the name, employee id, notes, and "Call Area/Directed to" are then populated into the proper positions in the google doc. 

I have used "Define range name" as follows. Column E "Name", Column "F" "ID", Column "H" "Notes", Column "J" "Call_Area".  Column "N" is "Email".

I would appreciate any help or ideas on how to accomplish this.

Thank you,
Joshua
SS2.png
SS1.png

Michael O'Shaughnessy

unread,
Mar 3, 2022, 9:24:30 PM3/3/22
to google-apps-sc...@googlegroups.com
Hello Joshua,

Are you looking for help writing the code or are you looking for someone to write it for you?

If you want help, please share what you have written or tried so far.

Do you want a separate document created for each checked row or do you want info "appended"?

GAS has several "replaceText" methods.  One of them is done by getting the body of the document and finding special tags to be replaced. 

For example you already have {{Name}} tag so you would write something like this:

let body = DocumentApp.getActiveDocument().getBody()
body.replaceText("{{Name}}", "Frank") 




--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/46578de9-8754-4606-8ff7-c10e6c5d5f3en%40googlegroups.com.

Joshua Geeting

unread,
Mar 4, 2022, 8:53:22 AM3/4/22
to Google Apps Script Community

I am very new to scripting and somewhat new to functions(I did advance cell functions 15 years ago) and have very limited coding knowledge(I used QBASIC as a kid...yes I know very old and very long ago). I have had some luck searching online and modifying to do some things I want to do. However, for this one, I can't find exactly what I'm looking for. 


However, it creates one for EVERY item on the list. I don't need that many emails made only when I have selected the line by use of the checkbox.  I need it to run and create it only when my "email" check box is checked. 

In response to your questions:

1. I am looking for help writing the script I would use it based on this one as it is the closest I can find to what I am looking for.

2. I would be ok with it creating a google doc for each "line" that I need an email for, I just don't want it for every line, only the one that I would check. So in other words I fill out my log and if I need an email generated I click the checkbox. In the field beside it, I get a google doc to email out. I could just delete the contents of the folder at the end of the day or throughout the day. 

2. Alternatively, It could be appended as well. I tried looking for an example of an "IF" type function so that in one cell let's call it (Based off of SS1) "P108"(Not shown in SS1), if I check any box in column N, then cell "P108" would say, 

"Hello {{CALL_AREA}} Team, {{NAME}},{{ID}} needs some assistance. Here is the pertinent information: {{NOTES}}. Thank you, Front Desk."

I could then just copy and paste the text of that cell to create an email.

I hope this all makes sense.

Thank you for responding. 

Joshua
Reply all
Reply to author
Forward
0 new messages