AnsweredAssumed Answered

Setting the workflow instance Initiator attribute in JS

Question asked by jyri.ahia@efektiry.fi on Dec 16, 2014
Hello,

I am starting new workflow instances with javascript in Alfresco share.

I would like to set the Initiator attribute of the workflow instance to a particular user.

I have tried to add the parameter like so:

var assigner = item.assocs["task:assigner"][0];

parameters["initiator"] = assigner;
parameters["bpm:initiator"] = assigner;

workflowAction.startWorkflow(paketti, parameters);

Also I tried to run parts of the code as another user with

public class Sudo extends BaseScopableProcessorExtension {
    public void sudo(final Function func, String userName) {
        final Context cx = Context.getCurrentContext();
        final Scriptable scope = getScope();

        RunAsWork<Object> raw = new RunAsWork<Object>() {
            public Object doWork() throws Exception {
                func.call(cx, scope, scope, new Object[] {});
                return null;
            }
        };
           
        AuthenticationUtil.runAs(raw, userName);
    }
}

But no help since I am not sure wich part I should run there? I tried to run this part workflowAction.startWorkflow(paketti, parameters);

I think that maybe you could change the Initiator parameter after the process is started?

Yours,

Jyri

Outcomes