CA Service Management

Expand all | Collapse all

How to hide drop-down option?

  • 1.  How to hide drop-down option?

    Posted Jun 06, 2017 09:56 AM

    Hi Team,

     

    Is there any way to hide drop-down option depending upon some condition in CA Service Catalog form.

     

    Best Regards,

    Pankaj 



  • 2.  Re: How to hide drop-down option?

    Posted Jun 06, 2017 01:26 PM

    As far as i am aware, no.

     

    What i do :

     

    Opt#1 : create several dropdowns and hide/show the one i need.

     

    Opt#2 : put your values in a table in your database and add severals columns that you can filter on based on the input provided by your end user. You can then create a report object for your dropdown and use a couple of report variables



  • 3.  Re: How to hide drop-down option?

    Posted Jun 07, 2017 02:42 AM

    Hi pier-olivier,

     

    I can't create several dropdowns because id of the dropdown is fixed and I can't change the id as well as I can't create duplicate id in the form.

    Thanks for the valuable suggestion.

     

    Best Regards,

    Pankaj



  • 4.  Re: How to hide drop-down option?

    Broadcom Employee
    Posted Jun 07, 2017 02:32 AM

    Good Morning Pankaj.
     
    Although it is not completely clear to me what you mean with 'upon some condition', I'll give some examples below.
     
    To hide or disable a field if the user has the enduser role, set the hidden or disabled attribute of that field to the following JavaScript expression:
     $(_.user.roles[_bu.id]==’enduser’).
    This expression returns a value of true and therefore hides or disables the field only if the user filling out the form has an enduser role in the current business unit.
     
    You may use this setting or a similar one to restrict users from either viewing or editing the text field named Memory in a form for a request for a new laptop computer.
    Conversely, this example displays or enables the field for all other roles in the business unit.
    Thus, when used with the disabled attribute, this example permits the request manager to edit the field, based on the available inventory.
     
    To display or enable a field for only request managers, hide or disable it for all other roles,
    by setting the hidden or disabled attribute of that field to $(_.user.roles[_.bu.id] != ‘requestmanager’).
     
    To hide or disable a field in a form shared by all business units, only if the current business unit is PBJ222,
    set the hidden or disabled attribute of that field to $(_bu.id==’PBJ222’).
     
    To hide or disable a field in a form shared by all business units, only if the parent of the current business unit is PBJ222,
    set the hidden or disabled attribute of that field to $(_bu.id.parent==’PBJ222’).
     
    To hide or disable a field if the request was created after a certain date,
    set the hidden or disabled attribute of that field to $(new Date(_.request.dateCreated) < ’date’).
     
    For example, to hide or disable a field if the request was created after January 15, 2010,
    specify $(new Date(_.request.dateCreated) < new Date().setFullYear(2010,0,15)).
     
    To hide or disable a field if the request status is Approval Done or higher,
    set the hidden or disabled attribute of that field to $(_.request.status=>600).
     
    Test the JavaScript expression to verify that it accomplishes your goals for enabling or disabling the field on the form.
     
    Thanks and kind regards, Louis van Amelsfort.



  • 5.  Re: How to hide drop-down option?

    Posted Jun 07, 2017 02:49 AM

    Hi Luis,

    Thanks for the quick reply.

     

    Lets clarify the requirements again,

    I want to create dependent dropdown in CA Service Catalog form.

    For Example:

    I have two dropdown

    1st dropdown have a option A,B

    2nd dropdown have a option C,D,E,F

    When I select A from 1st dropdown then with in the second dropdown I can only get the option C,D

    When I select B from 1st dropdown then with in the second dropdown I can only get the option E,F.

     

    Best Regards,

    Pankaj



  • 6.  Re: How to hide drop-down option?

    Posted Jun 07, 2017 04:21 AM

    Hi Luis,

     

    Like $(_bu.id.parent==’PBJ222’), can we capture our custom created form field value?

    For Example:

    first_name is the id of the field then what is the expression for capturing the value like above expression.

     

    Best Regards,

    Pankaj

     

     



  • 7.  Re: How to hide drop-down option?

    Broadcom Employee
    Posted Jun 07, 2017 03:18 AM

    Good Morning Pankaj.
     
    Please check the below example, which is meant as a starting point for you.
    It is not a 'conclusive' answer though. It is meant to get you going.
     
    The below is to be used in the script of the form.
    And the function to be executed for the field on the form.
    I hope this helps.
     
    /****************************************************************
    displayCompany checks the selection boxes to determine if the user is a contractor or not.
    If contractor is chosen the Company name is visible.  Otherwise the company name is hidden.
    This function is invoked when the onChange event of the radio button for The Contractor is selected.
    *****************************************************************/
     
      displayCompany : function(formID) {
      if (ca_fdIsSelectRadio(formID, 'ContractorResult', 'ContractorYes'))
           ca_fdShowField(formID,'company');
      if (ca_fdIsSelectRadio(formID, 'ContractorResult', 'ContractorNo'))
           ca_fdHideField(formID,'company');
     
      },
     
    Kind regards, Louis van Amelsfort.



  • 8.  Re: How to hide drop-down option?

    Posted Jun 07, 2017 03:35 AM

    Hi Luis,

     

    Very good morning.

    Its not about hide the dropdown.I want to hide the some of the option of dropdown.

    Many many thanks for your reply.

     

    Best Regards,

    Pankaj



  • 9.  Re: How to hide drop-down option?

    Broadcom Employee
    Posted Jun 07, 2017 03:40 AM

    Good Morning Pankaj.
     
    It is as I mentioned in my previous update.
    It is a starting point for you to get an idea about a possible 'script coding' to be used.
    It is out of my scope to get/write you a complete script as such.
     
    When needed, you could engage CA Services through your local CA Sales Representative.
     
    Thanks and kind regards, Louis.



  • 10.  Re: How to hide drop-down option?

    Posted Jun 07, 2017 04:15 AM

    Hi Luis,

     

    I am not asking you to write complete code for me, it will be great if you write one line of code how I will hide the option from the dropdown.

    For show and hide the complete field there is a method called ca_fdShowField(formId, _id) & ca_fdHideField(formId, _id) is there but for the hiding some option from dropdown is not there in the document.

     

    Best Regards,

    Pankaj



  • 11.  Re: How to hide drop-down option?

    Broadcom Employee
    Posted Jun 07, 2017 04:38 AM

    Good Morning Pankaj.
     
    After further researching for this, I found the following answer:
     
    Leveraging ca_fdShowField/ca_fdHideField with table fields is currently a limitation, based on the current table design.
     
    What I then would like to suggest, is for you to raise an Idea as an enhancement request to possibly include this functionality going forward.
    Please inform me of such and I will vote-up for the Idea, there after.
     
    Thanks for your understanding an dkind regards, Louis.



  • 12.  Re: How to hide drop-down option?

    Posted Jun 07, 2017 06:12 AM

    Hi Luis,

     

    I have created one idea as per your suggestion, please check the following link

    Hide some option of a dropdown field in CA Service Catalog form 

     

    Best Regards,

    Pankaj



  • 13.  Re: How to hide drop-down option?

    Broadcom Employee
    Posted Jun 07, 2017 07:45 AM

    And I voted-up for it accordingly. Thanks and Kind regards, Louis.



  • 14.  Re: How to hide drop-down option?

    Posted Jun 07, 2017 08:19 AM

    Many many thanks for suggestion and voted-up.

     

    Best Regards,

    Pankaj



  • 15.  Re: How to hide drop-down option?

    Posted Jun 07, 2017 08:19 AM

    As i said yesterday, you cannot.

     

    But apprently you did not read my answer completely so i will continue here with a crystal clear exemple.

     

    Create two tables in your database.

     

    Table_A

    id   value

    0   A

    1   B

     

    Table_B

    id   value   parent

    0   C          A

    1   D          A

    2   E          B

    3   F          B

     

     

    Create a report query that goes like this : select id, value from table_a

     

    Create a report query that goes like this : select id, value from table_B where parent = '%STRING%'  

     

    %STRING% must be declare in your variable. You can create one by clicking on "manage variables" in the report object designer.

     

     

    Create two drop downs in your form.

     

    First dropdown, in report/plug-in id : set the name of the first report object

     

    First dropdown, in onChange : ca_fdFetchSelectData(ca_fd.formId, 'IDOfYourSecondDropdown');

     

    Second dropdown, in report/plug-in id : set the name of the second report object

     

    Second dropdown, in report/plug-in id : set the report/ plug-in variable to : $({'STRING': ca_fdGetSelectedOptionValues(ca_fd.formId, 'IDOfyourFirstDropdown')[0]})

     

    Hope this helps,



  • 16.  Re: How to hide drop-down option?

    Posted Jun 07, 2017 08:24 AM

    Hi Pier,

     

    Thanks for the suggestion.

    I understand your approach even I know how to do it dynamically.But our requirement is to do it without database and spreadsheet.

     

    Best Regards,

    Pankaj