Search code examples
javascriptformsorbeonsap-commerce-cloud

Orbeon forms - how to change default behaviour of Orbeon Action


Currently in Orbeon Forms, when you define an Orbeon Action which would (for example) react to a value being changed on the form, you can specify which Service does that Action call while providing some input parameters. Also, you can specify what you want to do with Service response and how you want to use the data received, e.g. to maybe populate some other form field.

I have a situation where Orbeon forms are used as a part of Hybris Commerce Suite, and I need to trigger the Service call after some fields change, then perform the logic on server-side and reload the original page (where form is located). Since Orbeon Builder doesn't offer me that functionality, can you give me some hints/inputs of how can this be achieved?

In other words, can I override the default Orbeon Builder functionality to let me reload the page when a response is received from the server? If I was using regular HTML forms with JS/JQuery this wouldn't be an issue, I'm just not sure how Orbeon handles this.

Thanks in advance


Solution

  • Assuming you're using the Form Builder services and actions, to plugin your own JavaScript after the service ran, in Form Builder, edit the source of the form, and add the following before the </xf:model>:

    <xxf:script observer="my-service-submission"
        ev:event="xforms-submit-done">alert('gaga');</xxf:script>.
    

    In the observer attribute, replace my-service by the name you gave to your service (keeping the -submission suffix). And of course, replace alert('gaga') by the actual JavaScript code you'd like to run.