AnsweredAssumed Answered

How to auto close the form upon submit.

Question asked by satheeshkumar on Apr 2, 2015
Latest reply on Apr 24, 2015 by ddraper
Hi all,

I have created a form using topic "ALF_CREATE_DIALOG_REQUEST", the sample code snippet is shown below,


var alfDestination = null;

var result = remote.call("url call to repository");

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

//Code snippet of my pop-dialog form,
widgets : [
{
   name : "alfresco/menus/AlfMenuBarItem",
   config : {
      label : "Create Product Type using ALF_CREATE_DIALOG_REQUEST",
      publishTopic : "ALF_CREATE_DIALOG_REQUEST",
      publishPayload : {
         dialogTitle : "Create New Product Type",                                                                     
         fixedWidth : false,                                                                     
         widgetsContent : [{
            name : "alfresco/forms/Form",
            config : {
               showOkButton : true,
               okButtonLabel : "Add",
               showCancelButton : true,
               cancelButtonLabel : "Cancel",
               //Specify the TOPIC here
               okButtonPublishTopic : "ALF_CRUD_CREATE",                                                                           
               okButtonPublishGlobal : true,
               okButtonPublishPayload : {                                                                              
                  url : "api/type/hccm%3AproductTypeFolder/formprocessor",                                                                              
                  alf_destination : alfDestination,
                  alfResponseTopic : "HC_PRODUCT_CREATE"
               },
               widgets : [
                         
                  {
                     name : "alfresco/forms/controls/TextBox",
                     config : {
                        fieldId : "PRODUCT_NAME",
                        label : "Product Name",
                        name : "prop_cm_name",
                        description : "Provide a Unique Value for the Product Name.",
                        requirementConfig : {
                           initialValue : true
                        },
                        validationConfig : [ {
                           validation : "validateUnique",
                           itemsProperty : "response.productNameList",
                           errorMessage : "The Product Name already exists!",
                           publishTopic : "ALF_CRUD_GET_ALL",
                           publishPayload : {
                              url : "retrieve-library-list?retrieve=Product%20Library"
                           }
                        } ]
                     }
                  },
                  {

                     name : "alfresco/forms/controls/DojoValidationTextBox",
                     config : {
                        label : "Product Title",
                        name : "prop_cm_title"
                     }

                  },
                  {

                     name : "alfresco/forms/controls/DojoValidationTextBox",
                     config : {
                        label : "Product Description",
                        name : "prop_cm_description"
                     }

                  },
                  {

                     name : "alfresco/forms/controls/TextBox",
                     config : {
                        fieldId : "PRODUCT_PREFIX",
                        label : "Product Prefix",
                        name : "prop_hccm_prefix",
                        description : "Provide a Unique Value for the Prefix field.",
                        requirementConfig : {
                           initialValue : true
                        },
                        validationConfig : [ {
                           validation : "validateUnique",
                           itemsProperty : "response.productPrefixList",
                           errorMessage : "This Prefix is already used. Please try different value.",
                           publishTopic : "ALF_CRUD_GET_ALL",
                           publishPayload : {
                              url : "retrieve-library-list?retrieve=Product%20Library"
                           }
                        } ]
                     }

                  }]
            }

         }]                                                                     
      }
   }
} ]


Upon submit the form is posting the data to the mentioned destination and in the specified URl, there is no issue in that, but once I submitted the content the Pop-up Dialog(which contains my form) still exists, it neither close automatically nor clearing the form fields.


What I should do for my pop-up dialog to clear the form fields after submit, or close the pop-up dialog upon submit. Either one would full fill my need.

Any help is greatly appreciated.





I also tried with topic,
"ALF_CREATE_FORM_DIALOG_REQUEST"
,(this form properly closes the pop-up upon submit) I am able to use
formSubmissionTopic for pulish
, and I can create my own subscription topic for the topic published and call a function when subscribed, but in that function I am able to specify only the
URL
but not the
alf_destination
, so even after submitting nothing is happening because I haven't specify the alf_destination and just the dialog gets closed.



//Code snippet of ALF_CREATE_DIALOG_REQUEST
widgets : [
   {
      name : "alfresco/menus/AlfMenuBarItem",
      config : {
         label : "Create Product Type using ALF_CREATE_DIALOG_REQUEST",
         publishTopic : "ALF_CREATE_DIALOG_REQUEST",
         publishPayload : {
            dialogTitle : "Create New Product Type",                                                                     
            fixedWidth : false,                                                                     
            widgetsContent : [{
               name : "alfresco/forms/Form",
               config : {
                  showOkButton : true,
                  okButtonLabel : "Add",
                  showCancelButton : true,
                  cancelButtonLabel : "Cancel",
                  //Specify the TOPIC here
                  okButtonPublishTopic : "ALF_CRUD_CREATE",                                                                           
                  okButtonPublishGlobal : true,
                  okButtonPublishPayload : {                                                                              
                     url : "api/type/hccm%3AproductTypeFolder/formprocessor",                                                                              
                     alf_destination : alfDestination,
                     alfResponseTopic : "HC_PRODUCT_CREATE"
                  },
                  widgets : [
                            
                     {
                        name : "alfresco/forms/controls/TextBox",
                        config : {
                           fieldId : "PRODUCT_NAME",
                           label : "Product Name",
                           name : "prop_cm_name",
                           description : "Provide a Unique Value for the Product Name.",
                           requirementConfig : {
                              initialValue : true
                           },
                           validationConfig : [ {
                              validation : "validateUnique",
                              itemsProperty : "response.productNameList",
                              errorMessage : "The Product Name already exists!",
                              publishTopic : "ALF_CRUD_GET_ALL",
                              publishPayload : {
                                 url : "retrieve-library-list?retrieve=Product%20Library"
                              }
                           } ]
                        }
                     },
                     {

                        name : "alfresco/forms/controls/DojoValidationTextBox",
                        config : {
                           label : "Product Title",
                           name : "prop_cm_title"
                        }

                     },
                     {

                        name : "alfresco/forms/controls/DojoValidationTextBox",
                        config : {
                           label : "Product Description",
                           name : "prop_cm_description"
                        }

                     },
                     {

                        name : "alfresco/forms/controls/TextBox",
                        config : {
                           fieldId : "PRODUCT_PREFIX",
                           label : "Product Prefix",
                           name : "prop_hccm_prefix",
                           description : "Provide a Unique Value for the Prefix field.",
                           requirementConfig : {
                              initialValue : true
                           },
                           validationConfig : [ {
                              validation : "validateUnique",
                              itemsProperty : "response.productPrefixList",
                              errorMessage : "This Prefix is already used. Please try different value.",
                              publishTopic : "ALF_CRUD_GET_ALL",
                              publishPayload : {
                                 url : "retrieve-library-list?retrieve=Product%20Library"
                              }
                           } ]
                        }

                     }]
               }

            }]                                                                     
         }
      }
   } ]
   }
} ]

can someone let me know how to configure both url and alf_destination, when I create a dialog using 
"ALF_CREATE_FORM_DIALOG_REQUEST"
, either in the subscribed function or in the dialog itself.

Thanks in Advance,

Outcomes