cancel
Showing results for 
Search instead for 
Did you mean: 

Field validation during in a Workflow form

dranakan
Champ on-the-rise
Champ on-the-rise
Hello,

I would like to the check value of a field in a Workflow form. The verification of a field when it is property of a document is working : http://blog.mwrobel.eu/field-validation-alfresco-share-form/

I get problem to check the field in my workflow… I think that the error comes from my share-config-custom.xml. When the page is displayed, in source code mode in the browser, the link to the js function is not done with the field. I can't see something like this (with field-validation-alfresco-share-form sample) :


fieldId : "template_x002e_edit-metadata_x002e_edit-metadata_x0023_default_prop_ex_gross",
               handler : Alfresco.forms.validation.exampleGrossValidation, …

I try to give access to a function Alfresco.forms.validation.exampleGrossValidation.
My share-config-custom.xml

<config evaluator="string-compare" condition="activiti$Simple">
      <forms>
         <form>
            <field-visibility>
               <show id="bpm:workflowDescription" />
               <show id="bpm:workflowDueDate" />
               <show id="bpm:workflowPriority" />
               <show id="sgfwf:centre1" />
               <show id="bpm:assignee" />
               <show id="packageItems" />
               <!–  <show id="bpm:sendEMailNotifications" /> –>
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.general" />
               <set id="info" appearance="" template="/org/alfresco/components/form/2-column-set.ftl" />
               <set id="assignee" appearance="title" label-id="workflow.set.assignee" />
               <set id="items" appearance="title" label-id="workflow.set.items" />
               <set id="other" appearance="title" template="/org/alfresco/components/form/table-5-column-set.ftl" label-id="workflow.set.other" />
               <field id="bpm:workflowDescription" label-id="workflow.field.message">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl">
                     <control-param name="style">width: 95%</control-param>
                  </control>
               </field>
               <field id="sgfwf:centre1" set="other" help-id="example.price.gross.help" >
                 <constraint-handlers>
                                       <constraint type="MANDATORY" validation-handler="Alfresco.forms.validation.exampleGrossValidation" event="keyup" />
                  </constraint-handlers>
               </field>


Has someone done a field validation during a workflow ?
To validate my field, I need to access an external database… I think it's easier to access in Java code. Can I access my classes from the JS or can I access my classes directly from the form ?

Thanks

(Alfresco 4.0b).
6 REPLIES 6

dranakan
Champ on-the-rise
Champ on-the-rise
Has someone done a field validation during a workflow ?

dranakan
Champ on-the-rise
Champ on-the-rise
It's working now… Need to add mandatory…

<field id="sgfwf:centre1" set="other" mandatory="true">

Now I search to run Java code in my constraint-handlers. Perhaps I have to run a webscript from the JS… but I have no access to remote.connect(… from my js…
Some ideas ?

anand6105
Champ in-the-making
Champ in-the-making
Hi Dranakan,

Our team is also working on the same kind of scenario. We need to validate our workflow form. Dan we use contraint handler to call the java clasfrom where we can connect it to our custom database. If you have worked on it, can you please share the concept with us.

Thanks & Regards
Anand.

Hi Anand,

I have used a datatable (http://developer.yahoo.com/yui/datatable/) to show the information in a field.
Inside this datatable js code, I have put some call to webscript that check the value (depending on other fields).



DTP.dtpDatatable.subscribe("editorSaveEvent", function(oArgs) {
         var target = oArgs.editor.getTdEl();
         var column = DTP.dtpDatatable.getColumn(target);

         if (column.key == "centre") {
            …
            DTP.checkCentreCell(oArgs.editor.getRecord(), null, urlArgs);

         …

   /*
    * Check if the data is correct.
    */
   checkCentreCell : function(record, row,urlArgs){
      var callbacks = {
            success : function(o) {
               // Process the JSON data returned from the
               // server
               var values = [];
               try {
                  values = YAHOO.lang.JSON.parse(o.responseText);
                  var value = "";
                  if (values.length > 0) {
                     value = values[0].result;
                  }
                  if (value == "true") {
                     /* Data exist */
                  } else {

                     …
                     DTP.setValueInCell(record,row,"centre","");
                     DTP.setValueInCell(record,row,"centredes","");
                     …
                  }
               } catch (e) {
                  return;
               }
            },

            failure : function(o) {
               if (!YAHOO.util.Connect.isCallInProgress(o)) {
                  // Clean
                  …
                  DTP.setValueInCell(record,row,"centre","");
                  DTP.setValueInCell(record,row,"centredes","");
                  …
               }
            },

            timeout : 3000
         }
         var sUrl = Alfresco.constants.PROXY_URI
               + "custom/checkFromDatatable + "?firmNb=" + DTP.firmNb
               + "&fir_db=" + DTP.fir_db + urlArgs;
         var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callbacks);
   },

Hope this will help

aitbenmouh
Champ in-the-making
Champ in-the-making
Is it working in Alfresco 4.0.D i try to costum mandatory constraint but no success if someone verified it in 4.0.d give us information thanks.

Hi Lhoussin,

It's works with Alfresco 4.0.D too. Please post your files and I will check if we can help you.

Best regards.