Multiple Orders in Sales Order Add request in qbxml - quickbooks

I am trying to add a sales order to quickbooks using Quickbooks Webconnector. When i add a single order its successfully added, but when i try to add multiple orders in a single qbxml, quickbooks throws the following error.
"message="QuickBooks found an error when parsing the provided XML text stream."
Following is the request QBXML sent
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?qbxml version="8.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<SalesOrderAddRq>
<SalesOrderAdd defMacro="MACROTYPE">
<CustomerRef>
<FullName>Amazon.com.nvdc, Inc</FullName>
</CustomerRef>
<TxnDate>2014-07-29</TxnDate>
<BillAddress>
<Addr1>RNO1</Addr1>
<City>Fernley</City>
<State>NV</State>
<PostalCode>89408-8903</PostalCode>
<Country>US</Country>
</BillAddress>
<PONumber>TST00003</PONumber>
<DueDate>2014-07-29</DueDate>
<SalesOrderLineAdd>
<ItemRef>
<FullName>ES-10BLU</FullName>
</ItemRef>
<Desc>ES-10BLU</Desc>
<Quantity>3</Quantity>
<UnitOfMeasure>EA</UnitOfMeasure>
<Rate>100.0</Rate>
</SalesOrderLineAdd>
<SalesOrderLineAdd>
<ItemRef>
<FullName>ES-10BLUINVALID</FullName>
</ItemRef>
<Desc>ES-10BLUINVALID</Desc>
<Quantity>4</Quantity>
<UnitOfMeasure>EA</UnitOfMeasure>
<Rate>100.0</Rate>
</SalesOrderLineAdd>
<SalesOrderLineAdd>
<ItemRef>
<FullName>ES-10BLUDISC</FullName>
</ItemRef>
<Desc>ES-10BLUDISC</Desc>
<Quantity>5</Quantity>
<UnitOfMeasure>EA</UnitOfMeasure>
<Rate>100.0</Rate>
</SalesOrderLineAdd>
</SalesOrderAdd>
<SalesOrderAdd defMacro="MACROTYPE">
<CustomerRef>
<FullName>Amazon.com.nvdc, Inc</FullName>
</CustomerRef>
<TxnDate>2014-07-29</TxnDate>
<BillAddress>
<Addr1>RNO1</Addr1>
<City>Fernley</City>
<State>NV</State>
<PostalCode>89408-8903</PostalCode>
<Country>US</Country>
</BillAddress>
<PONumber>TST00004</PONumber>
<DueDate>2014-07-29</DueDate>
<SalesOrderLineAdd>
<ItemRef>
<FullName>ES-10BLU</FullName>
</ItemRef>
<Desc>ES-10BLU</Desc>
<Quantity>3</Quantity>
<UnitOfMeasure>EA</UnitOfMeasure>
<Rate>100.0</Rate>
</SalesOrderLineAdd>
<SalesOrderLineAdd>
<ItemRef>
<FullName>ES-10BLUINVALID</FullName>
</ItemRef>
<Desc>ES-10BLUINVALID</Desc>
<Quantity>4</Quantity>
<UnitOfMeasure>EA</UnitOfMeasure>
<Rate>100.0</Rate>
</SalesOrderLineAdd>
<SalesOrderLineAdd>
<ItemRef>
<FullName>ES-10BLUDISC</FullName>
</ItemRef>
<Desc>ES-10BLUDISC</Desc>
<Quantity>5</Quantity>
<UnitOfMeasure>EA</UnitOfMeasure>
<Rate>100.0</Rate>
</SalesOrderLineAdd>
</SalesOrderAdd>
<SalesOrderAdd defMacro="MACROTYPE">
<CustomerRef>
<FullName>Amazon.com.nvdc, Inc</FullName>
</CustomerRef>
<TxnDate>2014-07-29</TxnDate>
<BillAddress>
<Addr1>RNO1</Addr1>
<City>Fernley</City>
<State>NV</State>
<PostalCode>89408-8903</PostalCode>
<Country>US</Country>
</BillAddress>
<PONumber>TST00005</PONumber>
<DueDate>2014-07-29</DueDate>
<SalesOrderLineAdd>
<ItemRef>
<FullName>ES-10BLU</FullName>
</ItemRef>
<Desc>ES-10BLU</Desc>
<Quantity>3</Quantity>
<UnitOfMeasure>EA</UnitOfMeasure>
<Rate>100.0</Rate>
</SalesOrderLineAdd>
<SalesOrderLineAdd>
<ItemRef>
<FullName>ES-10BLUINVALID</FullName>
</ItemRef>
<Desc>ES-10BLUINVALID</Desc>
<Quantity>4</Quantity>
<UnitOfMeasure>EA</UnitOfMeasure>
<Rate>100.0</Rate>
</SalesOrderLineAdd>
<SalesOrderLineAdd>
<ItemRef>
<FullName>ES-10BLUDISC</FullName>
</ItemRef>
<Desc>ES-10BLUDISC</Desc>
<Quantity>5</Quantity>
<UnitOfMeasure>EA</UnitOfMeasure>
<Rate>100.0</Rate>
</SalesOrderLineAdd>
</SalesOrderAdd>
</SalesOrderAddRq>
</QBXMLMsgsRq>
</QBXML>
Does quickbooks support sending multiple sales orders in a single qbxml request or it accepts only one order in 1 request?

Whenever you see this error message:
QuickBooks found an error when parsing the provided XML text stream.
The very first thing you should be doing is running your XML through the XML Validator tool included with the QuickBooks SDK.
If you do that, you'll get this back:
Line: 48
LinePos: 49
Src Text: <SalesOrderAdd defMacro="MACROTYPE">
Reason: Element content is invalid according to the DTD/Schema.
Expecting: IncludeRetElement.
That's basically telling you that this tag:
<SalesOrderAdd
On this line:
Line: 48
Isn't correct.
It isn't correct because you didn't close your </SalesOrderAddRq> tag before opening a new <SalesOrderAdd> tag. You should have this around line 48 instead:
</SalesOrderAdd>
</SalesOrderAddRq> <!-- close the first request we're making... -->
<SalesOrderAddRq> <!-- ... before starting our second request -->
<SalesOrderAdd>

Related

OSB 12C REST adapter has blank fields

I am invoking a business service from OSB 12C that accepts POST methods. I added a REST adapter in the business column after making the request and response XSD's. In the pipeline, I use an XQuery file for transformation of the proxy service's request body to the business service's body.
Examining the receiving app as well as the network traffic, I see that the request is being submitted with a Content-Type: application/x-www-form-urlencoded header, but the payload is completely blank.
As a test, I changed the method to GET. This places the form fields within the URL, so the transformation, etc. is correct. It just doesn't work in the POST method. I've been stuck for a week on this.
Here's the XSD for the business request:
<?xml version = '1.0' encoding = 'UTF-8'?>
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
xmlns:tns="http://TargetNamespace.com/SmartCardBusiness_GetPendingRequests_request"
targetNamespace="http://TargetNamespace.com/SmartCardBusiness_GetPendingRequests_request"
elementFormDefault="qualified" attributeFormDefault="unqualified" nxsd:encoding="US-ASCII">
<xsd:element name="GetPendingRequests-BusinessRequest-Root-Element">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="db" type="xsd:string"/>
<xsd:element name="fromDate" type="xsd:string"/>
<xsd:element name="max" type="xsd:integer"/>
<xsd:element name="page" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:annotation>
<xsd:appinfo>NXSDSAMPLE=</xsd:appinfo>
<xsd:appinfo>USEHEADER=false</xsd:appinfo>
</xsd:annotation>
</xsd:schema>
And the XQuery file:
xquery version "1.0" encoding "utf-8";
(:: OracleAnnotationVersion "1.0" ::)
declare namespace smar="http://TargetNamespace.com/SmartCardBusiness_GetPendingRequests_request";
(:: import schema at "GetPendingRequestsBusinessRequest.xsd" ::)
declare variable $db as xs:string external;
declare variable $fromDate as xs:string external;
declare variable $max as xs:integer external;
declare variable $page as xs:integer external;
declare function local:func($db as xs:string, $fromDate as xs:string, $max as xs:integer, $page as xs:integer) as element()
(:: schema-element(smar:GetPendingRequests-BusinessRequest-Root-Element) ::) {
<smar:GetPendingRequests-BusinessRequest-Root-Element
xmlns:smar="http://TargetNamespace.com/SmartCardBusiness_GetPendingRequests_request">
<smar:db>{fn:data($db)}</smar:db>
<smar:fromDate>{fn:data($fromDate)}</smar:fromDate>
<smar:max>{fn:data($max)}</smar:max>
<smar:page>{fn:data($page)}</smar:page>
</smar:GetPendingRequests-BusinessRequest-Root-Element>
};
local:func($db, $fromDate, $max, $page)
The WADL file:
<?xml version = '1.0' encoding = 'UTF-8'?>
<application xmlns:soa="http://www.oracle.com/soa/rest"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns="http://TargetNamespace.com/SmartCardBusiness_GetPendingRequests_request"
xmlns="http://wadl.dev.java.net/2009/02">
<doc title="SmartCardBusinessServices">WADL Reference for REST calls for smart cards</doc>
<grammars>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://TargetNamespace.com/SmartCardBusiness_GetPendingRequests_request"
schemaLocation="../../GetPendingRequests/Business/GetPendingRequestsBusinessRequest.xsd"/>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://TargetNamespace.com/SmartCardBusiness_GetPendingRequests_response"
schemaLocation="../../GetPendingRequests/Business/GetPendingRequestsBusinessResponse.xsd"/>
</xsd:schema>
</grammars>
<resources>
<resource path="/getPendingRequests">
<method name="POST" soa:wsdlOperation="GetPendingRequests">
<request>
<representation mediaType="application/x-www-form-urlencoded"
element="cns:GetPendingRequests-BusinessRequest-Root-Element"
xmlns:cns="http://TargetNamespace.com/SmartCardBusiness_GetPendingRequests_request"/>
</request>
<response status="200">
<representation mediaType="application/json"
element="cns:GetPendingRequests-BusinessResponse-Root-Element"
xmlns:cns="http://TargetNamespace.com/SmartCardBusiness_GetPendingRequests_response"/>
</response>
</method>
</resource>
</resources>
</application>
Lastly, the WSDL:
<?xml version= '1.0' encoding= 'UTF-8' ?>
<wsdl:definitions
name="SmartCardBusinessServices"
targetNamespace="http://xmlns.oracle.com/ServiceBusApplication1/MVRServices/SmartCardBusinessServices"
xmlns:tns="http://xmlns.oracle.com/ServiceBusApplication1/MVRServices/SmartCardBusinessServices"
xmlns:inp1="http://TargetNamespace.com/SmartCardBusiness_GetPendingRequests_request"
xmlns:inp2="http://TargetNamespace.com/SmartCardBusiness_GetPendingRequests_response"
xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>
<plnk:partnerLinkType name="SmartCardBusinessServices">
<plnk:role name="SmartCardBusinessServicesProvider" portType="tns:SmartCardBusinessServices_ptt"/>
</plnk:partnerLinkType>
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://TargetNamespace.com/SmartCardBusiness_GetPendingRequests_request"
schemaLocation="../../GetPendingRequests/Business/GetPendingRequestsBusinessRequest.xsd"/>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://TargetNamespace.com/SmartCardBusiness_GetPendingRequests_response"
schemaLocation="../../GetPendingRequests/Business/GetPendingRequestsBusinessResponse.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="GetPendingRequests_inputMessage">
<wsdl:part name="request" element="inp1:GetPendingRequests-BusinessRequest-Root-Element"/>
</wsdl:message>
<wsdl:message name="GetPendingRequests_outputMessage">
<wsdl:part name="reply" element="inp2:GetPendingRequests-BusinessResponse-Root-Element"/>
</wsdl:message>
<wsdl:portType name="SmartCardBusinessServices_ptt">
<wsdl:operation name="GetPendingRequests">
<wsdl:input message="tns:GetPendingRequests_inputMessage"/>
<wsdl:output message="tns:GetPendingRequests_outputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SmartCardBusinessServices_ptt-binding" type="tns:SmartCardBusinessServices_ptt">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetPendingRequests">
<soap:operation soapAction="GetPendingRequests"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>

Orbeon Form with repeated grid : Identify field values of same iteration

I am using Form Builder (version 4.9) to create a form containing a Repeated Grid.
I've also defined a Process button, in order to send the form's data to a Servlet (using the send() method).
My goal is to save the form data in a DB table.
I am able to receive the Form's data as XML in the servlet, but I noticed that a field having the same value in different iterations,
appears only once per value in the XML, having a 'for' attribute with multiple values (indicating the number of the value repetitions).
However, I haven't been able to find a way to match all fields of the same iteration (indicating one table row), so I am not able to store the data in the DB correctly.
For Example , when I post the following table
HEADERS : FIELD_B - FIELD_C -
ITER_1 : FIELD_B_1 - FIELD_C_1 -
ITER_2 : FIELD_B_2 - FIELD_C_2 -
ITER_2 : FIELD_B_3 - FIELD_C_1 -
I get the following XML
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<control for="e7d2bb4ac261e77159fc236e7fd922c3540756f8" name="section-1"
type="section">
<resources lang="en">
<label>Untitled Section</label>
</resources>
</control>
<control for="69ec5abdeb2df55c97bf5b1db46cce6bc841aed8" name="FIELD_A"
type="input">
<resources lang="en">
<label>FIELD_A</label>
<hint />
</resources>
<value>FIELD_A_V</value>
</control>
<control for="9749b7620379db1e8f86eeceaf52c60fa19484d2" name="FIELD_B"
type="input">
<resources lang="en">
<label>FIELD_B</label>
<hint />
</resources>
<value>FIELD_B_1</value>
</control>
<control
for="89761405fd9de1a147bdda4d2c9279062b806016 9fa491ba6b72e86919e8a02226e28572c7309311"
name="FIELD_C" type="input">
<resources lang="en">
<label>FIELD_C</label>
<hint />
</resources>
<value>FIELD_C_1</value>
</control>
<control for="9cf502968950de2af58236fe0aaaab2a4fa5ac6d" name="FIELD_B"
type="input">
<resources lang="en">
<label>FIELD_B</label>
<hint />
</resources>
<value>FIELD_B_2</value>
</control>
<control for="46337304c26fca5cf9d5e91cdf393e3d39c0fbde" name="FIELD_C"
type="input">
<resources lang="en">
<label>FIELD_C</label>
<hint />
</resources>
<value>FIELD_C_2</value>
</control>
<control for="1155463007588b06b3842c534ca678aa6f5cf665" name="FIELD_B"
type="input">
<resources lang="en">
<label>FIELD_B</label>
<hint />
</resources>
<value>FIELD_B_3</value>
</control>
</metadata>
As you can see, in iterations 1 and 3, FIELD_C contains the value FIELD_C_1.
When parsing the XML, I am not able to find the order of the values of that field. I end up with the incorrect table :
HEADERS : FIELD_B - FIELD_C -
ITER_1 : FIELD_B_1 - FIELD_C_1 -
ITER_2 : FIELD_B_2 - FIELD_C_1 -
ITER_2 : FIELD_B_3 - FIELD_C_2 -
The iterations 2 and 3 have wrong values in FIELD_C.
How can I find the correct order of the values for the repeated fields ?
I am looking for a solution that does not require manipulating the form definition outside form builder, since the forms will be created by the end user with no knowledge of XForms.
The submit button in properties-local.xml is :
<property
as="xs:string"
name="oxf.fr.detail.process.OrbeonFormsPortlet.*.*">
validate-all
then send(
property = "oxf.fr.detail.send.success",
uri = "http://localhost:8080/web/guest/testlang/-/oaed-form-requests/pop_up/{xxf:get-request-header('Orbeon-Liferay-User-Id')}",
content = "metadata",
prune = "false"
)
</property>
The complete form definition is (the form contains a field - FIELD_A - outside repeated grid which is irrelevant to the problem):
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:saxon="http://saxon.sf.net/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:exf="http://www.exforms.org/exf/1-0">
<xh:head>
<xh:title>TestRepeat</xh:title>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true">
<!-- Main instance -->
<xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all">
<form>
<section-1>
<FIELD_A/>
<grid-3>
<grid-3-iteration>
<FIELD_B/>
<FIELD_C/>
</grid-3-iteration>
</grid-3>
</section-1>
</form>
</xf:instance>
<!-- Bindings -->
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
<xf:bind id="section-1-bind" name="section-1" ref="section-1">
<xf:bind id="FIELD_A-bind" name="FIELD_A" ref="FIELD_A"/>
<xf:bind id="grid-3-bind" ref="grid-3" name="grid-3">
<xf:bind id="grid-3-iteration-bind" ref="grid-3-iteration" name="grid-3-iteration">
<xf:bind id="FIELD_B-bind" ref="FIELD_B" name="FIELD_B"/>
<xf:bind id="FIELD_C-bind" ref="FIELD_C" name="FIELD_C"/>
</xf:bind>
</xf:bind>
</xf:bind>
</xf:bind>
<!-- Metadata -->
<xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>OAED</application-name>
<form-name>TestRepeat</form-name>
<title xml:lang="en">TestRepeat</title>
<description xml:lang="en"/>
<singleton>false</singleton>
</metadata>
</xf:instance>
<!-- Attachments -->
<xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all">
<attachments>
<css mediatype="text/css" filename="" size=""/>
<pdf mediatype="application/pdf" filename="" size=""/>
</attachments>
</xf:instance>
<!-- All form resources -->
<!-- Don't make readonly by default in case a service modifies the resources -->
<xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
<resources>
<resource xml:lang="en">
<FIELD_B>
<label>FIELD_B</label>
<hint/>
</FIELD_B>
<FIELD_C>
<label>FIELD_C</label>
<hint/>
</FIELD_C>
<section-1>
<label>Untitled Section</label>
</section-1>
<FIELD_A>
<label>FIELD_A</label>
<hint/>
</FIELD_A>
</resource>
</resources>
</xf:instance>
<!-- Utility instances for services -->
<xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
<request/>
</xf:instance>
<xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
<response/>
</xf:instance>
<xf:instance xxf:readonly="true" id="grid-3-template">
<grid-3-iteration>
<FIELD_B/>
<FIELD_C/>
</grid-3-iteration>
</xf:instance>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:xbl="http://www.w3.org/ns/xbl">
<fr:section id="section-1-control" bind="section-1-bind">
<xf:label ref="$form-resources/section-1/label"/>
<fr:grid>
<xh:tr>
<xh:td>
<xf:input id="FIELD_A-control" bind="FIELD_A-bind">
<xf:label ref="$form-resources/FIELD_A/label"/>
<xf:hint ref="$form-resources/FIELD_A/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
<xh:td/>
</xh:tr>
</fr:grid>
<fr:grid id="grid-3-grid" bind="grid-3-bind" repeat="content" min="1"
template="instance('grid-3-template')">
<xh:tr>
<xh:td>
<xf:input id="FIELD_B-control" bind="FIELD_B-bind">
<xf:label ref="$form-resources/FIELD_B/label"/>
<xf:hint ref="$form-resources/FIELD_B/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
<xh:td>
<xf:input id="FIELD_C-control" bind="FIELD_C-bind">
<xf:label ref="$form-resources/FIELD_C/label"/>
<xf:hint ref="$form-resources/FIELD_C/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
</xh:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
I do reproduce this, and this appears to be an oversight. Control data is grouped to optimize the output size, but I now see that that can cause problems!
I am not sure that it is possible to infer the order properly given the current structure. I added an issue about this.

Orbeon get documentId

I was interested in getting the documentId when submitting a form and link it to an user (i.e. by the email that is on a mandatory field of the form). The idea is to also call a webservice and send both fields to have this relationship. For now, I want to see this value in a field.
First of all, I have found that I can achieve this using xxforms:instance('fr-parameters-instance')/document but I have not success.
After this, I see here that now (I am using Orbeon 4.9) is changed to fr:document-id() but seems that I am still not able to see the document id in a simple field of the form. Bassically, something like:
<xf:action ev:event="xforms-submit">
<xf:setvalue ref="instance('fr-form-instance')/somefield" value="fr:document-id()"/>
</xf:action>
Simple example created with Form Builder:
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:saxon="http://saxon.sf.net/"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder">
<xh:head>
<xh:title>Send OrbeonID</xh:title>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true">
<!-- Main instance -->
<xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all">
<form>
<section-1>
<control-1/>
</section-1>
</form>
</xf:instance>
<!-- Bindings -->
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
<xf:bind id="section-1-bind" name="section-1" ref="section-1">
<xf:bind id="control-1-bind" name="control-1" ref="control-1"/>
</xf:bind>
</xf:bind>
<!-- Metadata -->
<xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>Biit</application-name>
<form-name>SendOrbeonID</form-name>
<title xml:lang="en">Send OrbeonID</title>
<description xml:lang="en"/>
<singleton>false</singleton>
</metadata>
</xf:instance>
<!-- Attachments -->
<xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all">
<attachments>
<css mediatype="text/css" filename="" size=""/>
<pdf mediatype="application/pdf" filename="" size=""/>
</attachments>
</xf:instance>
<!-- All form resources -->
<!-- Don't make readonly by default in case a service modifies the resources -->
<xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
<resources>
<resource xml:lang="en">
<section-1>
<label>Untitled Section</label>
</section-1>
<control-1>
<label>Write something:</label>
<hint/>
<alert/>
</control-1>
</resource>
</resources>
</xf:instance>
<!-- Utility instances for services -->
<xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
<request/>
</xf:instance>
<xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
<response/>
</xf:instance>
<!-- Form is sent -->
<xf:action ev:event="xforms-submit">
<xf:setvalue ref="instance('fr-form-instance')/section-1/control-1" value="fr:document-id()"/>
</xf:action>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline">
<fr:section id="section-1-control" bind="section-1-bind">
<xf:label ref="$form-resources/section-1/label"/>
<fr:grid>
<xh:tr>
<xh:td>
<xf:input id="control-1-control" bind="control-1-bind">
<xf:label ref="$form-resources/control-1/label"/>
<xf:hint ref="$form-resources/control-1/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
<xh:td/>
</xh:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
Theorically, If I fill up the input field and press the submit or save button, the field must be updated with the document id. But I am not able to see any value.
The good news is that the document id is already sent as a URL parameter by default. The URL parameter name is document. See also the relevant documentation.
At the end the way I have found to send the document Id is changing the behaviour of the buttons in Orbeon.
In the save as draft button:
<property as="xs:string" name="oxf.fr.detail.process.save-draft.*.*">
save
then send("oxf.fr.detail.save-draft.success")
then success-message("save-draft-success")
recover error-message("database-error")
</property>
And define the send action to somewhere outside of Orbeon:
<property as="xs:boolean" name="oxf.fr.detail.new.accept-post.*.*" value="true" />
<property as="xs:string" name="oxf.fr.detail.save-draft.success.uri.*.*" value="http://localhost:8080/get-id.jsp?document={xxf:instance('fr-parameters-instance')/document}"/>
<property as="xs:string" name="oxf.fr.detail.save-draft.success.method.*.*" value="post"/>
The JSP page get-id.jsp now is executed each time that the user save the draft of the form, but the browser is not redirected to the JSP page.
Changing to use a webservice or other action must be easy.
When you set your form builder controls calculated value to
xxf:instance('fr-parameters-instance')/document
you can get the document id.

Managing repeatable sections through events with orbeon

I found a few questions related to my problem (Orbeon index of repeat in repeatable section, Orbeon relevant properties and Orbeon nested repeats), but I couldn't get any of them to work properly.
I define a repeatable section with a couple of questions inside and a some relevant rules. I also define some events to manage the visibility of the questions. The problem appears when I create several repeated groups. When I select one of the answers, the relevant rules and the events are launched for all the questions with the same xpath route.
So, my question is: Is there a way to manage the same events ans the same relevant rules for repeatable sections?. That is, could I define some kind of dynamic route based on the index of the section that the user is selecting at the moment and use it in the relevant rules and the events?
The complete code used for the example is below:
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:saxon="http://saxon.sf.net/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude">
<xh:head>
<xh:meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<xh:title>Test_repeatable</xh:title>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true">
<xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>Test_app</application-name>
<form-name>Test_repeatable_v1</form-name>
<title xml:lang="en">Test_repeatable</title>
<description xml:lang="en">Description of the form.</description>
<singleton>false</singleton>
</metadata>
</xf:instance>
<xf:instance id="fr-form-instance">
<form>
<Category>
<Group>
<Group-iterator>
<Question/>
<Question2/>
<Question3/>
</Group-iterator>
</Group>
</Category>
</form>
</xf:instance>
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
<xf:bind id="Category-bind" name="Category" ref="/form/Category">
<xf:bind id="Group-bind" name="Group" ref="/form/Category/Group">
<xf:bind id="Group-iterator-bind" name="Group-iterator"
ref="/form/Category/Group/Group-iterator">
<xf:bind id="Question-bind" name="Question" ref="Question" required="true()"/>
<xf:bind id="Question2-bind"
name="Question2"
readonly="false"
ref="Question2"
relevant="/form/Category/Group/Group-iterator/Question='Answer'"
required="true()"/>
<xf:bind id="Question3-bind"
name="Question3"
readonly="false"
ref="Question3"
relevant="/form/Category/Group/Group-iterator/Question='Answer2' or instance('visible')/Group/Group-iterator/Question2 != 'false' "
required="true()"/>
</xf:bind>
</xf:bind>
</xf:bind>
</xf:bind>
<xf:instance id="fr-form-attachments">
<attachments>
<css filename="" mediatype="text/css" size=""/>
<pdf filename="" mediatype="application/pdf" size=""/>
</attachments>
</xf:instance>
<xf:instance id="fr-form-resources" xxf:readonly="false">
<resources>
<resource xml:lang="en">
<Category>
<label>Category</label>
<hint/>
<alert/>
<Group>
<label>Group</label>
<hint/>
<alert/>
<Question>
<label>Question</label>
<hint/>
<alert/>
<item>
<label>Answer</label>
<hint/>
<value>Answer</value>
</item>
<item>
<label>Answer2</label>
<hint/>
<value>Answer2</value>
</item>
</Question>
<Question2>
<label>Question2</label>
<hint/>
<alert/>
</Question2>
<Question3>
<label>Question3</label>
<hint/>
<alert/>
</Question3>
</Group>
</Category>
</resource>
</resources>
</xf:instance>
<xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
<request/>
</xf:instance>
<xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
<response/>
</xf:instance>
<xf:instance xxf:readonly="true" id="Group-template">
<Group-iterator>
<Question/>
<Question2/>
<Question3/>
</Group-iterator>
</xf:instance>
<!-- Keep track of visible/hidden status -->
<xf:instance id="visible">
<visible>
<Category>0</Category>
<Group>
<Group-iterator>
<Question>false</Question>
<Question2>false</Question2>
<Question3>false</Question3>
</Group-iterator>
</Group>
</visible>
</xf:instance>
<!-- Change the visibility status for 'Question'. -->
<xf:setvalue ev:event="xforms-enabled" observer="Question-control"
ref="instance('visible')/Group/Group-iterator/Question"
value="'true'"/>
<xf:setvalue ev:event="xforms-disabled" observer="Question-control"
ref="instance('visible')/Group/Group-iterator/Question"
value="'false'"/>
<!-- Update category showed elements count for 'Question'. -->
<xf:setvalue ev:event="xforms-enabled" observer="Question-control"
ref="instance('visible')/Category"
value="instance('visible')/Category + 1"/>
<xf:setvalue ev:event="xforms-disabled" observer="Question-control"
ref="instance('visible')/Category"
value="instance('visible')/Category - 1"/>
<!-- Change the visibility status for 'Question2'. -->
<xf:setvalue ev:event="xforms-enabled" observer="Question2-control"
ref="instance('visible')/Group/Group-iterator/Question2"
value="'true'"/>
<xf:setvalue ev:event="xforms-disabled" observer="Question2-control"
ref="instance('visible')/Group/Group-iterator/Question2"
value="'false'"/>
<!-- Update category showed elements count for 'Question2'. -->
<xf:setvalue ev:event="xforms-enabled" observer="Question2-control"
ref="instance('visible')/Category"
value="instance('visible')/Category + 1"/>
<xf:setvalue ev:event="xforms-disabled" observer="Question2-control"
ref="instance('visible')/Category"
value="instance('visible')/Category - 1"/>
<!-- Change the visibility status for 'Question3'. -->
<xf:setvalue ev:event="xforms-enabled" observer="Question3-control"
ref="instance('visible')/Group/Group-iterator/Question3"
value="'true'"/>
<xf:setvalue ev:event="xforms-disabled" observer="Question3-control"
ref="instance('visible')/Group/Group-iterator/Question3"
value="'false'"/>
<!-- Update category showed elements count for 'Question3'. -->
<xf:setvalue ev:event="xforms-enabled" observer="Question3-control"
ref="instance('visible')/Category"
value="instance('visible')/Category + 1"/>
<xf:setvalue ev:event="xforms-disabled" observer="Question3-control"
ref="instance('visible')/Category"
value="instance('visible')/Category - 1"/>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel">
<fr:section bind="Category-bind"
id="Category-control">
<xf:label mediatype="text/html"
ref="instance('fr-form-resources')/resource/Category/label"/>
<xf:hint ref="instance('fr-form-resources')/resource/Category/hint"/>
<xf:alert ref="instance('fr-form-resources')/resource/Category/alert"/>
<fr:section bind="Group-bind"
id="Group-control"
max="100"
min="1"
repeat="content"
template="instance('Group-template')">
<xf:label mediatype="text/html"
ref="instance('fr-form-resources')/resource/Category/Group/label"/>
<xf:hint ref="instance('fr-form-resources')/resource/Category/Group/hint"/>
<xf:alert ref="instance('fr-form-resources')/resource/Category/Group/alert"/>
<xh:tr>
<xh:td>
<xf:select1 appearance="full" bind="Question-bind"
id="Question-control">
<xf:label mediatype="text/html"
ref="instance('fr-form-resources')/resource/Category/Group/Question/label"/>
<xf:hint ref="instance('fr-form-resources')/resource/Category/Group/Question/hint"/>
<xf:alert ref="instance('fr-form-resources')/resource/Category/Group/Question/alert"/>
<xf:itemset
ref="instance('fr-form-resources')/resource/Category/Group/Question/item">
<xf:label ref="label"/>
<xf:value ref="value"/>
<xf:hint ref="hint"/>
</xf:itemset>
</xf:select1>
</xh:td>
</xh:tr>
<xh:tr>
<xh:td>
<xf:input bind="Question2-bind"
id="Question2-control">
<xf:label mediatype="text/html"
ref="instance('fr-form-resources')/resource/Category/Group/Question2/label"/>
<xf:hint ref="instance('fr-form-resources')/resource/Category/Group/Question2/hint"/>
<xf:alert ref="instance('fr-form-resources')/resource/Category/Group/Question2/alert"/>
</xf:input>
</xh:td>
</xh:tr>
<xh:tr>
<xh:td>
<xf:input bind="Question3-bind"
id="Question3-control">
<xf:label mediatype="text/html"
ref="instance('fr-form-resources')/resource/Category/Group/Question3/label"/>
<xf:hint ref="instance('fr-form-resources')/resource/Category/Group/Question3/hint"/>
<xf:alert ref="instance('fr-form-resources')/resource/Category/Group/Question3/alert"/>
</xf:input>
</xh:td>
</xh:tr>
</fr:section>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
EDIT: A little explanation of the code above.
This example has two sections, one normal and inside of it one repeatable.
Inside the repeatable section there are three questions. The first question has two answers. When I select the first answer the form runner must show the questions two and three. When the second answer is selected the runner must show only the third question. This works correctly if I only have one repeatable section.
The problem appears when I create a new repeatable section. If I select the answer one of the first question, the following questions are shown at the same time in both repeatable groups. The same when I select answer two.
So the question is: Is there a way to tell the Orbeon runner that it must apply the relevant rules only to the repeatable group where the event happens?
EDIT 2: Ok, your solution is working perfect in the case of 'Question2'.
The problem comes with Question 3. If you check the code for Question3 you can see that I try to access also another instance:
relevant="$Question='Answer2' or instance('visible')/Group/Group-iterator/Question2 != 'false' "
The 'visible' instance is not related with any control or bind, is only used for storing an internal value for the questions and is updated using xforms events, as you can see in the code below:
<xf:setvalue ev:event="xforms-enabled"
observer="Question2-control"
ref="instance('visible')/Group/Group-iterator/Question2"
value="'true'"/>
Thus, my new question is: Is there a way to store different values for different iterations of a repeatable section in a static instance and accessing them using a dynamic path (like in your first response with the $)?
If in the xf:bind for Question2 you want to refer to the value of Question in the same iteration, then just use $Question. In fact, as a rule of thumb, you can always refer to the value of another control gaga as $gaga, and trust that the right thing will happen. (At least it will in most cases.) So, your xf:bind for Question2 will become:
<xf:bind id="Question2-bind" name="Question2"
readonly="false" ref="Question2"
relevant="$Question='Answer'"
required="true()"/>

Fomat output of dollars and cents field in orbeon

How may I specifiy that the field that is to hold the sum of two other fields should be able to display a value higher than $999.999.99 as dollars and cents?
The source code of the form is below.
When I test the form, I enter 999999.99 in amount_1 and it displays $999,999.99. I enter .01 in amount_2. The total_amount field displays $1.0E. I want it to display $1,000,000.00 and gives a missing or incorrect value error.
I have tried using a Text Output control, but have the same problem.
I am writing a banking application that uses Form Runner to request data from bank agents, so floating point fields are not accurate enough.
I have looked at several posts that seem related to fomatting output, but have seen none that helped. I am using the default output format for the various data types.
Thank you for your help.
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:exforms="http://www.exforms.org/exf/1-0"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:saxon="http://saxon.sf.net/"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<xhtml:head>
<xhtml:title>Format Test Form</xhtml:title>
<xforms:model id="fr-form-model">
<!-- Main instance -->
<xforms:instance id="fr-form-instance">
<form>
<section-1>
<amount_1/>
<amount_2/>
<total_amount/>
</section-1>
</form>
</xforms:instance>
<!-- Bindings -->
<xforms:bind id="fr-form-binds" nodeset="instance('fr-form-instance')">
<xforms:bind id="section-1-bind" nodeset="section-1">
<xforms:bind id="amount_1-bind" nodeset="amount_1" type="xforms:decimal" name="amount_1"/>
<xforms:bind id="amount_2-bind" nodeset="amount_2" type="xforms:decimal" name="amount_2"/>
<xforms:bind id="total_amount-bind" nodeset="total_amount" name="total_amount"
type="xforms:decimal"
calculate="if ($amount_1 castable as xs:double and $amount_2 castable as xs:double) then $amount_1 + $amount_2 else 123456789012345"/>
</xforms:bind>
</xforms:bind>
<!-- Metadata -->
<xforms:instance id="fr-form-metadata" xxforms:readonly="true">
<metadata>
<application-name>BusTravelApp</application-name>
<form-name>FormatTestForm</form-name>
<title xml:lang="en">Format Test Form</title>
<description xml:lang="en"/>
<author/>
<logo mediatype="" filename="" size=""/>
</metadata>
</xforms:instance>
<!-- Attachments -->
<xforms:instance id="fr-form-attachments">
<attachments>
<css mediatype="text/css" filename="" size=""/>
<pdf mediatype="application/pdf" filename="" size=""/>
</attachments>
</xforms:instance>
<!-- All form resources -->
<!-- Don't make readonly by default in case a service modifies the resources -->
<xforms:instance id="fr-form-resources" xxforms:readonly="false">
<resources>
<resource xml:lang="en">
<amount_1>
<label>Amount 1</label>
<hint/>
<help/>
<alert/>
</amount_1>
<amount_2>
<label>Amount 2</label>
<hint/>
<help/>
<alert/>
</amount_2>
<total_amount>
<label>Total Amount</label>
<hint/>
<help/>
<alert/>
</total_amount>
<section-1>
<label>Section-1</label>
<help/>
</section-1>
</resource>
</resources>
</xforms:instance>
<!-- Utility instances for services -->
<xforms:instance id="fr-service-request-instance" xxforms:exclude-result-prefixes="#all">
<request/>
</xforms:instance>
<xforms:instance id="fr-service-response-instance" xxforms:exclude-result-prefixes="#all">
<response/>
</xforms:instance>
</xforms:model>
</xhtml:head>
<xhtml:body>
<fr:view>
<xforms:label ref="instance('fr-form-metadata')/title"/>
<fr:body>
<fr:section id="section-1-section" bind="section-1-bind">
<xforms:label ref="$form-resources/section-1/label"/>
<xforms:help ref="$form-resources/section-1/help"/>
<fr:grid columns="3">
<xhtml:tr>
<xhtml:td>
<fr:currency xmlns="http://orbeon.org/oxf/xml/form-builder"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary"
bind="amount_1-bind"
id="amount_1-control">
<xforms:label ref="$form-resources/amount_1/label"/>
<xforms:hint ref="$form-resources/amount_1/hint"/>
<xforms:help ref="$form-resources/amount_1/help"/>
<xforms:alert ref="$fr-resources/detail/labels/alert"/>
</fr:currency>
</xhtml:td>
<xhtml:td>
<fr:currency xmlns="http://orbeon.org/oxf/xml/form-builder"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary"
bind="amount_2-bind"
id="amount_2-control">
<xforms:label ref="$form-resources/amount_2/label"/>
<xforms:hint ref="$form-resources/amount_2/hint"/>
<xforms:help ref="$form-resources/amount_2/help"/>
<xforms:alert ref="$fr-resources/detail/labels/alert"/>
</fr:currency>
</xhtml:td>
<xhtml:td>
<fr:currency xmlns="http://orbeon.org/oxf/xml/form-builder"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary"
id="total_amount-control"
bind="total_amount-bind">
<xforms:label ref="$form-resources/total_amount/label"/>
<xforms:hint ref="$form-resources/total_amount/hint"/>
<xforms:help ref="$form-resources/total_amount/help"/>
<xforms:alert ref="$fr-resources/detail/labels/alert"/>
</fr:currency>
</xhtml:td>
</xhtml:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xhtml:body>
Use xforms:output and use formatting the value something like this.
<xforms:output bind="total_amount-bind" xxforms:format="format-number(., $ ###,###.##)" />
References:
http://wiki.orbeon.com/forms/doc/developer-guide/xforms-other-extensions#TOC-The-xxforms:format-attribute
http://www.w3schools.com/xsl/func_formatnumber.asp

Resources