CA Service Management

Expand all | Collapse all

Show / hide form based on variable

  • 1.  Show / hide form based on variable

    Posted Jan 15, 2018 12:22 PM

    Hi all,

     

    I have two forms in an offering: form1 and form2. I want form2 to be displayed only when form1.value1 == 'yes'. For form1.value1 == 'no' form2 should be hidden.

     

    I can't find a function that show/hide form based on a value.

    How can i accomplish this?

     

    Thank you in advance.

     

    //Pedro



  • 2.  Re: Show / hide form based on variable

    Posted Jan 15, 2018 02:04 PM

    Hi Petro,

    Check out this link Use JavaScript Expressions in Fields - CA Service Management - 14.1 - CA Technologies Documentation 

     

     

    I believe that what you are trying to achieve can be done with a custom function or a jQuery expression direct on the definition of the field.

     

    If this documentation doesn't help you, please explain what makes form1.value1 be true, if it's something that is clicked, checked or loaded.



  • 3.  Re: Show / hide form based on variable

    Broadcom Employee
    Posted Jan 16, 2018 03:30 AM

    Good Morning Pedro.

    In addition to Marcel's reply:
    On this page:
    https://docops.ca.com/ca-service-management/14-1/en/using/service-catalog-management/manage-forms/perform-automated-tasks-in-form-fields/use-javascript-expressions-in-fields#UseJavaScriptExpressionsinFields-Hide,Enable,orDisableanEntireFormUnderSpecifiedConditions

    You'll find:
    Hide, Enable, or Disable an Entire Form Under Specified Conditions
    To hide, enable, or disable an entire form under certain conditions,
    you attach the form to a service option group
    and enter the JavaScript expression you want in the Disabled and Hidden fields of the Service Option Group Definition dialog.

    >>
    You can hide, enable, or disable an entire form according to the request status,
    the role or business unit of the logged in user, or according to other criteria that you specify.
    For more information, see Attach a Form to a Service Option Group.

    Kind regards, Louis van Amelsfort.



  • 4.  Re: Show / hide form based on variable

    Posted Jan 16, 2018 03:40 AM

    Thank you deama10 Louis_van_Amelsfort

     

    I can show/hide the form2 onLoad. But form1.value1 is set only when the user is filling the form. My form2 should be shown/hidden based on that.

     

    For what I understood the property Hidden for the form can only be evaluated during onload and onsubmit. Am I missing something here?



  • 5.  Re: Show / hide form based on variable

    Broadcom Employee
    Posted Jan 16, 2018 03:49 AM

    Good Morning Pedro.

    When I read this correctly on page:
    https://docops.ca.com/ca-service-management/14-1/en/using/service-catalog-management/manage-forms/create-and-customize-a-form#CreateandCustomizeaForm-AttachaFormtoaServiceOptionGroup

    You need to set the 'hidden' property for all elements on the form.
    To hide the complete form as such.
    As in step9:
    If you want to hide or disable the entire form according to a criteria,
    enter the corresponding JavaScript expression in the Hidden or Disabled field.
    Use the following format: $(_.object.property).
    The expression must return a value of true or false.
    Example:
    To hide or disable the form when the request status is Pending Approval, enter: $(_.request.status == 400)
    To hide or disable the form for end-user roles only, enter: $(_.user.role == ‘enduser’)
    You can also specify other JavaScript expressions in fields.

    Kind regards, Louis.



  • 6.  Re: Show / hide form based on variable

    Posted Jan 16, 2018 03:58 AM

    The problem is that my form1 is a Main Form used in several offerings. Form2 can be anything with different fields and content. Setting an expression for each element of what can be my form2 is not practical. 

     

    Is there a way to evaluate my form1.value1 onChange so I can hide/show my form2? 



  • 7.  Re: Show / hide form based on variable

    Broadcom Employee
    Posted Jan 16, 2018 04:20 AM

    Good Morning Pedro.

     

    As per your latest remark, this would then be a 'new feature, for a new release of the product'.

    And for that, I can propose to you, to add an idea in this same Community.

     

    Thanks in advance for your effort on that.

    Kind regards, Louis.



  • 8.  Re: Show / hide form based on variable
    Best Answer

    Posted Jan 16, 2018 04:45 AM

    Since this seems to be a new feature I will consider an alternative:

    1. Create my form1 that will act as a Main Form
    2. Create several forms with Field Set component (one form for offer)
    3. Create a switch/case that based on _.soe will show/hide Field Set for form2


  • 9.  Re: Show / hide form based on variable

    Posted Jan 16, 2018 05:06 AM

    Idea created: Hide/show form based on user input 

    Thank you for your help.