Hi,
I'm trying to work out how to get to the instance data in the form from the button. The scenario is that we have several classes of users, each of whom must add their approval to a form before it gets sent to a workflow engine for action. What I want is to have some logic that checks the status of the form based on the content of a submission_status field from the form (not_submitted, awaiting_approval), and based on the current status it 'reconfigures' what the Submit button does, and also updates the instance data in the form. What I'm trying to achieve is something along the lines of: <submit button is pressed by user> IF submission_status = "not submitted" THEN SET submission_status = 'awaiting_approval' AND SET submission_reference=orbeon_document_ID AND EMAIL submission_approver_notification AND EMAIL submitter ELSEIF submission_status='awaiting_approval' THEN SET submission_status='approved' AND AND submit completed form to web service ENDIF Any advice welcome... |
Administrator
|
Hi James,
When a button is pressed, it runs a "process", and you can customize what the process does through properties. Processes support conditions (if statements based on values in the form), and can set values in the form data (see the xf:setvalue action), so you should be able to do what you're describing with a process. If you've never done anything with processes in Orbeon Forms, you might first need to do a little bit of reading, but everything you need should be in this documentation: https://github.com/orbeon/orbeon-forms/wiki/Form-Runner-~-Buttons-and-Processes You'll let us know how this works for you. Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Finally managed to get back to this.
I created a process attached to the send button: <property as="xs:string" name="oxf.fr.detail.process.send.Customer.*"> if ("//Nt-Status='NOT SUBMITTED'") then (require-valid then xf:setvalue(ref="//Nt-Status", value="SUBMITTED") then xf:setvalue(ref="//SU-Reference", value="xxf:instance('fr-parameters-instance')/document") then save then pdf then email then navigate(uri="http://localhost:8080/manager")) else error-message(message="This form has already been submitted") </property> NT-Status is a text output field on the form that shows the customer the status of their form (NOT SUBMITTED, SUBMITTED, AWAITING VALIDATION, etc). SU-Reference is a reference number on the form that gives the customer a meaningful unique reference should they need to call the helpdesk. What I wanted to achieve was : If form not already submitted Update the status of the form to 'Submitted' Update the reference embedded in the form to the document ID Create a PDF Email the validator with the form details so they can complete their work Drop out to a meaningful page (which will be a logout, but for now is the Tomcat manager console, just to prove I managed to get it to go somewhere else). The process looks like it ought to work, but the stack trace below was what I got when I pressed the button. It's an error with no error message, so I'm having trouble working out what went wrong. 2015-02-23 10:44:49,547 INFO ProcessorService - /xforms-server - Received request 2015-02-23 10:44:49,563 INFO lifecycle - event: {"request": "424", "session": "9C0C8BC0FD07F4FCA6C3943B84D22EAD", "source": "xforms", "message": "ajax with update events", "uuid": "cd515766c3458daa16f1b9eac8e2a3ab5d49888c"} 2015-02-23 10:44:49,563 INFO lifecycle - event: {"request": "424", "session": "9C0C8BC0FD07F4FCA6C3943B84D22EAD", "source": "xforms", "message": "before document lock", "uuid": "cd515766c3458daa16f1b9eac8e2a3ab5d49888c"} 2015-02-23 10:44:49,563 INFO lifecycle - event: {"request": "424", "session": "9C0C8BC0FD07F4FCA6C3943B84D22EAD", "source": "xforms", "message": "got document lock", "path": "/xforms-server", "method": "POST", "uuid": "cd515766c3458daa16f1b9eac8e2a3ab5d49888c", "wait": "0"} 2015-02-23 10:44:49,681 INFO lifecycle - event: {"request": "424", "session": "9C0C8BC0FD07F4FCA6C3943B84D22EAD", "source": "fr", "message": "start: process", "uuid": "cd515766c3458daa16f1b9eac8e2a3ab5d49888c", "scope": "oxf.fr.detail.process", "name": "send"} 2015-02-23 10:44:49,691 ERROR XFormsServer - 2015-02-23 10:44:49,691 ERROR XFormsServer - +----------------------------------------------------------------------------------------------------------------------+ 2015-02-23 10:44:49,691 ERROR XFormsServer - |An Error has Occurred | 2015-02-23 10:44:49,691 ERROR XFormsServer - |----------------------------------------------------------------------------------------------------------------------| 2015-02-23 10:44:49,691 ERROR XFormsServer - |[No error message provided.] | 2015-02-23 10:44:49,691 ERROR XFormsServer - |----------------------------------------------------------------------------------------------------------------------| 2015-02-23 10:44:49,691 ERROR XFormsServer - |Application Call Stack | 2015-02-23 10:44:49,691 ERROR XFormsServer - |----------------------------------------------------------------------------------------------------------------------| 2015-02-23 10:44:49,691 ERROR XFormsServer - |----------------------------------------------------------------------------------------------------------------------| 2015-02-23 10:44:49,691 ERROR XFormsServer - |Exception: java.lang.NullPointerException | 2015-02-23 10:44:49,691 ERROR XFormsServer - |----------------------------------------------------------------------------------------------------------------------| 2015-02-23 10:44:49,691 ERROR XFormsServer - |.orbeon.oxf.xforms.function.xxforms.XXFormsInstance|iterate |XXFormsInstance.scala | 36| 2015-02-23 10:44:49,691 ERROR XFormsServer - |org.orbeon.saxon.expr.PathExpression |iterate |PathExpression.java | 636| 2015-02-23 10:44:49,691 ERROR XFormsServer - |org.orbeon.saxon.expr.CardinalityChecker |evaluateItem |CardinalityChecker.java | 259| 2015-02-23 10:44:49,691 ERROR XFormsServer - |org.orbeon.saxon.functions.StringFn |evaluateItem |StringFn.java | 41| 2015-02-23 10:44:49,691 ERROR XFormsServer - |org.orbeon.saxon.expr.Expression |iterate |Expression.java | 370| 2015-02-23 10:44:49,691 ERROR XFormsServer - |org.orbeon.saxon.sxpath.XPathExpression |iterate |XPathExpression.java | 141| 2015-02-23 10:44:49,691 ERROR XFormsServer - |org.orbeon.oxf.util.PooledXPathExpression |org$orbeon$oxf$util$PooledXPat|PooledXPathExpression.scala | 176| 2015-02-23 10:44:49,692 ERROR XFormsServer - |hExpression$$anonfun$evaluateSingleKeepItemOrNull$1|apply |PooledXPathExpression.scala | 103| 2015-02-23 10:44:49,692 ERROR XFormsServer - |hExpression$$anonfun$evaluateSingleKeepItemOrNull$1|apply |PooledXPathExpression.scala | 103| 2015-02-23 10:44:49,692 ERROR XFormsServer - |org.orbeon.oxf.util.DynamicVariable |withValue |DynamicVariable.scala | 42| 2015-02-23 10:44:49,692 ERROR XFormsServer - |org.orbeon.oxf.util.XPath$ |withFunctionContext |XPath.scala | 57| 2015-02-23 10:44:49,692 ERROR XFormsServer - |org.orbeon.oxf.util.PooledXPathExpression |evaluateSingleKeepItemOrNull |PooledXPathExpression.scala | 102| 2015-02-23 10:44:49,692 ERROR XFormsServer - |.util.XPathCache$$anonfun$evaluateSingleKeepItems$1|apply |XPathCache.scala | 160| 2015-02-23 10:44:49,692 ERROR XFormsServer - |.util.XPathCache$$anonfun$evaluateSingleKeepItems$1|apply |XPathCache.scala | 160| 2015-02-23 10:44:49,692 ERROR XFormsServer - |org.orbeon.oxf.util.XPathCache$ |withEvaluation |XPathCache.scala | 545| 2015-02-23 10:44:49,692 ERROR XFormsServer - |----------------------------------------------------------------------------------------------------------------------| 2015-02-23 10:44:49,692 ERROR XFormsServer - |Exception: org.orbeon.oxf.common.ValidationException | 2015-02-23 10:44:49,692 ERROR XFormsServer - |----------------------------------------------------------------------------------------------------------------------| 2015-02-23 10:44:49,692 ERROR XFormsServer - |org.orbeon.oxf.common.OrbeonLocationException$ |wrapException |OrbeonLocationException.scala | 60| 2015-02-23 10:44:49,692 ERROR XFormsServer - |org.orbeon.oxf.util.XPath$ |handleXPathException |XPath.scala | 304| 2015-02-23 10:44:49,692 ERROR XFormsServer - |org.orbeon.oxf.util.XPathCache$ |withEvaluation |XPathCache.scala | 548| 2015-02-23 10:44:49,692 ERROR XFormsServer - |org.orbeon.oxf.util.XPathCache$ |evaluateSingleKeepItems |XPathCache.scala | 159| 2015-02-23 10:44:49,692 ERROR XFormsServer - |org.orbeon.scaxon.XML$ |evalOne |XML.scala | 58| 2015-02-23 10:44:49,692 ERROR XFormsServer - |oxf.fr.process.XFormsActions$$anonfun$trySetvalue$1|apply |XFormsActions.scala | 67| 2015-02-23 10:44:49,692 ERROR XFormsServer - |scala.util.Try$ |apply |Try.scala | 161| 2015-02-23 10:44:49,692 ERROR XFormsServer - |org.orbeon.oxf.fr.process.XFormsActions$class |trySetvalue |XFormsActions.scala | 63| 2015-02-23 10:44:49,692 ERROR XFormsServer - |org.orbeon.oxf.fr.process.SimpleProcess$ |trySetvalue |SimpleProcess.scala | 35| |
Administrator
|
Thanks for the report. Issue identified and fixed:
https://github.com/orbeon/orbeon-forms/issues/2108 Which version of Orbeon Forms are you currently using? -Erik |
Erik,
Sorry, I didn't see your reply. I'm on 4.8.0 PE at the moment. Regards, James. |
Free forum by Nabble | Edit this page |