Need Script Code for Automating Emails Based on Cell Input in Google Sheets - email

I am trying to create a script that will auto-email a person. Basically, this sheet is going to have a list of items and track those items, and I need to assign each item when it comes it. When I assign it to a person's name, I want the script to then email that person. There are only about 15 people, but I assume I would need a script for each person aka if I put "Sally" in the sheet, there is a script to now email "Sally" to say she has been added to this task.
Ideally, I would like a way to also generate an email again to "Sally" if I update her task, add a comment to it, or do another input to do some sort of follow-up.
Any help would be appreciated immensely!

It wont be good to directly post the complete solution but I will mention the required functionalities which I get in my mind , please use them to solve your task:
onEdit(e) - use this to trigger a particular set of functions whenever a particular range or cell value is changed(it may be automated or manual both can trigger this function) look into the official documentation for how to detect the changes occurred in which cell(https://developers.google.com/apps-script/guides/triggers)
once the new task is assigned to a person(for first time) send an email to that person using GmailApp(install the library in app script) , get the ThreadById of this email and store it into the sheet along the same row, if any changes are made afterwords like adding comments or something,use this threadId to reply to the same email using "thread.reply"(How do you reply to email thread with google Mailapp?)
I think you have also asked how to make the system dynamic, I mean you are right now coding as if each member needs a code for his/her entry. Please study a bit deeper you will easily find an approach to make it dynamic using the onEdit and some for loops as the way you are thinking is not recommended in automation scenarios.

Related

Is there a way to permanently add a box displaying points of students in the navbar

So I am working on a project that awards points to students for submitting assignments or participating in forums, these points are then exposed as an Http resource using Flask.
The points are calculated by looking at the events triggered for each student.
One of the requirements right now is to add a box next to the student's name that shows the total amount of points they have. I have two ways of accessing the points, either by an http request from moodle or by storing and retrieving the points from moodle's database.
My question is what is the best approach of creating this "box", I have tried using moodle blocks and hacking the code but nothing seems to be working. Is creating a plugin for this the only solution or is there a simpler way to do it (if it is even possible)?
To answer your question properly you should have provided at least the theme and the Moodle version you work with. Should this box be displayed everywhere? Is the score calculated for every course individually?
Two proposals that came into my mind:
You could create a custom plugin of type block. There you can display the score of the user of the session and the top ten for example (If the score is calculated for each course individually). A disadvantage is that every teacher of a course could remove that block easily, if he or she wants to.
If the score counts system-wide you could put that box at the start page of your Moodle website, where only people with higher rights will be able to remove it.
If you use boost you could display the score in the navbar right next to the users name. For that you will have to create a new child theme of boost and overwrite navbar.mustache of theme_boost which get's it's information from columns2.php because it's included into columns2.mustache. In this PHP file you can include your logic and display it with the HTML which you put into navbar.mustache.
Of course these are not really simple ways to do that. But at the moment I doubt that an easy solution exists for this problem.

Add a user comment in a crystal report at run time

Our ERP system uses Crystal Reports to generate Company Stationary, which is used with an automail process to send out via email
In this case a user has ask if they could, at run time, type in a message on a Customer Statement, for example "Hi here is your statement please see invoice 00022 this is the one with the query". Clearly this message may not always be required and would be different at each run.
The only method to do this I have found is to use a txt parameter, but the problem is the input box at run time does not explain with the text typed, so if you make a typo you can not see it.
Can this be done with a pop up box in code?
I have looked for examples but not found anything
This isn't something that Crystal itself supports. It's read-only: Once a report is loaded, it's done calculating. If you refresh it, it performs the same calculations.
Like you said, you could use a text parameter where the user could enter a single clump of notes. In theory you could even include a parameter where you enter the invoice numbers that you want the message to appear next to. But that opens the whole can of worms regarding "How do I error check this?" and "What if the invoice number is in the wrong place?"
In short this isn't something you'd want to attempt in Crystal. If this report is launched by an app you developed, I'd try to make it a feature in the app. But reports are effectively read-only, and short of writing your own SQL commands, you'll have a bad time trying to write with a read-only system.

Create a Google Form (or similar) that verifies Student ID before submission

Context:
I teach at a university with mostly monolingual, English-speaking teachers, and students with mostly Russian and Kazakh names.
I want to create a simple form (like this https://docs.google.com/forms/d/1zo0vSfrH-xIosENy1wVjOd_VvPL5LL6UX6g4VqIPFn0/viewform ) that would keep track of reports of plagiarism on a Google Sheet (like this https://docs.google.com/spreadsheets/d/1h2nAvCq31xumi4SvjMvWWp8RR7ppJ_NtLCiuvrLqVkc/edit?usp=sharing )
Having the English speaking teachers type in Russian and Kazakh names would likely lead to mistakes. There are too many students at the university to choose them from a drop-down menu, and would be too many teachers and courses to create separate Google Forms for all of them, or to use Google's branching page choices (it would require creating hundreds of pages). So I would like instructors to be able to type in the Student ID # and their own Instructor ID #, and then have some way to verify that they have typed that information in correctly (so we don't have the wrong students being penalized, or penalties that don't get assigned to any student at all).
Questions:
1. Is there any possible way (via scripting, an add-on, etc.) to have Google Forms take the Student ID from Page 1, then look up the student's name on the Student Info tab of the Google Sheet and insert it into the text field on the second page of the Google form, so the instructor can verify it's the correct student? (Or any other technique anyone can think of that would allow a Google Form user to verify that they had entered the correct data, or help manage the massive number of choices of students in a university of several thousand students.)
If (as I'm afraid), there is no way to do it with Google Forms, can anyone suggest a Form creation platform that would do something like this, and that would integrate with Google Sheets or something similar?
Any help would be appreciated. Thanks in advance.
If you are open to doing it differently I'd go this route...
1) Use a short answer box and allow edits to answers.
2) Put the onSubmit() trigger into the sheet. When a submission comes in, send a follow up email to the person with the ID that they typed and the student name that it corresponds to. Let them know that no action is required if that is correct. If it isn't correct, they should edit their response with the edit response link which you can get using getEditResponseUrl(). I'd call it done right here and only worry about additional features if they are needed. It isn't as ideal as verifying at the time but would get the same thing done for people that can't keep their IDs straight. :-)
3) But... if you have people that keep messing up and they don't fix their issues or whatever, add a link in the email to confirm that the entry is accurate. If it isn't then a weekly/daily task runs that deletes any entries that haven't been confirmed and are older than Y days.
4) Alternately, instead of verifying what they type, give them drop down lists made up of a combination of student ID and name. I'd have multiple lists, depending on the number of active students. One or many though, make a script in the sheet that updates the dropdowns in the form either on edit or by manually running the script, either from a menu item or by attaching it to an icon on the page where the IDs/names are at. They should see 12345 - Joe Smith as the option and can find the right one if that student name doesn't match the ID they thought they should use.
I have a script like #4 that I use to populate a form with updated products whenever the list changes. I tied it to a big red button JPG to help the end users remember to run it when they change something, as a menu option didn't work and running every time there was an edit was too much.
If you list of students/IDs also includes the teachers/classes/etc you could even do custom forms for each staff member that uses the form that only populates their students. Not sure how many staff you have so that might not be practical. Though again, once you have the script and the data is accurate, updates are a single click.

Is it possible to add a custom parameter in a Open Graph story with a common action?

We're working on a fitness application where people run and carry out a physical activity for the community as part of a workout.
For example, on Wednesday, Axel ran 5.6km and helped dig a wild flower garden.
We want to build an easy way for users to share these stories on their timelines in Facebook with a map of the course they ran and a sentance that describes the activity. We've opted to use the fitness.runs common action and can provide the course information easily enough, however it's not clear if or how we can add a custom parameter task in the sentence. Ideally the story (with accompanied map) would read:
*Axel* ran *5.6* km to *help dig a wild flower garden* with GoodGym.
Any advice on how to get that working would be greatly appreciated.
I do not think this is possible. Looking at both the run action and the course object you cannot add custom properties. For example, when you go to configure the run action you see the following message at the top "Common Action Type: Run You are viewing the configuration options for the common Action Type: Run. These are read only and are displayed for informational purposes only."
However you might want to consider using User Messages which "allow users to write a personalized message attached to this action." Then you could encourage users to write something about what they helped to do.

Using applescript to edit a server variable

I do not know if I am asking this correctly (but none of my searches anywhere yielded an answer).
I'll try my best to explain;
I've created an Applescript that is used in a mail client (Mac Mail and MS Outlook).
Basically when an email is recieved, it checks the subject, if the subject contains "whatever" then the script executes.
This script asks if you'd like to send an auto-response. If you click no, nothing happens. If you click yes, one is sent. Simple enough right?
Well, the problem I ran into is 20 people all said yes at the same time, sending 20 auto-generated emails.
I am attempting to find SOMEWAY to have "it" check to see if someone has already clicked yes. Does anyone have any insight? Am I going too far outside the scope of Applescript? If so, any alternatives would be greatly appreciated.
You need some centralized way to keep track when a yes is clicked. So a simple text file on the server may do the job. What I'm thinking is that when someone clicks yes to send the auto-responce then the first thing the script does is check the central file to see if anyone else has already clicked yes. If the file does have a yes then a new dialog pops up and lets the user know the email was already responded to and of course that yes does not respond. If the file does not have a yes then the script writes a yes for that email to the file, then sends the response.
You would need some way to distinguish between the emails that come in at different times so you would check the central file for this unique email property... something that is unique to each email but the same for everyone that receives it. If there is not a unique property then maybe a time based check would work. For example you could write the time-of-day to the file, and you don't send a response if the file contains a time within 30 minutes or some other suitable time period.
I hope that gives you some ideas. Good luck.