Menu

Custom field based on Service in Portal

metafaniel
2015-03-20
2015-04-13
  • metafaniel

    metafaniel - 2015-03-20

    Is there a way to create a custom field in the Portal, to be visible only if a certain Service or service subcategory is selected?
    I'd like the user to be able to select from a list (combo/options) depending if a certain service has been selected. All other services don't need this custom field.

    Thanks in advance for any given help in thus question!!

     
  • Renzo Parra

    Renzo Parra - 2015-04-13

    I had a similar issue myself. I had 10 different service subcategory and each had their own custom field.

    First you need to add the fields using this guide.

    Second, you have to add a constant to your module naming all of the attributes you wish to show in the Portal:

    <constants></constants>
    <constant id="user-content-PORTAL_USERREQUEST_FORM_ATTRIBUTES" xsi:type="string" _delta="redefine"><!CDATA[title,description,impact,urgency,customattribute1,customattribute2,etc]]></constant>

    I found I could get which service the user selected so I could create a custom array of attributes based on the service subcategory.

    On your root/portal/index.php file you have everything you need to customize your iTop Portal. The fields are shown to the user in the function RequestCreationForm. In that function there's an array with all of the attributes your UserRequest class has and it's called $aList.

    You just have to create a new array with the attributes you want from $aList and then replace the variable $aList from a foreach statement with your own array of attributes.

    I'm attaching my index.php file so you can compare it and find out what I'm talking about.

    PD. You will need the service subcategory id. You can get that by entering the MySQL console and typing:
    select * from servicesubcategory;

     

    Last edit: Renzo Parra 2015-04-13

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.