cancel
Showing results for 
Search instead for 
Did you mean: 

Create rule for a simple workflow

samar
Champ in-the-making
Champ in-the-making
Hi

I want to use Alfresco Action Web Service to create a simple workflow.
The steps I perform in GUI on the Alfresco Client portlet are:
    - Go to  My Alfresco > My folder(space)
    - Choose More Actions > Manage Content Rules
    - Choose Create Rule
   1- Select Conditions:
    Select Condition->'All Items'
          Click 'Add to List'
   2- Select Actions:
      
    Select Action->'Add simple workfolw to item'
          Click 'Set Values and Add'
             Set action values:
             - Approve Flow
             Name for approve step: 'request Approval'
             Select 'Move' radio button
             Select the destination folder
             -Reject Flow
             Choose 'No' reject flow
   3- Details
    Type: 'Update'
          Tilte: 'test'
          Description: ''
          choose 'Apply rule to sub spaces' only
I need to write Java code to perform the steps above,
my code is something like:
      Rule rule1 = new Rule();
      Action action1 = new Action();
      Condition condition1 = new Condition();
      
      Reference actionReference1; // = ref to My folder
      NamedValue[] parameters1; // = "All Items"
      
      condition1.setParameters(parameters1);
      action1.setConditions(0, condition1);

      action1.setActionName("request Approval");
      //action1.set choose 'Move item'?
      action1.setActionReference(actionReference1);
      rule1.setRuleTypes(0,"update");
      rule1.setAction(action1);
      //apply rule to subspaces

I cannot find
    how to set the condition to "All items"?
      how to make the Action to move the item from My folder to destination folder?
      are rule types defined constants somewhere?
      how to apply rule to subspaces?
Thank you,
5 REPLIES 5

samar
Champ in-the-making
Champ in-the-making
Hi

I found the rule constants in org.alfresco.service.cmr.rule.RuleType

My other 3 questions are valid..

Thanks

samar
Champ in-the-making
Champ in-the-making
Hi all,

This is the latest code I could reach:

      Rule rule1 = new Rule();
      Action action1 = new Action();
      Action action2 = new Action();
      Condition condition1 = new Condition();
      Reference actionReference1 = new Reference();
      //set its value to Drafts > Writer_Samar
      Reference actionReference2 = new Reference();
      //set its value to Pending Approval > Editor_Samar > Writer_Samar

      NamedValue[] parameters1 = new NamedValue[] {
            Utils.createNamedValue(Constants.PROP_NAME, "All Items") };//check?
      
      condition1.setParameters(parameters1);      
      
      action1.setTitle("simple-workflow");//correct attribute meaning?
      action1.setConditions(0, condition1);
      action1.setActionReference(actionReference1);
      
      //action2.setDescription('Move item') ? [use CMLMove] ?
      action2.setTitle("approve-step");
      action2.setActionName("request Approval");
      action2.setActionReference(actionReference2);
      
      action1.setActions(0, action2);//check?
      
      rule1.setRuleTypes(0,"update");
      rule1.setAction(action1);
      //apply rule to subspaces

I still cannot find:
    how to set the condition to apply to "All Items"?
    which Action attribute should be set to "simple-workflow"?
    which Action attribute "Move item to 'Writer_Samar' if 'request Approval' action is taken"?
    not sure which Action attribute defines the approve flow
    how to apply rule to subspaces?
Any help would be appreciated,
Thank you Smiley Happy

rulo
Champ in-the-making
Champ in-the-making
Hi Samar…did you found any solution?

cbz47a
Champ in-the-making
Champ in-the-making
Is there any java sample (client code) available which can create a simple workflow using  Alfresco web service APIs ???

andresaimar
Champ in-the-making
Champ in-the-making
Samar did you get the solution?
I am currently trying to create a rule but I always got a NULL EXCEPTION when trying to save the rule.

Did anyone knows something about it?

By the way, I am doing it by using web services.