CA Service Management

  • 1.  CA Service Catalog 14.1 Form - OnSubmit JavaScript

    Posted Sep 08, 2016 02:58 PM

    Hi all, 

    I am having an issue where information entered in Catalog is not showing in the request details upon submission. 

     

    I have a sliding scale that shows hidden values depending on the value of the scale. 

     

    As per below, the user can use the sliding scale to select up to a maximum of 5 vendors. 

     

     

    Number of vendors sliding scale information

    \

     

    and *****Field that is hidden******** information

     

     

     

    My script is as follows

    checkFrmData: function() {
    ca_fd.js.displaymyslider();
    ca_fd.js.myonsubmit();
    },

     

    displaymyslider: function() {
    var myslider = ca_fdGetSliderValue(ca_fd.formId, 'vendor_slider');

        if (myslider ==1)
          {
          ca_fdShowField(ca_fd.formId, 'ven1_mychosen_name');

       else
       {
          ca_fdHideField(ca_fd.formId, 'ven1_mychosen_name');

     

    myonsubmit: function() {

    ca_fdEnableFields(ca_fd.formId, ['ven1_mychosen_name']);

    }
    }

     

     

    The code works for my form. 

    When I slide from 0 to 1, the field will appear. 

     

    If I slide back to 0, the field disappears, which is what I want to happen. 

     

    I can now add further code to this and allow the user to choose 5 vendors on the scale and then all 5 fields will become unhidden. 

     

    Now when I go to the request form and submit

     

     

     

    The final request details are shown as per below.

    My issue is that the text entered in red circle is not displaying in the form. 

     

     

    I then went back to my form design and added an extra function in the OnSubmit in the main form

     

    I adjusted my code as shown in red

    checkFrmData: function() {
    ca_fd.js.displaymyslider();
    ca_fd.js.myonsubmit();
    },

     

    displaymyslider: function() {
    var myslider = ca_fdGetSliderValue(ca_fd.formId, 'vendor_slider');

        if (myslider ==1)
          {
          ca_fdShowField(ca_fd.formId, 'ven1_mychosen_name');

       else
       {
          ca_fdHideField(ca_fd.formId, 'ven1_mychosen_name');

    ,

    myonsubmit: function() {

    ca_fdEnableFields(ca_fd.formId, ['ven1_mychosen_name']);

    }
    }

     

     

     

    This resulted in the On Submit button not working. 

     

     

    Has anyone got any advice as to how I can show this hidden field and still display it in the final form upon submission?



  • 2.  Re: CA Service Catalog 14.1 Form - OnSubmit JavaScript

    Posted Sep 08, 2016 06:23 PM

    For the hidden field shown via JavaScript not displaying after submitting the request:

     

    Catalog does not store the dynamic state of form fields which are governed via JavaScript functions (i.e. ca_fdShowField). As such you would need to call a JavaScript function onLoad of the form to validate which fields should be displayed/hidden and then call ca_fdShowFied/ca_fdHideField to appropriately show/hide the same.

     

    As for the 'Submit' button not working, you're onSubmit JavaScript function needs to return true in order to be able to submit:

     

    • onSubmit
      Specifies the JavaScript function to run when the user submits the request that contains the form.
      This function must return a Boolean value. If the function returns any value except true, the form is not submitted.
      Multiple forms having an onSubmit attribute can appear on a single page. In that case, each JavaScript function runs when the user submits the form that includes the function.
      The information about alerts for the onLoad function also applies to the onSubmit function.

     

    This is from the following:

     

    Form Attributes - CA Service Management - 14.1 - CA Technologies Documentation 



  • 3.  Re: CA Service Catalog 14.1 Form - OnSubmit JavaScript

    Posted Sep 09, 2016 06:23 AM

    Thanks for this Jason, 

    I have added a onLoad function. 

     

     

    *****Field that is hidden******** information is now the default hide value of false. (ie: not hidden)

     

     

     

     

    It will then "on load" hide the field, which is what I want.

     

    Then in the displamyslider function it will hide or show accordingly as the user drags the slider. 

     

    I am however still having the same issue. 

     

    Do I then need an onSubmit function as well? 

    And if I do, how do I get it to display on the final form upon submission?

    Doing a ca_fd.js.showField within the OnSubmit function does not work......all it does is show the field on Submit but not actually submit if that makes sense

     

    My new code as per below.  No OnSubmit included for now as I'm not sure if it is needed. 

     

     

     

    checkFrmData: function() {

     

    ca_fd.js.hideFields();

    ca_fd.js.displaymyslider();

     

    },

     

    //This is for OnLoad of form

    hideFields: function() {

    ca_fdHideField(ca_fd.formId, 'ven1_mychosen_name');

    }

     ,

    //This hides or shows depending on the sliding scale

    displaymyslider: function() {
    var myslider = ca_fdGetSliderValue(ca_fd.formId, 'vendor_slider');

        if (myslider ==1)
          {
          ca_fdShowField(ca_fd.formId, 'ven1_mychosen_name');

       else
       {
          ca_fdHideField(ca_fd.formId, 'ven1_mychosen_name');

     


    }



  • 4.  Re: CA Service Catalog 14.1 Form - OnSubmit JavaScript
    Best Answer

    Posted Sep 09, 2016 09:44 AM

    Looks like you need to invoke ca_fd.js.displaymyslider() onLoad of the form and onChange of the slider.



  • 5.  Re: CA Service Catalog 14.1 Form - OnSubmit JavaScript

    Posted Sep 09, 2016 10:30 AM

    Jason_Wolfe you are a wizard. 

    This works perfectly. 

    Thanks a million!