Initiate CRUD API via Form Action

37 views
Skip to first unread message

PITS HKE

unread,
Oct 7, 2022, 12:18:39 PM10/7/22
to Orbeon Forms
Hi All,


CRUD API is RESTFUL and I need pass document ID in the URL.  However, I can’t make document ID as a parameter in HTTP service.

Appreciate for your enlightenment.

Thank you.
Jonathan 

Alessandro Vernet

unread,
Oct 9, 2022, 7:13:58 PM10/9/22
to orb...@googlegroups.com
Hi Jonathan,

Are you referring to the document id of the current data? If so, you can use the function `fr:document-id()` (see link below). And yes, you can access the CRUD API from an HTTP Service.


--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orbeon+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/cd567acb-f2fd-4f56-b305-15414480dfd3n%40googlegroups.com.

PITS HKE

unread,
Oct 11, 2022, 4:40:05 AM10/11/22
to Orbeon Forms
Dear Alex,

Thank you.  However, the fr:service-call inside the data-iterate deems not in effective.  Appreciate for your enlightenment.

<fr:data-iterate ref="/*/row">
<fr:repeat-add-iteration repeat="my-grid" at="end"/>
<fr:service-call service="get-attachment" />
<fr:control-setattachment control="my-attachment" at="end"/>
</fr:data-iterate>

In addition, with reference to https://doc.orbeon.com/form-runner/api/persistence/search, any luck I can pass a parameter to the query as part of the http-service call?  Thank you.
<search>
<query/>
<query path="details/title" match="substring">???</query>
<page-size>10</page-size>
<page-number>1</page-number>
</search>
Regards,
Jonathan

Alessandro Vernet

unread,
Oct 11, 2022, 3:16:02 PM10/11/22
to orb...@googlegroups.com
Hi Jonathan,

Using `<fr:service-call>` inside a `<fr:data-iterate>` should be working; in fact we have a unit test for this. Would you be able to create a minimal test form that we can run here to reproduce the problem you are seeing, using services that are bundled with Orbeon Forms? For instance, you could use:

- /xforms-sandbox/service/zip-states, which returns a list of US states, for the outer service.
- /xforms-sandbox/service/zip-cities?state-abbreviation={../state}, which returns cities in the specified state, for the inner service.

-Alex

PITS HKE

unread,
Oct 12, 2022, 1:16:39 AM10/12/22
to orb...@googlegroups.com
Alex,

Million thanks again.

This syntax of "{../state}" is exactly I am looking for.

Sorry for my ignorant but the other API requires POST of XML parameters like search.  Can you please enlighten me about the needful syntax to get this through in there loop of iterate?

Thank you.

Jonathan


You received this message because you are subscribed to a topic in the Google Groups "Orbeon Forms" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orbeon/odgEhcR5OnE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orbeon+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/CANrzKkkNuSGY4u1e0DU9FDD%3Ddj6Ec-MRenaDGLnn31B7121rnw%40mail.gmail.com.

Alessandro Vernet

unread,
Oct 12, 2022, 6:09:40 PM10/12/22
to orb...@googlegroups.com
Hi Jonathan,

Would you be able to share with us the source of a minimal form definition that you have written already, so I can maybe see what is missing, and point you in the right direction?

-Alex

PITS HKE

unread,
Oct 14, 2022, 5:12:25 AM10/14/22
to Orbeon Forms
Alex,

.... in my source ....

<Param1>&lt;search return-all-indexed-fields="true"&gt;
&lt;query /&gt;
    &lt;query path="section-1/DeskNumber"/&gt;
    &lt;page-size&gt;100000&lt;/page-size&gt;
    &lt;page-number&gt;1&lt;/page-number&gt;
&lt;/search&gt;</Param1>

<xf:submission id="httpservice1-submission" class="fr-service"
                           resource="http://localhost:8080/orbeon/fr/service/persistence/search/app1/form1"
                           method="post"
                           serialization="application/xml"
                           mediatype="application/xml"/>
            <fr:listener version="2018.2" events="form-load-after-controls" controls="form"
                         actions="action1"/>
            <fr:action name="action1" version="2018.2">
                <fr:service-call service="httpservice1">
                          <fr:value value="Param1" ref="/"/>
                      </fr:service-call>
                <fr:data-iterate ref="/documents/document">
                          <fr:repeat-add-iteration repeat="grid-3" at="end"/>
                      </fr:data-iterate>
            </fr:action>

Since there are three records in http://localhost:8080/orbeon/fr/service/persistence/search/app1/form1, I will expect three row is added into grid-3 but it is not true.

Thank you for your enlightenment.

Regards,
Jonathan

Alessandro Vernet

unread,
Oct 18, 2022, 1:29:44 AM10/18/22
to orb...@googlegroups.com
Hi Jonathan,

Got it. Here are a few things you can check (if you haven't already):

1. If with Postman you call the search service with the document you have there, are you getting back a `<documents>` with the 3 documents you expect?
2. Your `<xf:submission id="httpservice1-submission">` looks right, but you must also have a corresponding `<xf:instance id="search-instance">`. Try creating an HTTP service on demo.orbeon.com, then go to Edit Source to see what the source should look like.
3. Once all this is taken care of, make sure your logging is set per the dev config (see link below), run `tail -f orbeon.log` when loading the form, and see if there are any errors in the log.

Alessandro Vernet

unread,
Oct 27, 2022, 10:01:49 PM10/27/22
to orb...@googlegroups.com
Hi Jonathan,

Did you get a chance to look into this? If so, have you managed to write XForms code that reacts to the user switching to another section?

-Alex
Reply all
Reply to author
Forward
0 new messages