Skip to main content

Access current store element from Webedit script/workflow

Comments

1 comment

  • Zendesk API User
    Author: MichaelaReydt - 3/18/2013 10:02

    Hello,

    I'm not sure, if the following is the answer to your question... You want to start a workflow inside the WebClient and this workflow uses a script, which references a Executable? Inside the Executable you need the current object on which the workflow was startet?

    I tested this with a very short example.

    My workflow looks like this:

    My script "communitytest" contains two lines:

    #!executable-class

    com.espirit.moddev.community.test.CommunityTestExecutable

    and my Executable has the following code:

    package com.espirit.moddev.community.test;

    import de.espirit.firstspirit.access.script.Executable;

    import de.espirit.firstspirit.access.script.ExecutionException;

    import de.espirit.firstspirit.access.store.StoreElement;

    import de.espirit.firstspirit.access.store.templatestore.WorkflowScriptContext;

    import de.espirit.firstspirit.ui.operations.RequestOperation;

    import de.espirit.firstspirit.agency.OperationAgent;

    import java.io.Writer;

    import java.util.Map;

    /*

    * Example of a simple executable class

    *

    * Script:

    * #!executable-class

    * com.espirit.moddev.community.test.CommunityTestExecutable

    */

    public class CommunityTestExecutable implements Executable {

        public static final Class<?> LOGGER = CommunityTestExecutable.class;

        public Object execute(Map<String, Object> params) throws ExecutionException {

            final WorkflowScriptContext wsc = (WorkflowScriptContext) params.get("context");

           StoreElement storeElement = wsc.getStoreElement();

            //show a dialog

            OperationAgent operationAgent = wsc.requireSpecialist(OperationAgent.TYPE);

            //show the data of the current object inside a diaolog

            RequestOperation requestOperation = operationAgent.getOperation(RequestOperation.TYPE);

            requestOperation.setKind(RequestOperation.Kind.INFO);

            requestOperation.setTitle("current Object");

            requestOperation.perform("current Object: " + storeElement);

            return true;

        }

        public Object execute(Map<String, Object> context, Writer out, Writer err) throws ExecutionException {

            return execute(context);

        }

    }

    Starting the workflow inside the WebClient at the homepage of the Mithras-project shows me this dialog:

    0

Please sign in to leave a comment.