I hope someone here can help me with this as i am at a loose end. I have a little experience with programming (variables, etc) but not much at all with Javascript, JSON and many others.
Unfortunalty i cannot fully describe what im doing as it invloves sensitive info but i will try my best:
My plan is to collect data from a webhook and enter it into a google sheet which can then be seen by myself and my colleagues (and it needs to be as 'real-time' as possible, hence using webhooks instead of API - i think)
Ive been using google apps script and javascript
At the moment i just want to be able to collect the data from 1 variable, once i know how to do that i can hopefully figure out how to get the rest of the data that i need from the other variables - but there is another problem, the JSON data seems to come in 2 different formats which to be perfectly honest i confusing the **** out of me, so if anyone can could you please explain as best you can what i need to do.
I have looked at w3 schools and a number of other sites and forums (of which this one seemed to make the most sense hence me asking on here) but most of it has fryed my brain.
anyway here is what i need :
I would like to get the data from "title" - in this example "Order #301428\"
here is part of the webhook i have received - the data has made it to the spreadsheet but it is in one massive string which is no good to me, i need to be able to just grab the data i need.
also could someone please tell me how to enter the data i need in a google sheet
Thank you very much in advance for any help
here is the 1st format that i have recieved (not complete as sensitive data) :
{"parameter":{},"postData":{"contents":"{\"id\":12374453,\"title\":\"Order #301428\",\"created_at\":\"2020-04-28T23:43:13.000Z\",\"updated_at\":\"2020-04-30T10:52:27.000Z\",\"customer_id\":10960996,\"user_id\":14426,\"status\":4,\"scheduled_at\":\"2020-04-30T10:00:00.000Z\",\"merchant_id\":149,\"extras\":{\"previous_task_distance\":null,\"distance_to_team\":null},\"
here is the 2nd format :
{"contextPath":"","parameters":{},"contentLength":23356,"parameter":{},"queryString":"","postData":{"contents":"{\"id\":12425150,\"title\":\"Order #354554\",\"created_at\":\"2020-04-30T09:14:01.000Z\",\"updated_at\":\"2020-04-30T10:43:11.000Z\",\"customer_id\":11003352,\"user_id\":14894,\"status\":4,\"scheduled_at\":\"2020-04-30T11:00:00.000Z\",\"merchant_id\":149,\"extras\":{\"previous_task_distance\":null,\"distance_to_team\"
thank you again
Thank you all for your help - i've looked through numerous tutorials and other information but no matter what i do i cant get it to work and i honestly have no idea what im doing wrong - the thing that is really getting me is i can get the long string of data to show up in google sheets so i know ive got the connection there right - but when i follow any of the advice regarding JSON.parse, Javascript objects, JSON.stringify or anything else it just doesnt work - heres my code (my latest test)
var data = JSON.parse(e);
var orderno = data.postData.contents[1];
sheet.getRange(lastRow + 1,1,1,1).setValue([orderno]);
for some reason i cant enter all of my code
Take the json and parse it into an object:
https://www.w3schools.com/js/js_json_parse.asp
You should then be able to access the attributes like so:
obj.postData
PostData appears to be another json string embedded in the first json, so you will need to parse that as well.
Related
Using alpha anywhere. I have a list, say 'roles' and 'companies' filtered by user_code. I am using it offline so I need everything to be pre-populated while connection available. When Offline, I need to filter the list by company so that I can get the 'roles' based on the current company_session. Can anybody point me to the right way? Or at least can anyone teach me how to get the data from the A5W list and bring them to javascript accessible like javascript array, or JSON format?
I figured it out. too long on a computer. Alpha Anywhere actually have simplified this. In UX component method I found getListData method. It done exactly what I need!! at least I am one step ahead.
var data = {dialog.Object}.getListData('USERROLESLIST');
var dataJSON = JSON.stringify(data);
Then, the JSON.stringify give me the visual of the actual data in the list.
I am very new to programming and I need some help. I am making a billing/invoice program. I would like to be able to populate and unpopulated an invoice by checking or unchecking a company and either one or multiple services. The company names and services are being stored in a database. I know this needs to be done with JavaScript. I have been looking for examples of how to do this on the internet and I can't find anything that use checkboxes. I'm probably making this way harder than what it should be. Any help on how I can do this would be greatly appreciated.
Google's first result on "javascript checkbox" is an answer to your struggle (w3schools link).
you need to do it in few steps 1st. If data is stored in SQL database use PHP to transfer data for json or use PHP to insert data stright in to columns(checkbox labels)
2nd. Data is readable, so lest go for next step if you using JSON insert data in to your label's.3rd. Write some code in JS, you need to create few functions like get checkbox val, load invoice , and some more relative to your case. For sure you will have some trouble with writing code, but you have community, and we are here to help :D Good luck
I am using this API from Stands4 to get quotes. I was able to build my random quote generator for free code camp using their RANDOM tag in the request. Now I want to know how to write a request to get quote from a tv show for a personal project I am working on. Does anyone know how this is possible?
Here is the API doc: Link
In particular I am looking at the second and third lines of their Request parameters table. I want to use 'SEARCH' but don't know how to produce the correct 'query'. Maybe I am going about this wrong.
Here is the show I would like to get quotes from: Link
Here is what I tried. Goal is to get a random quote from the show.
http://www.stands4.com/services/v2/quotes.php?uid=MYUID&tokenid=MYTOKENID&searchtype=RANDOM&SEARCH&query=Its+Always+Sunny+In+Philadelphia
Unfortunately, these aren't the greatest docs so you'll have to play around with the "query=" part of your search. You're correct in thinking that's where to start.
Here's the approach I would take to make this work:
1. Searchtype=Search: I would start subbing in all sorts of different things from It's always Sunny and seeing what gets returned, including: character names, the show name, writer/actor names, and if all else fails show objects ("Paddy's pub" and "Day man") come to mind. Note: for things with spaces make sure you're using url-encoding.
2. Searchtype=Author: Take writer names and maybe character names to see if putting those in with an author search type returns anything.
3. Use their Scripts API: I'd hope something would come from that, but if it doesn't work, you can always try and find some scripts from their Scripts API and parse them.
If all else fails you can use a scraping tool like Import.io and grab quotes from a site like IMDB. Import.io is free and very easy to use.
I have a table with lat/long for two points and I need to automatically insert driving distance (not point to point). I know I have to use a 3rd party and I would prefer to do everything in T-SQL - if possible.
I have been working with Google and managed to get the distance in 2 ways (not in SQL):
1) Javascript: This doesnt seem like a viable solution but I found some code online that produces the distance but the address has to be manually entered and I still don't know how to get that number into my table. Is there a way to run JavaScript in SQL and use my lat/long columns as parameters? My guess is no, but I figured I would ask anyway. If there is a way than I can post the code so you can show me how.
2) Found this and it seems like it could work: http://maps.google.com/maps/api/directions/xml?origin={PlaceA}&destination={PlaceB}&sensor=false
which returns results in XML. However, there are multiple distance nodes that arent uniquely identified. Also, is there a way to run this in SQL and use my lat/long columns as parameters for the origin and destination fields, then enter the LAST
<distance>
<value>Number</value>
<text>Number</text>
</distance>
that is returned into my table?
If there is any way to do this through SQL than I am open to any method that works.
The two methods I posted don't really help me get the info into my table and I dont know how to run them from SQL server.
I'm working on finding a variable for a PollDaddy poll. The API says that the hash is attributed to the variable PDV_h[PollID] (check "Voting" part of API). I've been looking all around this poll here but can't seem to find it. Can anyone help me figure out the hash and tell me how you were able to find it?
The hash doesn't seem to be used in the link you gave me here.
But on what I assume is your site, here, there's a variable PDV_h5547018, which gives you the hash you need to make the request.
This is what I got back, but this will be invalidated, of course:
PDV_n0='f5a9a0cf08b733a0e1738e271c9303d6';PD_vote0(0);
I would track down where it was made but there are so many script references. I assume you are using a script request from them, which is why they say it's in the JavaScript.