Can the "transition" attribute value of the form be defined according to a certain condition?

When I write a form, I want to define the “transition” attribute value according to a certain condition. For example, if “map” is not empty, “transition = updatexxx”, if it is empty, “transition = createxxx”. What should I do?

1 Like

You can use variable in transition such as transition="${myTransition}"

1 Like

be careful!!!
the variables have to be defined in an <always action>. Here are the docs for reference (i never though i would be saying these words regarding moqui).

Tag name: always-actions
Description : These actions always run when this screen appears in a screen path, including both screen rendering and transition running. One difference between this and the pre-actions element is that this runs before transitions are processed while pre-actions do not. The always-actions also run for all screens in a path while the pre-actions only run for screens that will be rendered.

1 Like

Thank you for your reply!

Thank you for your reply! I will pay attention to what you said.

FWIW, the transitions can have an actions section…and conditional-response…i.e. if you want to return to different locations. It may be more clear to handle the conditional action inside a single transition.

One thing to remember…Moqui effectively adds in-map=“context” and out-map=“context” to the service-call if it is there instead of an actions block. If using an actions-block, you need to control the in-map and out-map yourself

e.g. from BulkPaymentCheck.xml in SimpleScreens

    <transition name="handleSubmit">
            <if condition="setDelivered"><then>
                <service-call name="update#mantle.account.payment.Payment" in-map="context + [statusId:'PmntDelivered']" multi="true"/>
            <else-if condition="setAuthorized">
                <service-call name="update#mantle.account.payment.Payment" in-map="context + [statusId:'PmntAuthorized']" multi="true"/>
            </else-if><else-if condition="setRefNums">
                <service-call name="mantle.account.PaymentServices.assign#BankAccountCheckNumber" in-map="context" multi="true"/>
                    paymentIds = new StringBuilder()
                    for (int i = 0; ; i++) {
                        if ((context.get("_useRowSubmit") == "true" || context.get("_useRowSubmit_" + i) == "true")
                                && context.get("_rowSubmit_" + i) != "true") continue
                        String curKey = "paymentId_" + i
                        if (context.containsKey(curKey)) {
                            if (paymentIds.length() > 0) paymentIds.append(",")
                        } else { break }
        <conditional-response url="${ec.web.getWebappRootUrl(false, null)}/fop/apps/${appRoot}/Accounting/Payment/PaymentCheck" url-type="plain">
            <parameter name="paymentIds" from="paymentIds"/><parameter name="filename" value="PaymentChecks.pdf"/>
        <conditional-response url="${ec.web.getWebappRootUrl(false, null)}/fop/apps/${appRoot}/Accounting/Payment/PaymentDetail" url-type="plain">
            <parameter name="paymentIds" from="paymentIds"/><parameter name="filename" value="PaymentDetails.pdf"/>
        <default-response url="."/>

Also, separately, note that store#xxx would do create#xxx or update#xxx where xxx is an entity name, so you might be able to just replace it with that instead if that is all you are trying to do.


Thank you for your reply!
I will pay attention to what you said.