Can't get choice url to work
-
- New User
- Posts: 17
- Joined: Thu Nov 12, 2020 12:13 pm
- First Name: Lynnon
- Last Name: Gadberry
- Company Name: Arkansas Data Services.com
- Phone: 5014728384
- Address 1: 27 MacArthur Dr
- City: Conway
- State / Province: Arkansas
- Zip / Postal Code: 72032
- Country: United States
- Contact:
Can't get choice url to work
I used the universal display file example https://docs.profoundlogic.com/display/ ... splay+File to develop this web service. The select box looks like this.
The choice url is: /profoundui/universal/getStateAbbreviations
Running the web service from a browser the results looks like this.
{
"success": true
"response": [
new option("AK","AK"),
new option("AL","AL"),
new option("AR","AR"),
new option("AS","AS"),
.
.
new option("WY","WY")]
}
I don't see where I'm doing anything different than what's in the example, so why is this not working?
The choice url is: /profoundui/universal/getStateAbbreviations
Running the web service from a browser the results looks like this.
{
"success": true
"response": [
new option("AK","AK"),
new option("AL","AL"),
new option("AR","AR"),
new option("AS","AS"),
.
.
new option("WY","WY")]
}
I don't see where I'm doing anything different than what's in the example, so why is this not working?
- matt.denninghoff
- Profound Logic Staff Member
- Posts: 115
- Joined: Wed Feb 10, 2016 3:53 pm
- First Name: Matthew
- Last Name: Denninghoff
- Company Name: Profound Logic Software
- State / Province: Ohio
- Country: United States
- Contact:
Re: Can't get choice url to work
If there is no comma after the "true", like in what you posted, then the JSON syntax is not valid. If the JSON syntax is not valid, then the browser cannot parse the results, and the Profound UI code cannot load them into the drop-down.
One way to see if the JSON syntax is valid is to copy the JSON output and paste it into a JSON validator, such as this one: https://jsonlint.com/.
One way to see if the JSON syntax is valid is to copy the JSON output and paste it into a JSON validator, such as this one: https://jsonlint.com/.
-
- New User
- Posts: 17
- Joined: Thu Nov 12, 2020 12:13 pm
- First Name: Lynnon
- Last Name: Gadberry
- Company Name: Arkansas Data Services.com
- Phone: 5014728384
- Address 1: 27 MacArthur Dr
- City: Conway
- State / Province: Arkansas
- Zip / Postal Code: 72032
- Country: United States
- Contact:
Re: Can't get choice url to work
I noticed that after my initial post.
Here is what I'm seeing the the browser. The browser is complaining about the JSON format. I copied/pasted the JSON into a JSON syntax checker. JSON is expecting a string value after [, it doesn't like "new".
The browser had the same error.
Here is what I'm seeing the the browser. The browser is complaining about the JSON format. I copied/pasted the JSON into a JSON syntax checker. JSON is expecting a string value after [, it doesn't like "new".
The browser had the same error.
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Can't get choice url to work
The immediate problem is that the O in "new option" needs to be capitalized.
As you've noticed, however, the syntax is valid JavaScript, but not valid JSON. That's because the dropdown widget is very old -- it existed in Genie even before Profound UI existed, and back in those days, it wasn't important for it to be valid JSON, this was before JSON was widely used in APIs, etc. That example is also very old. So, correcting the O should make the screen work, but it won't hold up to a JSON validator.
In newer versions of Profound UI we offer a "true JSON" alternative. You'll find an example in the docs for the Select Box widget.
https://docs.profoundlogic.com/display/PUI/Select+Box
As you've noticed, however, the syntax is valid JavaScript, but not valid JSON. That's because the dropdown widget is very old -- it existed in Genie even before Profound UI existed, and back in those days, it wasn't important for it to be valid JSON, this was before JSON was widely used in APIs, etc. That example is also very old. So, correcting the O should make the screen work, but it won't hold up to a JSON validator.
In newer versions of Profound UI we offer a "true JSON" alternative. You'll find an example in the docs for the Select Box widget.
https://docs.profoundlogic.com/display/PUI/Select+Box
-
- New User
- Posts: 17
- Joined: Thu Nov 12, 2020 12:13 pm
- First Name: Lynnon
- Last Name: Gadberry
- Company Name: Arkansas Data Services.com
- Phone: 5014728384
- Address 1: 27 MacArthur Dr
- City: Conway
- State / Province: Arkansas
- Zip / Postal Code: 72032
- Country: United States
- Contact:
Re: Can't get choice url to work
Scott, I went for the JSON method.
I could not get it to work until I change the response to be "text" and "value". Is that a requirement when doing Choice URL with select boxes?
{
"success": true,
"response": [
{"text": "Alabama", "value": "AL"},
{"text": "Alaska", "value": "AK"},
{"text": "American Samoa", "value": "AS"},
.
.
{"text": "Wyoming", "value": "WY"}]
}
Still learning here.
I could not get it to work until I change the response to be "text" and "value". Is that a requirement when doing Choice URL with select boxes?
{
"success": true,
"response": [
{"text": "Alabama", "value": "AL"},
{"text": "Alaska", "value": "AK"},
{"text": "American Samoa", "value": "AS"},
.
.
{"text": "Wyoming", "value": "WY"}]
}
Still learning here.
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Can't get choice url to work
Yes, "text" and "value" are a requirement if you use the JSON method.
-
- New User
- Posts: 17
- Joined: Thu Nov 12, 2020 12:13 pm
- First Name: Lynnon
- Last Name: Gadberry
- Company Name: Arkansas Data Services.com
- Phone: 5014728384
- Address 1: 27 MacArthur Dr
- City: Conway
- State / Province: Arkansas
- Zip / Postal Code: 72032
- Country: United States
- Contact:
Re: Can't get choice url to work
Now I get it.
Thanks Scott.
Thanks Scott.
-
- New User
- Posts: 17
- Joined: Thu Nov 12, 2020 12:13 pm
- First Name: Lynnon
- Last Name: Gadberry
- Company Name: Arkansas Data Services.com
- Phone: 5014728384
- Address 1: 27 MacArthur Dr
- City: Conway
- State / Province: Arkansas
- Zip / Postal Code: 72032
- Country: United States
- Contact:
Re: Can't get choice url to work
Now I'm wanting to pass parms to the choice URL but can't get it to work.
Choices URL:
/profoundui/universal/getADSVALlist?parm1=?&parm2=?
Choice parameter value: This is what I see in browser. ErrorID contains the parms that the program read in.
{
"success":false,
"errorId":"?/0",
"errorText":"Error occurred retreiving ADSVAL list. See joblog 359847/QTMHHTTP/PROFOUNDUI for details."
}
Appears that the database driven selection properties is not used by "choices url".
Can't find examples where parms are passed to "choices url".
Choices URL:
/profoundui/universal/getADSVALlist?parm1=?&parm2=?
Choice parameter value: This is what I see in browser. ErrorID contains the parms that the program read in.
{
"success":false,
"errorId":"?/0",
"errorText":"Error occurred retreiving ADSVAL list. See joblog 359847/QTMHHTTP/PROFOUNDUI for details."
}
Appears that the database driven selection properties is not used by "choices url".
Can't find examples where parms are passed to "choices url".
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Can't get choice url to work
Parameter markers and parameter values are a feature of SQL databases.
You are building a URL in a web browser, not running an SQL statement... you can't use SQL features, here.
You are building a URL in a web browser, not running an SQL statement... you can't use SQL features, here.
- matt.denninghoff
- Profound Logic Staff Member
- Posts: 115
- Joined: Wed Feb 10, 2016 3:53 pm
- First Name: Matthew
- Last Name: Denninghoff
- Company Name: Profound Logic Software
- State / Province: Ohio
- Country: United States
- Contact:
Re: Can't get choice url to work
Scott beat me to reply. You could do something like this in your "choices url":
Code: Select all
script: '/profoundui/universal/getADSVALlist?parm1=' + get("ID_SysCode") + '&parm2=' + get("Id_FldID")
Who is online
Users browsing this forum: No registered users and 2 guests