CA Service Management

 View Only

 pre select category in dropdown detail_cr

Domagoj Hrzic's profile image
Domagoj Hrzic posted Jan 02, 2025 09:39 AM

    Hello, 

any help would be appreciated regarding this customization.

On home.htmpl I created an link to open a form to create a new request for category Category:

 <tr>
    <td style="padding-left: 15px; height: 30px">
        <PDM_LINK OP=CREATE_NEW FACTORY=cr PRESET_REL="category:pcat.id:sym:Category" class="emp portlet_body_text" style="font-size:0.9em;" PRESET="description:Category">Category</PDM_LINK>
    </td>
    </tr>

and in detail.htmpl added an dropdown where the category should be pre-selected (or hidden) when the detail_cr is loaded.

<PDM_MACRO name=dtlDropdown hdr="Category" attr="category" autofill=yes codename="" factory=pcat_cr_ss initial="pcat:403381" list_display="$list.description" lookup="no" make_required="yes" rel_attr_name="REL_ATTR" size=30 use_list_display="1" whereclause="sym = 'Category'">

Generated HTML:

<select id="df_1_1" pdmqa="category" tabindex="100" onfocus="return detailFocus(this);" onblur="return detailBlur(this);" title="Kategorija (required)" name="SET.category">
<option selected="" value="pcat:403381">Category
</option></select>

but in the GUI the option is not selected.

I suppose some JS should be implemented to populate the field and show related properties fields when the link is selected on home.htmpl?

Best Regards,

Domagoj

Domagoj Hrzic's profile image
Domagoj Hrzic

An option could be also to have an pre-selected category read-only field, and some fields shown depending on the category persid or name.

Regards,

Domagoj

Aleksandar Stancic's profile image
Aleksandar Stancic

Hi Domagoj,

i had similar request and this was the solution.

in home.htmpl define JS function

function myCreate(id, pcat)
        {
            if(typeof ahdtop.ticketObj == "object")
            ahdtop.ticketObj.resetTicket();
            var url=cfgCgi+
            "?SID="+cfgSID+
            "+FID="+fid_generator()+
            "+OP=CREATE_NEW+FACTORY="+pcat+"+PRESET=category:pcat:" + id;
            window.location=url;
        }

and in link part reference it like this 

<td style="padding-left: 15px;">
<a href="javascript: myCreate('402115','cr');"
   class="emp portlet_body_text"
   onmouseover='window.status = "Create a new Request"; return true;'
   onmouseout="window.status = window.defaultStatus; return true;">LABEL FOR CATEGORY</a>
</td>
where 402115 is id of category in prob_ctg table
hope it helps you