Service and Actions on Repeatable Sections

55 views
Skip to first unread message

bruno.buzzi

unread,
May 7, 2019, 8:29:35 AM5/7/19
to orb...@googlegroups.com
Hi,

The form has an HTTP service that take an argument from a Orbeon Form
component (a combo box) and then display the result in another component.

So far for god ! no problems here...

But inside a Repeatable Section the value passed to the service is always of
the first combo box iteration.

It is possible by hand to set the iteration of the argument and the
component to set ?
<xf:action class="fr-set-control-value-action">
<xf:var name="control-name" value="'myComboField'"/>
<xf:var name="control-value" value="/conversion/tepValue"/>
</xf:action>

"myComboField" is inside a repeatable section so i need to pass the value of
the corresponding iteration.
The same goes to the receptor of the service response.

Maybe this is relate to:
https://github.com/orbeon/orbeon-forms/issues/1298

I'm not try to fill a repeat with the result of a service but take the
correct value (iteration) from a repeatable section to call a service and
the set the corresponding values with the service result.

regards,
bruno



--
Sent from: http://discuss.orbeon.com/

Alessandro Vernet

unread,
May 7, 2019, 7:00:18 PM5/7/19
to orb...@googlegroups.com
Hi Bruno,

What triggers the service to run? If something inside a "row" (e.g. a button
inside that row, or value change for a control in that row), then the value
of the control on the "current row" should be sent to the service.

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet

bruno.buzzi

unread,
May 10, 2019, 4:05:24 PM5/10/19
to orb...@googlegroups.com
Alex,

A value change trigger the call to the service.

But the field that trigger the call is inside a Repeatable Section.

So the service is called always with the value of the first section
iteration.

The resource url of the service is:
http://myIP:8787/orbeon-gemstone-api/conversionfuenteenergia?fuente={fr:control-string-value('field-1')}&precio={fr:control-string-value('field-2')}&consumo={fr:control-string-value('field-3')}

I think the problem is here, {fr:control-string-value('field-1')} always is
set with the value of the first iteration of 'field-1'.

After solving this i'm not sure how to tell the Action the index of the
field to set ...

regards,
bruno

Alessandro Vernet

unread,
May 14, 2019, 2:20:13 PM5/14/19
to orb...@googlegroups.com
Hi Bruno,

Is this a GET request you're doing to that URL? If so, I'd recommend you
have the action pass the values to the service, instead of putting them on
the URL manually as part of the service declaration. This way, the action
will automatically take care of passing the value of the control on the
"current row". Also see the "Passing URL parameters to GET and DELETE
methods" section on the page linked below. You'll let me know if this works
for you.

https://doc.orbeon.com/form-builder/advanced/services-and-actions/actions

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet

bruno.buzzi

unread,
May 20, 2019, 5:02:09 PM5/20/19
to orb...@googlegroups.com
Alex,

FIXED after:
1- Changing my service to be POST
2- Setting "Passing parameters to the service's XML request" in Orbeon
3- Put XPath in actions to point to 2)

Thanks for the pointer !

regards,
bruno

Alessandro Vernet

unread,
May 21, 2019, 2:41:22 PM5/21/19
to orb...@googlegroups.com
Perfect Bruno, I'm glad it worked and you were able to pass the values of the
"current iteration". And thank you for the update.

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet

bojja...@gmail.com

unread,
Sep 11, 2019, 1:15:15 PM9/11/19
to Orbeon Forms
Hi Alex, I'm trying to do something similar and it does not work for me. I cannot do the POST method as my rest service do not accept it. 

Tried using an action to set the URL parameters for a GET request. 

Steps I did - 

1.Create http service
* enter the resource url
* Method - GET
* Serialisation - HTML form
* URL parameters - employeeid in first column first row and left blank in second column first row (the value of this emplyee id is set from the control in the repeated grid)
2. Create action
* run action when 'employeeId' control changes its value
* call created http service
* set service request values - control 'employeeId' and xpath - '/request/employeeid '
* and response to the respective controls in the same iteration

It does not give any response. Also tested the http service using the test button in HTTP service editor by entering a sample employeeid in the url parameters section -> receives a resource error. It works when I pass the same value in the url and test it it works and returns a response.

Need help in setting the get request parameter from the repeated grid control?

Alessandro Vernet

unread,
Sep 11, 2019, 7:25:16 PM9/11/19
to orb...@googlegroups.com
Hi Bojja,

Those issues are always a bit tricky to debug for us here if we can't access
your service, as we can't reproduce the issue locally. Could you:

1. Provide screenshots of your HTTP Service dialog, Action dialog, and the
section of the form where the control is?
2. So we have more information in the log, could you please try to set your
logging as described in the Development configuration section of the XForms
Logging page, stop your server, remove the `orbeon.log`, restart the server,
reproduce the error you're getting when you press the test button and attach
the `orbeon.log` you get?

https://doc.orbeon.com/configuration/advanced/xforms-logging.html

Alessandro Vernet

unread,
Sep 18, 2019, 2:01:52 PM9/18/19
to orb...@googlegroups.com
Hi Bojja, did you get your service and action to work? If not, and if this is
still on your front-burner, would you be able to share with us the
screenshots and `orbeon.log` per my previous message?
Message has been deleted

MANISH

unread,
Sep 20, 2019, 12:02:44 AM9/20/19
to Orbeon Forms
Hi Alex - attached as requested. This is still a bummer!
Orbeon log.rar

Alessandro Vernet

unread,
Sep 20, 2019, 8:25:50 PM9/20/19
to orb...@googlegroups.com
Hi Bojja,

Thank you for the screenshots and the log.

The service that seems to be causing a problem is `getCancellationDetails`.
In the `orbeon.log` you attached, I am not seeing the service being called.
If you look at the logs on the service side, does it look like Orbeon Forms
calls it when the value of "Employee ID" is changed?

Also, does the service call work when you trigger it from Form Builder with
the Test button in the "HTTP Service Editor" dialog? What is the result in
the Test Results tab?

MANISH

unread,
Sep 22, 2019, 9:54:39 PM9/22/19
to Orbeon Forms
Hi Alex- that's the service which is failing. I do not see it being called when testing the form by changing the values.

Testing using the dialog returns a resource error if the service is called using the GET parameters (Image attached)

Thanks
Test.PNG

Alessandro Vernet

unread,
Sep 23, 2019, 6:18:52 PM9/23/19
to orb...@googlegroups.com
Hi Bojja,

From that screenshot, it doesn't seem that your service is returning XML or
JSON, which is expected by Orbeon Forms and would explain the error you are
getting when running this service, or am I reading this incorrectly?

MANISH

unread,
Sep 23, 2019, 9:26:31 PM9/23/19
to Orbeon Forms
Hi Alex - the service returns a JSON payload. It returns a response when I use the parameters in the resource url instead of passing them through the URL parameters section in the HTTP service editor.

If it is not a repeat section I could have used  fr:control-string-value('control') which returns a response with no issue. So, I would say the service only fails when adding the parameters under URL parameters section.

Thanks
Manish

Alessandro Vernet

unread,
Sep 30, 2019, 12:36:16 AM9/30/19
to orb...@googlegroups.com
Hi Manish,

In your screenshot, it seems that the service call failed, as the tab is
red. Is the the symptom of a problem, or were the correct parameters just
not passed in this case? If the latter, we would need to have some code the
reproduces the problem you're seeing to be able to help; would you Would you
be able to create a minimal example that reproduces the problem, that we can
run here, and attach it a response so we can look into it?

Alessandro Vernet

unread,
Oct 4, 2019, 1:39:19 PM10/4/19
to orb...@googlegroups.com
Hi Manish, did you get a chance to check if the tab showing in red was a
symptom of a problem with the service call?

MANISH

unread,
Jan 2, 2020, 11:02:40 PM1/2/20
to Orbeon Forms
Hi Alex - Tried passing the value manually by using the URL parameters and clicked on test. It shows the results tab in green but the response is null. Tried to test it in the form and when entered an employee id in the repeat field this error message is shown "There was an error communicating with a backend service. Please contact the application administrator."

Alessandro Vernet

unread,
Jan 8, 2020, 7:16:08 PM1/8/20
to orb...@googlegroups.com
Hi Manish,

So we have more information in the log, could you please try to set your
logging as described in the Development configuration section of the XForms
Logging page, stop your server, remove the `orbeon.log`, restart the server,
reproduce that second situation where you get a the message "There was an
error communicating with a backend service. Please contact the application
administrator.", and attach the `orbeon.log` you get?

https://doc.orbeon.com/configuration/advanced/xforms-logging.html

MANISH

unread,
Jan 8, 2020, 9:07:30 PM1/8/20
to Orbeon Forms
Hi Alex - using the same form as before, reproduced and the log attached.
orbeon.log

Alessandro Vernet

unread,
Jan 10, 2020, 7:08:35 PM1/10/20
to orb...@googlegroups.com
Hi Manish,

Thank you for the `orbeon.log`. On line 9455, I see the following error:

xforms-submit-error - Body received with non-XML media type
for `replace="instance"`: application/x-www-form-urlencoded

So it seems that the service you're calling with `getCancellationDetails`
isn't returning a correct `Content-Type` header. Does this help?

Alessandro Vernet

unread,
Jan 17, 2020, 1:01:24 PM1/17/20
to orb...@googlegroups.com
Hi Manish, did you get a chance to look into this one, and why the server
responds with `Content-Type: application/x-www-form-urlencoded`, not an XML
or JSON content type?

MANISH

unread,
Jan 22, 2020, 10:02:01 PM1/22/20
to Orbeon Forms
Hi Alex - Raised and fixed here - https://github.com/orbeon/orbeon-forms/issues/4384

Thanks

Alessandro Vernet

unread,
Jan 23, 2020, 2:37:51 PM1/23/20
to orb...@googlegroups.com
Perfect Manish, I didn't realize that this was the same issue, and thank you
for the update.
Reply all
Reply to author
Forward
0 new messages