Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processes: allow actions to return data #1688

Open
ebruchez opened this issue Apr 23, 2014 · 15 comments
Open

Processes: allow actions to return data #1688

ebruchez opened this issue Apr 23, 2014 · 15 comments

Comments

@ebruchez
Copy link
Collaborator

Internally, actions return Try[Any]. But send, in particular, could return data, including:

  • response XML
  • response text
  • response headers
  • etc.

We could see this as an immutable bag of parameters going through the process. send would be one of the few actions returning or updating the current bag. The parameters could be accessed from XPath expressions as variables or via functions (e.g. in conditions), or via parameters.

send then setvalue(ref = "/a/b/c", value = "$response-xml/*/foo")

See also discussion about calling a CMIS service and returning an id. This has also been discussed with a customer's RFE.

@ebruchez
Copy link
Collaborator Author

ebruchez commented Aug 5, 2014

Use case: return value from a service and call a JS function:

send(…) then script(xvt"alert('{$response-text}')")

Or something along those lines (the alert text would need to be escaped, in particular).

@ebruchez
Copy link
Collaborator Author

ebruchez commented Feb 7, 2017

We also need this for #2132 if we have a dialog asking for an email address which we want to pass to the email action.

  • we could have a set-var(name = "foo", value = ...) action which updates in-scope (immutable) variables
  • to take the result of an action, do `set-var(name = "foo") and the value will come from the preceding action
  • hopefully this is compatible with a future update to the process language using say let foo = ... (see also New syntax for simple processes #1255)

@avernet
Copy link
Collaborator

avernet commented Apr 13, 2018

+1 from customer, to be able retrieve an error message returned by a send() and use that message in an error-message().

@avernet
Copy link
Collaborator

avernet commented Nov 12, 2018

+1 from user for the same use case mentioned in the previous comment.

@avernet
Copy link
Collaborator

avernet commented Nov 28, 2018

+1 from user

@ebruchez
Copy link
Collaborator Author

ebruchez commented Dec 1, 2018

Also related to #224 and #3803: we'd like to clarify the source of a "set control value" action instead of implicitly considering that it comes from the service response.

Now if data is conceptually stored in vals accessible later in the process, what is the structure of that val? Is it a single XML document? This would be limiting. A service, for example, returns a status code, body, etc. So we need to know what datatypes are supported by a val. Probably that the following would make sense:

  • XPath item or sequence of items
  • hashmap (could be an XPath map)

If they are accessible with a $foo syntax, would you have to write map:get($foo, 'body') to deal with a response body?

@avernet
Copy link
Collaborator

avernet commented Feb 4, 2019

+1 from customer to access the result from send() and set the value of a field in the form with that message

@avernet
Copy link
Collaborator

avernet commented Apr 18, 2019

+1 from user

@ykowalewski
Copy link

+1 from me to have such feature

@ebruchez
Copy link
Collaborator Author

ebruchez commented Sep 11, 2019

+1 from customer for accessing a send's HTTP status code.

@ebruchez
Copy link
Collaborator Author

Also related to the new "action syntax", which needs something similar.

@avernet
Copy link
Collaborator

avernet commented May 16, 2020

+1 from user

@avernet
Copy link
Collaborator

avernet commented May 11, 2021

+1 from customer who would like to see the save action, which in their case is calling their own implementation of the persistence API, to be able to return an error message, which could then be made to be shown to end-users

@avernet
Copy link
Collaborator

avernet commented Jul 7, 2021

+1 from user

For send(), if one needs to access the document returned by the service, and XML or JSON is returned, as a workaround, it can be accessed with xxf:instance('fr-send-submission-response').

@avernet
Copy link
Collaborator

avernet commented Jul 12, 2021

Example:

<property as="xs:string"  name="oxf.fr.detail.process.submit.*.*">
    send(
        method  = "GET",
        uri     = "https://www.w3schools.com/XML/simple.xml",
        replace = "instance"
    )
    then success-message(
        message = "First item on the menu: {xxf:instance('fr-send-submission-response')/food[1]/name}"
    )
</property>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants