Forum Discussion
GeoffreyHarmuth
6 years agoQrew Captain
So im stuck on this, is there anyone that can assist here? this code of Dans is not working.
Any help is appreciated.
Any help is appreciated.
- AustinK6 years agoQrew CommanderCan you be more descriptive than it "is not working"? Which part of the code does not work? Did you try both jquery and the other option? Did you test it in the console first to make sure it worked before trying to implement it via IOL? Is the part that isn't working the part of the code that is not fully included, the part that fills the fields to the form?
If you can say which section of the code is failing then someone can possibly help. - GeoffreyHarmuth6 years agoQrew CaptainHi Austin. Thanks, my post was just to check if someone is able to assist on this since Dan is MIA.
So the first line of code (Jquery) doesn't seem to work, i'm not sure if there is a syntax error. I tested in the console first.
Secondly, i'm not sure how to combine the 2 pieces of code (below) To pull the information and add into the quickbase native address type field.:
First one to fetch the info:var apikey = "YOUR API KEY";
var addr = "puns.chew.snow";
var url = 'https://api.what3words.com/v2/forward?addr=${addr}&display=full&format=json&key=${apikey...;
$.get(url)
.then(function(json) {
console.log(json.geometry.lat);
console.log(json.geometry.lng);
console.log(json.map);
console.log(JSON.stringify(json, null, " ")); });
And second to populate the field forms:_fid_7.value = json.geometry.lat;
_fid_8.value = json.geometry.lng; _fid_9.value = json.map;
I am thinking I should run the code in a formula url button, and making the script as follows:var apikey = "YOUR API KEY";
var addr = [what3words address field];
var url = 'https://api.what3words.com/v2/forward?addr=${addr}&display=full&format=json&key=${apikey...;
$.get(url)
.then(function(json) {
_fid_7.value = json.geometry.lat; _fid_8.value = json.geometry.lng; _fid_9.value = json.map; console.log(JSON.stringify(json, null, " ")); });
But im messing the code up somewhere (not a developer here). I would like for the script to run automatically using iol, but im not entirely sure how the script page would need to look - AustinK6 years agoQrew CommanderLets start with the easy stuff. You have gone to what3words and created an api key correct? You have to register an account and possibly more, it says it is free. Then you replace the "Your API Key" part with your API key.
You also will need to edit that URL it is using. This code is using the v2 API but they are on v3 now.
https://api.what3words.com/v3/convert-to-coordinates?words=filled.count.soap&key=[API-KEY]
You can try this code here and see if it works with your API key. It should console.log the data which you can see by hitting f12 if in Chrome and going to the console tab.
var apikey = "YOUR API KEY";
var addr = "puns.chew.snow";
var url = 'https://api.what3words.com/v3/convert-to-coordinates?words=${addr}&format=json&key=${apikey....;
$.get(url)
.then(function(json) {
console.log(json.geometry.lat);
console.log(json.geometry.lng);
console.log(json.map);
console.log(JSON.stringify(json, null, " "));
});