05-25-2017 10:10 AM
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
06-01-2017 01:19 AM
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
05-26-2017 02:15 PM
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
05-28-2017 10:42 PM
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
05-30-2017 10:01 AM
05-30-2017 11:10 AM
no, unfortunately not
05-30-2017 11:20 AM
What version are you running? I built this with 1.6.1
05-30-2017 11:47 AM
Alfresco Process Services 1.6.0
I get both of the outcome buttoms whatever value (number) is choosen.
Marco
05-30-2017 12:01 PM
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
06-01-2017 01:19 AM
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
Explore our Alfresco products with the links below. Use labels to filter content by product module.