Can't get choice url to work

Use this board to ask questions or have discussions with other Rich Displays users.
rustygad
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

Post by rustygad »

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.
Screenshot 2021-03-21 204003.png
Screenshot 2021-03-21 204003.png (20.78 KiB) Viewed 3249 times
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?
User avatar
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

Post by matt.denninghoff »

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/.
rustygad
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

Post by rustygad »

I noticed that after my initial post.

Here is what I'm seeing the the browser.
Screenshot 2021-03-22 090434.png
Screenshot 2021-03-22 090434.png (9.4 KiB) Viewed 3246 times
The browser is complaining about the JSON format. I copied/pasted the JSON into a JSON syntax checker.
Screenshot 2021-03-22 085552.png
Screenshot 2021-03-22 085552.png (20.93 KiB) Viewed 3246 times
JSON is expecting a string value after [, it doesn't like "new".
The browser had the same error.
Scott Klement
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

Post by Scott Klement »

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
rustygad
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

Post by rustygad »

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.
Scott Klement
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

Post by Scott Klement »

Yes, "text" and "value" are a requirement if you use the JSON method.
rustygad
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

Post by rustygad »

Now I get it.

Thanks Scott.
rustygad
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

Post by rustygad »

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:
Screenshot 2021-03-23 072901.png
Screenshot 2021-03-23 072901.png (24.75 KiB) Viewed 3236 times
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".
Scott Klement
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

Post by Scott Klement »

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.
User avatar
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

Post by matt.denninghoff »

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")
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests