Dear Team,
I have created custom workflow for document review and approval for Group,
for that i have written script, but script not working properly.
please refer below script:
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "activiti$activitiReview";
workflow.parameters["bpm:workflowDescription"] = "Please assign approver for "+ document.name;
workflow.parameters["bpm:groupAssignee"] = people.getGroup("GROUP_cadgroup");
workflow.parameters["bpm:sendEMailNotifications"] = true;
workflow.execute(document);
Please suggest!
have you set ${bpm_groupAssignee} in your user task group assignment. Also please provide more info - what is not working properly? are you getting any error on executing your action?
Do you get any errors? Is it that workflow getting started but not getting assigned to group or workflow itself is not getting started? Can you please share more details..
Hi,
issue is when I have log in with Admin
1. I can able to make changes in file
2. a can able to upload file
3. mail is successfully sent to users in group
but when i log in with user credentials,
above 3 points are not working.
Can u suggest?
I don't know if it is problem with some roles or permission. But I can suggest some workaround you can try if it is working or not.. From this code you will be able to run your script as admin user irrespective of the login user.
Add following java file at repo side as RunAsAdminUtil.java
package com.demo.platformsample;
import org.alfresco.repo.jscript.BaseScopableProcessorExtension;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Scriptable;/**
*
* Purpose: Creates javaScript function to run any javaScript code as administrator
*
*/
public class RunAsAdminUtil extends BaseScopableProcessorExtension {
/**
* This method runs javascript function with Admin privileges
*
* @param func
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public void runAsAdmin(final Function func) {
final Context cx = Context.getCurrentContext();
final Scriptable scope = getScope();
RunAsWork raw = new RunAsWork() {
public Object doWork() throws Exception {
func.call(cx, scope, scope, new Object[] {});
return null;
}
};
AuthenticationUtil.runAs(raw, AuthenticationUtil.getSystemUserName());
}
}
In service-context.xml register this class like this..
<bean id="runAsAdminUtil" parent="baseJavaScriptExtension"
class="com.demo.platformsample.RunAsAdminUtil">
<property name="extensionName">
<value>runAsAdminUtil</value>
</property>
</bean>
And user your code something like this..
function forRunAsAdmin(){
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "activiti$activitiReview";
workflow.parameters["bpm:workflowDescription"] = "Please assign approver for "+ document.name;
workflow.parameters["bpm:groupAssignee"] = people.getGroup("GROUP_cadgroup");workflow.parameters["bpm:sendEMailNotifications"] = true;
workflow.execute(document);}
runAsAdminUtil.runAsAdmin(forRunAsAdmin);
By doing this you will be able to run your script as admin user.
Hope it works for you.
J’ai créé un flux de travail personnalisé pour examiner et approuver des documents, mais l’envoi de courrier aux utilisateurs ne fonctionne pas
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.