CA Service Management

 View Only
Expand all | Collapse all

Customized dropdown with non SREL values

  • 1.  Customized dropdown with non SREL values

    Posted Dec 20, 2018 10:42 AM

    Got a requirement to add a new dropdown with values 'Very-High', 'High', 'Medium' ,'Low'. I see using the schema designer, we could create a new attribute but I don't how to provide this customized values on drop down without creating a new table.

     

    Can someone give me an idea on how to get this without creating a new table?.

     

    Thanks,

    Vis 



  • 2.  Re: Customized dropdown with non SREL values

    Broadcom Employee
    Posted Dec 20, 2018 02:16 PM

    Vis, I don't think you can do this with dtlDropdown macro(someone corrects me if I am wrong). I would recommend using a custom table/object with those 4 records and then use the regular dropdown srel to the custom object. Thanks _Chi



  • 3.  Re: Customized dropdown with non SREL values
    Best Answer

    Posted Dec 21, 2018 01:37 AM

    I had thoughts regarding your question, here is a discussion: Poll: Data type selection 

    I prefer to use dropdown with predefined values and keep them as integer to reduce data usage, code sample:

    // To make this work simply replace all *z_my_int_attr* with your own integer type attr

    // Preload values
    var z_my_int_attr_val;
    switch (Number("$args.z_my_int_attr")) {
         case 0 : z_my_int_attr_val = "Undefined";break;
         case 1 : z_my_int_attr_val = "Low";break;
         case 2 : z_my_int_attr_val = "Medium";break;
         case 3 : z_my_int_attr_val = "High";break;
    }

    // Dropdown code
    detailDropdown("Dropdown header", "z_my_int_attr", "pri", 1, 20,
         true, "", "$args.z_my_int_attr",
         "no", "z_my_int_attr", "$args.z_my_int_attr",
         "","","no","","",
         z_my_int_attr_val,
         "Undefined", "0",
         "Low", "1",
         "Medium", "2",
         "High", "3"
    );


  • 4.  Re: Customized dropdown with non SREL values

    Posted Dec 21, 2018 08:07 AM

    Thank you so much cdtj. Let me try this and get back to you. 



  • 5.  Re: Customized dropdown with non SREL values

    Posted Dec 21, 2018 09:13 AM

    It worked. Awesome!! Thanks cdtj.. I got another question here.

     

    Is it possible for us to add an event on this dropdown?



  • 6.  Re: Customized dropdown with non SREL values

    Posted Dec 21, 2018 09:25 AM

    add this one just before dropdown code:

    detailSetEventHandler("onchange='zSomeFunc(this);'");

    example: How to create Combobox input (Editable Dropdown) 



  • 7.  Re: Customized dropdown with non SREL values

    Posted Dec 21, 2018 09:56 AM

    Thanks, cdtj.. I saw your comment another thread and added it

    detailDropDown onclick event 

     

    Only in the Edit mode, the dropdown shows the Low, Medium, High. But after saving the form, it shows the values 1,2,3.



  • 8.  Re: Customized dropdown with non SREL values

    Posted Dec 21, 2018 10:01 AM

    seems your mapping is missing or incorrect, could you share your code?



  • 9.  Re: Customized dropdown with non SREL values

    Posted Dec 21, 2018 10:08 AM

    // Preload values
    var zimpact_val;
    switch (Number("$args.zimpact")) {
    case 1 : zimpact_val = "1-Low"; break;
    case 2 : zimpact_val = "2-Medium"; break;
    case 3 : zimpact_val = "3-High"; break;
    }

    // Dropdown code
    detailSetEventHandler("onchange='setCOType();'");
    detailDropdown("Impact", "zimpact", "pri", 1, 20, true, "", "$args.zimpact", "no", "zimpact", "$args.zimpact", "", "", "no", "", "", zimpact_val, "1-Low", "1", "2-Medium", "2", "3-High", "3" );



  • 10.  Re: Customized dropdown with non SREL values

    Posted Dec 21, 2018 10:21 AM

    everything looking good, try to add alert before dropdown showing zimpact_val and "$args.zimpact"...

    you simply check variable via console: ahdframe.zimpact_val



  • 11.  Re: Customized dropdown with non SREL values

    Posted Dec 27, 2018 02:42 PM

    Since I'm a programmer and I try to respect databases normals forms, I try to always use a relation when I should do so.

     

    And when I say that I try is because if i wanted to go "full normal", the z_grouping attribute in the present example should be a relation to avoid data redundancy. I did not do it for a couple of reasons that we could debate in a philosophical discussion but for the current example, let just say that we can't be perfect but we can be better

     

     

     

    For cases like this one, I like to use a "generic" object in wich I store values for a wide range of usage.

     

    Object definition wich i lovely called z_dropdown :

     

    z_grouping (string) (It is the english name for my z_groupement attribute)

    z_value (string) (It is the english name for my z_valeur attribute)

     

    (Other attributes are generated automatically)

    (cdtj there is one of your invention in there, z_generate_name  used to generate a unique asset tag : Concat an auto-incremental ID to CI name . Still rocking it !)

     

     

    If I want to store your values 'Very-High', 'High', 'Medium' ,'Low', I would add 4 items with the same z_grouping values.

     

     

    z_value/z_grouping

    Very-High/grouping_1

    High/grouping_1

    Medium/grouping_1

    Low/grouping_1

     

     

    On the object on wich the new dropdown is needed, add an attribute wich is a SREL to z_dropdown

     

     

    And then I add a dropdown with a whereClause on the z_grouping attribute on a detail form :

     

    <PDM_MACRO name=dtlDropdown hdr="Example" attr=z_typeEvolution factory=z_dropdown whereclause="z_groupement = 'grouping_1'">

     

     

    To add element in the dropdown, you just need to create a new item in z_dropdown with the same z_grouping!

     

     

     

    To manage all this via the GUI, you need to create both list_ and detail_ forms and a custom admin menutree

     

     

     

    If interested I can share the steps involved. Takes maximum one hour to implement.



  • 12.  Re: Customized dropdown with non SREL values

    Posted Dec 27, 2018 04:02 PM

    Thanks pier-olivier.tremblay! Appreciate your time in getting us this detail. We too thought about creating a new table for this but as it had only very few values, we went with the other approach.

     

    We have few other lists where we wanted a conditional drop down. for this we will use this approach. Thanks!