cancel
Showing results for 
Search instead for 
Did you mean: 

Passing arguments to javascript for field validation

wurstgelee
Champ in-the-making
Champ in-the-making
I´m trying to do some field validation in a workflow form.

As far as I understand http://docs.alfresco.com/4.0/topic/com.alfresco.enterprise.doc/concepts/forms-intro.html?resultof=%2..., it is possible to pass arguments (@param args) to a validation handler (the javascript function).

My validation handler implementation for the field validation currently looks like this:

<field id="aiwf:itemDescription2" set="InvestItems" label="" mandatory="true">
            <control template="/custom-textfield.ftl" />
            <constraint-handlers>
              <constraint type="MANDATORY" validation-handler="Alfresco.forms.validation.validateStringLength" event="keyup" silent="false" message="test1">
              </constraint>
            </constraint-handlers>
</field>

I would like to pass the valid min and max string length to the validateStringLength function. How can I archieve this? Or isn´t this possible?

Please help me! Smiley Wink
2 REPLIES 2

angello0571
Champ on-the-rise
Champ on-the-rise
Hi there,

the way you can work with java script in a workflow is using a scriptTask, something like this:

 <scriptTask id="scripttask2" name="ScriptTask" scriptFormat="javascript">
      <extensionElements>
        <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
          <activiti:field name="script">
            <activiti:string>
               //Javascript code here…
          </activiti:field>
        </activiti:executionListener>
      </extensionElements>
      <script></script>
</scriptTask>

But is strongly recommended to apply constraints in your workflow model for your forms, there you can apply aspects and constraints for your properties.

Here is a great explanation of the BPM Model for Alfresco's workflow http://docs.alfresco.com/4.0/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Fconcepts%2Fwf-task-mod...

Good luck Smiley Wink

wurstgelee
Champ in-the-making
Champ in-the-making
Thanks for your answer - but thats not what I´m talking about.

Me: asking about field validation in a workflow form
You: writing about a scripttask in a workflow… ?!

Or did I misunderstand you?

Edit: At least you pushed me in the right direction. Smiley Happy Thanks again!