Dr.Gopala krishnam raju AMBATI Posted February 12, 2019 Posted February 12, 2019 (edited) I made webhook sms api integration into my solution , I am trying to extract data with formatiing with following calculation - "smsbalance" = Left ( RightWords ( GetLayoutObjectAttribute ( "SMS BALANCE"; "CONTENT"; 1 ) ; 3 ) ; 4 ) I am getting desired result but whats happening is "smsbalance" field is not getting updated till i enter into the field smsbalance click into it and clicking outside tried lot scripting entering into it commiting records refreshing windows webviewer is getting updated but not "smsbalance" as u can see i have 4 digit sms balance , how to calculated to any number of sms balance remaining ??/ hope i am clear sms balance" Edited February 12, 2019 by Dr.Gopala krishnam raju AMBATI
Ocean West Posted February 12, 2019 Posted February 12, 2019 Why use a web viewer if the data from the API returns JSON object? Just use Insert URL to field or variable and then get the results and use the JSON functions to return the balance.
Dr.Gopala krishnam raju AMBATI Posted February 12, 2019 Author Posted February 12, 2019 (edited) I know wats JSON no experience to how use JSON and curl never touched will try if failed will cum back saw JSON I don't know what they do plz help with example I will try to understand and apply Edited February 12, 2019 by Dr.Gopala krishnam raju AMBATI
comment Posted February 12, 2019 Posted February 12, 2019 If you can get JSON (or even better, XML) from the data provider, that's certainly preferable to scraping a web page. To get help with parsing the JSON response, show us an example and explain what you want to extract to where.
comment Posted February 12, 2019 Posted February 12, 2019 Re your original question: if the field is unstored, it should refresh when you do Refresh Window. You could also give it an object name and use the Refresh Object script step to refresh it explicitly.
Dr.Gopala krishnam raju AMBATI Posted February 12, 2019 Author Posted February 12, 2019 (edited) 31 minutes ago, comment said: Re your original question: if the field is unstored, it should refresh when you do Refresh Window. You could also give it an object name and use the Refresh Object script step to refresh it explicitly. tried a lot not working trying since 1hr wat oceanwest said using insert url and json get element kept url into field mistake happening where i am not understanding ???? yes i did it but json balance is not updating DID SOMETHING WORKING PERFECT TODAY I LEARNT JSON used above calculation what does[0] mean i dont know Edited February 12, 2019 by Dr.Gopala krishnam raju AMBATI
Ocean West Posted February 12, 2019 Posted February 12, 2019 GetAsNumber ( JSONGetElement ( $json ; "[0]BALANCE" ) ) The key is case sensitive and has to match exactly to the raw JSON and because the JSON is an ARRAY you need to declare [0] as arrays in JSON start at zero json.fmp12
Dr.Gopala krishnam raju AMBATI Posted February 12, 2019 Author Posted February 12, 2019 4 minutes ago, Ocean West said: GetAsNumber ( JSONGetElement ( $json ; "[0]BALANCE" ) ) The key is case sensitive and has to match exactly to the raw JSON and because the JSON is an ARRAY you need to declare [0] as arrays in JSON start at zero json.fmp12 212 kB · 0 downloads yup tx
Ocean West Posted February 12, 2019 Posted February 12, 2019 it's a good habit to cast your JSON results to the type of data you want: GetAsDate () GetAsText() GetAsNumber()
Dr.Gopala krishnam raju AMBATI Posted February 12, 2019 Author Posted February 12, 2019 1 minute ago, Ocean West said: it's a good habit to cast your JSON results to the type of data you want: GetAsDate () GetAsText() GetAsNumber() OK GOT IT WILL REMEMBER 13 minutes ago, Ocean West said: it's a good habit to cast your JSON results to the type of data you want: GetAsDate () GetAsText() GetAsNumber() HAHAHAHA tx for the idea u gave now i am more complex now i m pulling delivery status
Dr.Gopala krishnam raju AMBATI Posted February 12, 2019 Author Posted February 12, 2019 17 minutes ago, Ocean West said: it's a good habit to cast your JSON results to the type of data you want: GetAsDate () GetAsText() GetAsNumber() HAHAHAHA tx for the idea u gave now i am more complex now i m pulling delivery status
comment Posted February 12, 2019 Posted February 12, 2019 (edited) 1 hour ago, Ocean West said: it's a good habit to cast your JSON results to the type of data you want: GetAsDate () GetAsText() GetAsNumber() It shouldn't be necessary as a rule. JSON has only 3 data types for values - string, number and boolean - and the JSONGetElement() function returns the appropriate data type for each. That should eliminate the need to use GetAsText() or GetAsNumber() on the result. As for other types such as dates, GetAsDate() will work only if the extracted string matches the date format currently used by the file - which I sincerely doubt will happen often. Edited February 12, 2019 by comment
Ocean West Posted February 12, 2019 Posted February 12, 2019 as a rule I'd agree, however i have had a few experiences when I see numbers with quotes in JSON that means that it may interpret it as string/text vs number and if you push the value between a few variables you also risk loosing the data type cast - making simple boolean logic fail. I suspect it's more prevalent when doing an SQL call to get a value vs pulling it from JSON object as JSON interpreter in the platform is fairly modern, and somewhat intuitive.
comment Posted February 12, 2019 Posted February 12, 2019 (edited) 2 hours ago, Ocean West said: however i have had a few experiences when I see numbers with quotes in JSON If you see numbers with quotes in JSON it can mean only one of two possible things: They're not meant to be interpreted as numbers - e.g. phone numbers or ZIP codes; or: The JSON providers do not know what they're doing. In the latter case there may be justification to force the data type explicitly - though I would guess in most cases failing to do so will not cause any problems, since Fiiemaker will eventually do it for you implicitly. Fo example: JSONGetElement ( $json ; "text" ) * 2 returns 246, even though $json contains: { "text" : "123" } Edited February 13, 2019 by comment 1
Recommended Posts
This topic is 2109 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now