CA Service Management

 View Only
  • 1.  two JS functon issue in onSubmit

    Posted Aug 20, 2015 07:59 AM

    Hi,

     

    I have placed two function in onsubmit. Each function validate fields before submit.

     

    But issue is form is working when only one function placed. If two function added it is not working as expected. Request get submitted, it is not validating.

     

    Any idea why it is behaving like that.

     

     

    Thanks,

    Amala



  • 2.  Re: two JS functon issue in onSubmit

    Posted Aug 20, 2015 09:00 AM

    hi,

    I'm not familiar with CA SC,

    but if there is possibility to set 1 function onsubmit which will contain execution of 2 other functions?

    example:

    function mainFunc(){

         if ( (func1()) && (func2()) )

              return true;

         }

    }

    onsubmit = mainFunc;

    Regards.



  • 3.  Re: two JS functon issue in onSubmit

    Broadcom Employee
    Posted Aug 21, 2015 10:53 AM

    it will need to check if it is allowed to call another function within a function and how ( the syntax )  in a script of a catalog's form  .



  • 4.  Re: two JS functon issue in onSubmit

    Broadcom Employee
    Posted Aug 21, 2015 11:25 AM

    The correct syntax to call another function within a function in a catalog form's script :


    x : function(param2) {

    alert(param2);

    },

     

    z : function(param1) {

    ca_fd.js.x('invoking function x with value:'+param1);

    }

     

    The information above is  actually in the script's dialog sample of a form .   So ,  you need to put ca_fd.js. in front of the function .



  • 5.  Re: two JS functon issue in onSubmit
    Best Answer

    Broadcom Employee
    Posted Aug 21, 2015 10:51 AM

    By current design :

    1) Onsubmit expects a single function and it should be one for form. However, while submitting the request, it will aggregate  Onsubmit values of all forms inside that request. In this process, it will not allow to submit, even if there is failure of Onsubmit in one form.

     

    2) you can have multiple onLoad functions separated by ';'. But this is not the case with 'onSubmit'.

     

    So onSubmit attribute of a form ,  you can ONLY place one js function there .