Create an automatic status change for room booking in Spreadshee - google-sheets

Trying to set up a Google Sheet that can automatically determine request status based on previous request.
So the flow start with Zapier pushing information to this sheet and specific row
Data Entry Sheet
*The data here will be replaced every time there is a new booking request so the number of cell will always be the same.
The approval system that is needed use the "first come first serve" rule where as long as there is no previous request that match the time within the request, google sheet can directly says it's approved, otherwise it is rejected.
The problem is we need to know if there is already another approved request that is submitted before the request that we want to check. This is the sheet we use to track all previous request
Sheet of Previous Request
Is there any way we can compare the data from "New Request" Sheet to all of previous request in "Reservation" Sheet?
Also another question, can we add all the the request that came in into the list of previous request?
Thank You!
Basically I haven't tried any combinations of command but I have try using filter or array individually but it doesn't work.
This is a new project so there is no previous result I can show but the expected result is all the request will have their request status filled so Zapier can return that request status to it's requestor.

Related

How to log users email in Google Apps Script

I'm trying to make a script that logs the date and time, and a user's email address when a button is pressed in Google Sheets. I can get the date and time values printed but whenever the button is pushed it just returns "Logger" instead of an email address. I'm also struggling to figure out how to change which cell the value is returned in, as the sheet is designed to log many users. Here's what I have so far, any help is appreciated.
edit, I've gotten the script to insert the user's email into a specified cell. Now I'm just wondering how to make it so it inserts the date and email into the next available row.
function setDate() {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Form Responses 1").getRange("N2").setValue(new Date());
var email = Session.getActiveUser().getEmail();
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Form Responses 1").getRange("O2").setValue(email);
}
Refer to getActiveUser()
If security policies do not allow access to the user's identity, User.getEmail() returns a blank string. [...] However, these restrictions generally do not apply if the developer runs the script themselves or belongs to the same Google Workspace domain as the user.

User delta query confusion

When using the deltaLink retrieved from a request to the users/delta endpoint on the v1.0 Microsoft graph API, do subsequent requests (using the deltaLink) returned from each previous request return changes since the initial request, or from the last request?
I am confused as to what the intended scenario is for the endpoint. Is the token a long-lived thing, that you use in your application for a while to keep reusing to track changes from some initial sync, or is it a temporary method to see changes between two points in time, and then the token is discarded?
Right now it appears to "accumulate" changes since the token was created, which I guess makes sense, but if left to live for a long time would requests would potentially accumulate a lot of changes.
When you call a deltaLink, it returns everything that has changed since that deltaLink token was issued. The results will also include a new deltaLink token that you use for your next poll of the system.
In other words, it is similar to the source code control systems like Git work. When you execute git pull, it looks at last commit in your local repository and then pulls down all of the changes that have occurred since that commit. In this example, Git's commit id is the delta token.
For example, you can start syncing Users "from now" using this query:
https://graph.microsoft.com/v1.0/users/delta
The results will look something like this:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users",
"#odata.deltaLink": "https://graph.microsoft.com/v1.0/users/delta?$deltatoken=4Pqov5cPSZPKjBZh-vGbekLcJ2oUTc1kzqA0XhF-lJrEmf3B2i-HyS72r9jBIqHuZUzdMopk5VyHnAI6_qh59FjavhOmaTmQW4JPL2bLKu5LpQ3m_zMSsp6M3Os03KOgaeay0zwAa08QefM1ArkZzkB_pUmZyV6MIS1eN7JHnBOgotBPFyPb-dnjAcheWE9W0HkUR87kf3jsuA4Ja4QTRnN3Hj_4eYdzoYxLWi54Aq2bHWTbDlPtl76M8Bhw8jiq37Y4R-G7G0eZNuRt43CBY0l3XliXXR5Ubi4ZUGApDAGVSPNc_VdHV4H3nbaB5qvwZZ7tAfqZB0-06-ZI-a0y2hxAPJLnI-iTB2PXdqxnaZn4f26k0khW52C57czh9KOjfE3nYV6pwEDFRFu-qj4062eMQwo2H6yoCLysv-C-XIOK3nDTaR3BPDOPGqNbnZkmB33-MXe9gcCPojAoU9ql95Z9de5QPnqezWVfBhXj_sRv3RlQQfCkGJHg3ZTVkdA475xJuHOhy2po38KlT3FmN0rzg0jOjvfPyTGrRI24C58ushGouckqHcCQllr4Dby9ECsPjVcNFEklSddjllaRMOkpUilecEdHnxsy0zH60bKkc2-6fcUvYuya8y4-7IySvbpk241ldxvoO9EQpDnUCdh3GgxKnYNuLtOiqiGdYVgGgTJa-iBQ1xVghcpsEMD9NqrByB3mSmy9rRKN3WP_C_HQBnEpV7Z3dvu-8ZxewMEhEObhhv8H_15msP4Bm6KvfuO-0EyNaMy_OXv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xbyig6bENFyMR_5w_Q3LugXIIRknWB21jxWbcMOY1ggaYZno-MBFA2ueFDox8ImN4A9orD-8XpgbSqywqv5dnh4rCDoate27oMkz8NEGW6UdZUOSBrC0k91FKO2yHUa8KDA3tTKMIgDU-ynS0hOzfc_4cUICDpQJJOv2tXsWigkuVshJc-1733CXF3ptA8llB9dFPt6_-oWKAjxvHRq6_X8mX2Siz9D2kTXpfUS-AKmEpKcphNWzpIg5K8iKMy-xB_insLCYbkjFkxU5Q6-VnjS6KRolOXaRSejh2faVxFbgIFrOP6Ns5inBJZUemAPV7TTxY_RIGh3f4nMbzxU2P5doyYP7wTr_aiLDw1uJrDxjXRLPzLseS1uizlLpZMPw-QIAUARFyUzj7k4U9bzXoX_9URA5acvETVZOebdUbR3kCOOoBMmbdELX7uUkICPu_T0fsbGLAKA4wZSIIYdqCUydMQk9NofgvE28v-NB2g4-fFPuFANn0H4b0ktFrBT8wUO61ElrnwsL1tLyx6kP4s1y6OaH_ARTpb9StCkcvbO2bh4HYLj09xnxgbx_4RPUI6cag6mjCRhNTIipj3feZ0pBEVlL7NiTavSV2Ho2gGJujurYSE4cdF-Gjtraeulj0ur1buEwVQX8LbLWbO76X4cQLhE7G2Yf7GV8tjW2DX4TdG9yRciPaBntE0Imxe6IKZnSEEyqXMsZIRWLBfI3WIiVka-QD9lJlPZAdkNMb5VqQxyqruiCZ3nK-R7njc1EoVDejJEDOGyAljhF_kvcxsd_Hu0G8QHi0JtXXm8Tm9hH1O7EtEIDQAHR0tt6ihHixK2IYdfmoe3EIHJ_VmlC37RqTHf2ru2FgkoutuNLII9tYsMhWEEin-tgFwdCvUA0ONHytNY2I0EFKkx56t9JGoupL-lwpnhtnqpnVAPAgAk93D01fBz2NSNlXs_z3E8SOmXud35RNCG62i_nmzHICz_WRwKMHEbqelSst9U2h5FY.uzRUQfIEYUBmAFBUnNWTJn2yfL9toRZ2_VNuoRrA7jg",
"value": []
}
The value of #odata.delaLink is a URI that points to the state of Users as of the specific moment in time the URI was generated. If nothing has changed and you follow #odata.delaLink, you will receive an empty data set and a new URI. If you then add a new User, calling the deltaLink would return only that new user.

MS Graph API response not returning all the data items it supposed to

My intention is to build a Machine Learning program that will give a recommendation for archiving email item by reading all previous email history.
For that, I am trying to read all the email item from:
https://graph.microsoft.com/beta/me/messages
First I am getting the total number of email items in my account using /messages?$count=true which returns 1881 as the result.
Then I am trying to get all the 1881 item using:
https://graph.microsoft.com/beta/me/messages?$top=1881
But the problem is that returns 976 email items. Where are the rest of the email item? How I can find them?
Are you getting a #odata:nextLink property in your response?
If that's the case, you might need to send another request with a skiptoken parameter. It should contain a value from the #odata:nextLink response property.
On the "paging" documentation page - https://developer.microsoft.com/en-us/graph/docs/concepts/paging - it is specified that different APIs have different max page size. It's possible that the endpoint for fetching emails does not support a page size of 1881. In that case, you might need to access a second page of the results.
Another suggestion is to replace beta endpoint with the V1 API call because me/messages is available there also - https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/user_list_messages

On Form Submit, How do I update another sheet with some of the new information?

So I am essentially trying to do what Zapier does with it lookup row and update row as needed. I can't use Zapier for our team's purposes because I can't work with the 15 minute ish delay.
1 - User sends data via form to Sheet A.
2 - User then needs to update information in Sheet A by submitting new data to sheet B via another Form.
3 - Data in sheet B is then matched up with row data in sheet A via the "ID".
4 - Sheet B Data then overwrites Sheet A data.
I feel like this should be simple...
Try using Forms Service, Spreadsheet Service, Triggers and Events
Form Service
This service allows scripts to create, access, and modify Google Forms.
Spreadsheet Service
This service allows scripts to create, access, and modify Google Sheets files.
Triggers and event
Triggers let Apps Script run a function automatically when a certain event, like opening a document, occurs. Simple triggers are a set of reserved functions built into Apps Script, like the function onOpen(e), which executes when a user opens a Google Docs, Sheets, or Forms file.
Using Form submit trigger you can catch the form values using ItemResponse method, get the details from the previous sheet using getValues(). Compare the two sets of values then make neccessary updates.
Hope it helps.

Bringing in a google form response to a sheet

Here is a copy of the sheets and form (form > go to live)
https://docs.google.com/a/ncsu.edu/spreadsheets/d/1mEz9mLEgP4Cfts2ZU6NwhNiL6xjWdFbt42RUj-RYbZw/edit?usp=sharing
So currently, I get responses in a different sheet. Ideally, I would get the response on the tracking sheet with the appropriate format for the dates. Additionally, I would like to keep the functionality of the tracking sheet which is to be able add in items by hand and not through the form. I currently have a script in place which auto-inputs the current date as the two separate formats.
So I'm looking for a solution which either takes in form response to the sheet and appropriate cells (the first empty cell). Or I'm looking to create a script which onEdit which when the form sheet is edited, will fetch the new response and copy it over appropriately onto the tacking sheet.
I have tried googling answers.. But I think I may be a failure at it since I wasn't able to really find a solution for this particular problem. Thank you in advance for the help!
form:
https://docs.google.com/forms/d/1AHSQrLkq3U7NJMvgWoH3lAygova7Mi4BaXHdROaaS2g/edit?usp=sharing
The script associated to this form should do the trick.
All the explanations on how to use it are in the response sheet

Resources