CA Service Management

 View Only

 How to customize field behavior in the detail_cr form

John Carmino's profile image
John Carmino posted Nov 25, 2021 07:33 AM

Hi guys,

I need help with this case:

I created a custom attribute on the cr object for the user to justify when there is a change in impact or urgency, but the field should only appear in the detail_cr form when the user changes the impact or urgency value.
could someone help me with this?

hermann1815's profile image
hermann1815
Hi,

in detail_cr form at runtime you can only do it with JS/JQuery

For example:

function showcustomfield() {
         if(_dtl.edit)
	{
	 jQuery("[pdmqa='yourfield']").show(); //Value
         jQuery("label:contains('yourfieldheader')").closest('th').show(); //Show Header
	 }
}​


Attach the event. onBlur means it fires when you leave the Field or you can try OnChange. You will find it in all forms.

<PDM_MACRO name=dtlTextbox hdr="Urgency" attr=urgency evt="onBlur=\\\"showcustomfield()\\\"">

<PDM_MACRO name=dtlTextbox hdr="Impact" attr=impact evt="onBlur=\\\"showcustomfield()\\\"">


Hide:

jQuery("[pdmqa='yourfield']").hide();
		 jQuery("label:contains('Header')").closest('th').hide();
		 document.main_form.elements["SET.yourfield"].value = "";​


Untested.
John Carmino's profile image
John Carmino
Hi @Henning1815,

Thanks for your help with my case,

I tried to do it the way you suggested, but I still can't get it to work.
I took another attribute, just to test (template_name), and the field appears on the form even if there is no change in the impact or urgency fields.

Can you help with this?


​​
​​​