AnsweredAssumed Answered

How to do business validation of a form before submitting the form?

Question asked by satheeshkumar on Mar 31, 2015
Latest reply on Apr 6, 2015 by satheeshkumar

I have created a custom contentModel, as shown below,

<!– Each Produt Type folder should contain a prefix associated to it. –>
      <type name="hccm:productTypeFolder">
         <title>Product Type Folder</title>
            <property name="hccm:prefix"> //Custom prefix fileld
               <!– TODO Need to add Regex Constraint for Prefix Field –>

I have created a form as shown below to create folders in the desired location
/slingshot/doclib2/doclist/file/site/" +site+ "/documentLibrary/Product%20Library

var site = "product-management";
//Read the node reference of Product Library under Document Library
var alfDestination = null;
//Derived based on the URI "/slingshot/doclib2/doclist/{type}/site/{site}/{container}/{path}"
var result ="/slingshot/doclib2/doclist/file/site/" + site
      + "/documentLibrary/Product%20Library");

if (result.status.code == status.STATUS_OK) {
   alfDestination = JSON.parse(result).metadata.parent.nodeRef;

var productName = {
      config: {
         label:"Product Name",

var productTitle = {
      config: {
         label:"Product Title",

var productDescription = {
      config: {
         label:"Product Description",

var productPrefix = {
      config: {
         label:"Product Prefix",
         name:"prop_hccm_prefix" //Custom prefix field

var anpForm = {
      name : "alfresco/forms/Form",
         okButtonLabel : "Create",
         okButtonPublishTopic : "ALF_CRUD_CREATE",
         okButtonPublishGlobal : true,
         okButtonPublishPayload : {
            //Specify the URL here to POST the data
            //Dereived based on the URI "/api/{item_kind}/{item_id}/formprocessor"
            url : "api/type/hccm%3AproductTypeFolder/formprocessor",
            //To create the folder under product Library of document library, we need the productLibrary nodeRer,So POST that too.
            alf_destination : alfDestination,
            alfResponseTopic :"PRODUCT_CREATE"


model.jsonModel = {

Now what I want is, if the user enter anything in "prop_hccm_prefix" field, I should make some ajax call and check the repository for any existence of the same prefix value under the location "
/slingshot/doclib2/doclist/file/site/" +site+ "/documentLibrary/Product%20Library
" and if exists, then show some red text in the UI like the prefix you entered is already used for some other "product type folder", is there a way I can achieve this.

I just want to achieve this similar to "REGEX" validation, I want to do AJAX validation.

Can you please help?

Thanks in Advance.