CA Service Management

  • 1.  Validate spinner field in form is not working as expected

    Posted Nov 20, 2018 10:58 AM

    Validation of a spinner field in form is not working as expected. In catalog 17.1.0.16, the validation function only works correctly when the field value is changed manually in the text box, and does not work when the attached arrows of the spinner field are used or the form is submitted.

     

    The function is configured in the onValidate attribute of the field with the call ca_fd.js.validate(_val), and the function code is written in the script dialog.

     

    {
    validate:function(value){ 
      console.log('Validate field '+value);   
     
      var ip_free = parseInt(ca_fdGetTextFieldValue(formId,'ip_free'),10); 
      var ip_add = parseInt(value,10); 
     
      if(ip_add > ip_free){   
        return 'Validation failed';  
      } 
      else{   
        return null; 
      }
    }
    }


    Is it a bug or has the field changed its behavior?



  • 2.  Re: Validate spinner field in form is not working as expected

    Broadcom Employee
    Posted Nov 21, 2018 03:27 AM

    Good Morning Vinicius.

    Could this be of help for you?

    https://docops.ca.com/ca-process-automation/4-2-2/en/reference/form-reference/form-element-events
    onValidate
    Occurs when the associated code verifies a field value against business rules before one of the following actions occurs:
    - The field value is stored in the data buffer.
    - The field value is written to the database.

    For example, the user tabs to or clicks a Serial Number field that must start with the letters SN and contain 10 numeric digits.
    Before the user can tab to the next field or click away from the field,
    the onValidate event and its associated code verify the data.
    You can alert the user if the serial number does not meet validation rules so they can adjust their entry.
    You can use onValidate for custom validation of the field input.
    For example, to ensure that a field input is at least three characters in length,
    you can write a custom function in the Script dialog:

    validateValue:function(_val) {
    if(_val.length < 3) {
    return "Please enter more than 3 characters for this field";
    } else {
    return null;
    }

    In the Form Designer, include the onValidate attribute value for the text field on which to run the validation.
    For example:
    ca_fd.js.validateValue(_val)

    The custom function replaces the required parameter _val with the correct field value when the script runs.
    If the validation script returns a null value, the field input passes validation.
    Otherwise, the field input fails validation and the script returns an error
    (for example, "Enter more than 3 characters for this field").

    Kind regards, Louis van Amelsfort.



  • 3.  Re: Validate spinner field in form is not working as expected

    Posted Nov 21, 2018 07:00 AM

    Hi Louis,

     

    Thank you for attention, but that is the question, when the user tabs to the next field or click away from the spinner field the validation function not occurs if the field value was changed by the attached arrows. Only if I click in the spinner field and change de value manually, then by tabbing to the next field the validation function works normally.

     

    In addittion, when the form is submitted the validation function not works and an error is displayed in the browser console:

     

    Error: x.replace is not a function
    link/<@http://<site>/usm/explorer/scripts/catalogux/common/components/form/fields/spinner/spinner.directive.js:1:6291
    $digest@http://<site>/usm/explorer/scripts/catalogux/angular.js:1:131094
    $apply@http://<site>/usm/explorer/scripts/catalogux/angular.js:1:132803
    gH@http://<site>/usm/explorer/scripts/catalogux/angular.js:1:155684
    window.ca_fdValidateForm@http://<site>/usm/explorer/scripts/catalogux/common/components/form/FormAPIs.js:21:4
    ca_fdIsValid@http://<site>/usm/gwt/fdBase/scripts/formdesigner.js:1050:18
    ca_fdIsVisibleFormInvalid/<@http://<site>/usm/gwt/fdBase/scripts/formdesigner.js:1073:20
    each@http://<site>/usm/explorer/scripts/jquery.js:1:12892
    each@http://<site>/usm/explorer/scripts/jquery.js:1:9429
    ca_fdIsVisibleFormInvalid@http://<site>/usm/gwt/fdBase/scripts/formdesigner.js:1067:4
    finish@http://<site>/usm/wpf?Node=icguinode.catalogitemdetails&Args=10420&ObjectID=10420&NspPath=&AddResult=1:2228:10
    finishaddandcont@http://<site>/usm/wpf?Node=icguinode.catalogitemdetails&Args=10420&ObjectID=10420&NspPath=&AddResult=1:2189:7
    onclick@http://<site>/usm/wpf?Node=icguinode.catalogitemdetails&Args=10420&ObjectID=10420&NspPath=&AddResult=1:1:1


    PS
    The link that you posted is about Ca Process Automation and the problem in discussion is about the Ca Service Catalog, I dont know if the functionality is the same.

     

    Thanks