How to extract a value from a repeating grid to use in HTTP service URL

35 Views Asked by At

I have a repeating grid on my page. When one of the items changes in it, I want to make a request to a particular URL based on the value of a field.

With a non-repeating element, I've found I can get this to work by retrieving the field value directly like this:

enter image description here

However, I can't work out how to do this with a repeating grid.

I did have a crazy idea to write an action to identify which instance of the repeating grid has been changed and write that to a field that I could use:

<xf:action id="GetCurrentlyItem-binding">
    <xf:action ev:event="xforms-value-changed" ev:observer="all-fields" if="true()">
        <xf:action class="fr-set-control-value-action">
            <xf:var name="control-name" value="'constant'" />
            <xf:var 
                name="control-value" 
                value="if (name(event('xxf:binding')) = 'targetName') then event('xxf:binding') else //constant"
            />
        </xf:action>
    </xf:action>
</xf:action>
</xf:action>

That sort of works, but the service is called before the field is updated, so it doesn't work in practice (I did see the warning about xxf:binding causing this issue). And also this solution seems sort of nasty.

If there is a way to force the ordering of actions so that this action is triggered before the service is called that would work. But it feels like the proper solution really is to find a way to add the value from the edited instance of the repeated row into the URL.

Thanks very much in advance.

1

There are 1 best solutions below

0
avernet On

Say you have a service that takes a parameter p1, which is then passed to the service as ?p1=some-value.

In an action, you can decide to call this service when a value changes in a repeated grid, and pass the value of a control as p1, as done below. If you react to a change in the value of a given control C1 and send the value of another control C2, Orbeon Forms will automatically select the particular C2 that is on the same "line" as the C1 that has changed.