Invoking to field


#1

I am doing a simple rest service and I want to populate a field with the result of my invoke and i'm having a difficult time of it. I put a datagrid on the page so I know I am getting valid data. I can do a rowselect event and pass the field from the grid by setting my field sel_zipcode with ${event.zipcode} but if I try to do it directly to the field when i'm invoking using field sel_zipcode with {result.zipcode} it does not work.

Thanks for your help...


#2

if I try to do it directly to the field when i'm invoking using field sel_zipcode with {result.zipcode} it does not work.

Unfortunately I do not understand what does doing it directly to the field means. Could you clarify? You can attach some screenshots from Radzen.


#3

I am invoking my rest client from a button.
setting the property of sel_zipcode with the result of ws call result.zipcode
my textbox has a value of ${sel_zipcode}

when the user clicks the button I would like to fill in fields on the screen with the result.


#4

This setup looks absolutely valid. I think the only reason it won't work is if the REST method fails or returns different result than the expected. Can you check in your browser's developer tools what the server response is?


#5

the result looks fine to me, I put a datagrid on the same page from the same call and can display the fields there without issue.


#6

i'm pretty sure i'm missing something obvious


#7

The DataGrid usually expects an array of items. Is this what your REST API returns? Can you paste here a sample response (or a screenshot from your browser's network tab)?


#8

[
{
"amt": 516.7,
"ap_terms_cd": "UR ",
"authorize_initials": "12 ",
"batch_id": "FREIGHT ",
"dsc_dt": 20181222,
"due_dt": 20181222,
"inv_dt": 20181222,
"inv_no": "000003406751110",
"job_no": null,
"zipcode": "43228",
"vchr_dt": 20190102,
"vchr_no": 240839,
"vend_name": "FED-EX FREIGHT ",
"vend_no": "000000001148"
}
]


#9

I thought so. You will have to use ${result[0].zipcode} in this case because the response is an array. Right now ${result.zipcode} is undefined


#10

Thank you! that was driving me crazy.
for my own knowledge how should I format the data differently to not have to specify the index ?


#11

You should return a JSON object literal instead of array.

OLD:

[
  {
    "zipcode": "43228"
  }
]

NEW:

{
  "zipcode": "43228"
}

#12

got it. Thank you very much.