Custom outcome based on conditions

cancel
Showing results for 
Search instead for 
Did you mean: 
mrahn
Active Member II

Custom outcome based on conditions

Jump to solution

Dear community.

Using Alfresco Process Services I wonder whether I could have costom outcomes based on conditions.

Example:

In a form a user provideds the expected price for something that has to be ordered. If the value is not above 10.000€ the user should get an outcome buttom labelled Send to A. If the value is > 10.000€ an outcome buttom labelled Send to B should be provided.

Is there a way to achieve this just by front end scripting (without implementation)? The modelling interface doesn't seem to provide functionality for this.

Best regards

Marco

1 Solution

Accepted Solutions
mrahn
Active Member II

Re: Custom outcome based on conditions

Jump to solution

Hi Greg.

It seems to be a Browser issue. If I use button.textContent instead of button.innerText it works. I use Firefox 38.4.0.

Here the code I use:

Event: formRendered

var buttons = angular.element(document.getElementsByClassName("activiti-btn"));
for(var i = 0; i < buttons.length; i++){
var button = buttons[i];
if(button.textContent == "OUTCOME 1" || button.textContent == "OUTCOME 2"){
        button.disabled = true;
    }
}

Event: formFieldValueChanged

var buttons = angular.element(document.getElementsByClassName("activiti-btn"));
var intcount = scope.findFormFieldWithId(scope.allFormFields, 'thenumber');
for(var i = 0; i < buttons.length; i++){
    var button = buttons[i];
    button.disabled = false;
 if(button.textContent == "OUTCOME 2" && intcount.value < 11){
        button.disabled = true;
    }
 if(button.textContent == "OUTCOME 1" && intcount.value > 10){
        button.disabled = true;
    }
}
Thanks again for your help!
Marco

View solution in original post

8 Replies
gdharley
Intermediate

Re: Custom outcome based on conditions

Jump to solution

Add a javascript function to the formFieldValueChanged event to disable the second "outcome" button if the value entered is < 1000.

e.g. 

var buttons = angular.element(document.getElementsByClassName("activiti-btn"));

for(var i = 0; i < buttons.length; i++){
var button = buttons[i];
button.disabled = false;
if(button.innerText == "OUTCOME 2" && field.value < 10){
button.disabled = true;
}
}

I have attached a simple app example.

Cheers,

Greg

mrahn
Active Member II

Re: Custom outcome based on conditions

Jump to solution

Hello Greg.

Thank you very much!

I understand what the script does and wonder why it doesn't work in my environment. We run Alfresco Process Services 1.6.0.

Best regards

Marco

gdharley
Intermediate

Re: Custom outcome based on conditions

Jump to solution

Did the project I attached work in your environment? 

Greg

mrahn
Active Member II

Re: Custom outcome based on conditions

Jump to solution

no, unfortunately not

gdharley
Intermediate

Re: Custom outcome based on conditions

Jump to solution

What version are you running? I built this with 1.6.1

mrahn
Active Member II

Re: Custom outcome based on conditions

Jump to solution

Alfresco Process Services 1.6.0

I get both of the outcome buttoms whatever value (number) is choosen.

Marco

gdharley
Intermediate

Re: Custom outcome based on conditions

Jump to solution

Hmm,

Certainly workign in 1.6.1.

Try adding the following to the formRendered event to disable both outcomes until such time as you enter something.

var buttons = angular.element(document.getElementsByClassName("activiti-btn"));

for(var i = 0; i < buttons.length; i++){
var button = buttons[i];
button.disabled = true;
}

Also, the class name may have changed between 1.6 and 1.6.1 so make sure the buttons are actually being found (add a debugger statement to ensure all 4 buttons are matched).

Greg

mrahn
Active Member II

Re: Custom outcome based on conditions

Jump to solution

Hi Greg.

It seems to be a Browser issue. If I use button.textContent instead of button.innerText it works. I use Firefox 38.4.0.

Here the code I use:

Event: formRendered

var buttons = angular.element(document.getElementsByClassName("activiti-btn"));
for(var i = 0; i < buttons.length; i++){
var button = buttons[i];
if(button.textContent == "OUTCOME 1" || button.textContent == "OUTCOME 2"){
        button.disabled = true;
    }
}

Event: formFieldValueChanged

var buttons = angular.element(document.getElementsByClassName("activiti-btn"));
var intcount = scope.findFormFieldWithId(scope.allFormFields, 'thenumber');
for(var i = 0; i < buttons.length; i++){
    var button = buttons[i];
    button.disabled = false;
 if(button.textContent == "OUTCOME 2" && intcount.value < 11){
        button.disabled = true;
    }
 if(button.textContent == "OUTCOME 1" && intcount.value > 10){
        button.disabled = true;
    }
}
Thanks again for your help!
Marco

View solution in original post