CA Service Management

 View Only
  • 1.  Clearing a field when status update is Resolved

    Posted Feb 16, 2024 09:13 AM

    We have a function that already works to clear the configuration item when new status is Resolved.

    I am trying to write a similar function to set a zenvironment field to empty when status is Resolved.  I wrote the function and I added it to the New Status with a  ; inbetween the functions.  It just doesn't seem to do anything.

    Here is my function:

    function clear_zenvironment_item(e) 
    {
    make_desc_required(e);
        var code;
        if (typeof e != "undefined" && e != null)
        {
            if (e.type  == "select-one")
            {
                code = nx_escape(e.value);
            }
            else
                code = nx_escape(document.main_form.elements["SET.status"].value);
        }
        else
        {
    <PDM_IF "$args.KEEP.DEF_CODE" == "">
            code = default_trans_code;
    <PDM_ELSE>
            code = def_code;
    </PDM_IF>
        }
    // Clear New Configuration Item and Environment field if status changed to Resolved.
    if (code == "RE"){
    nx_escape(document.main_form.elements["KEY.zenvironment"].value = "<empty>");
    nx_escape(document.main_form.elements["SET.zenvironment"].value = "<empty>");
    detailMakeReq("zenvironment");
    } else {
    detailMakeReq("zenvironment", true);
    }
    }

    Here's is my dropdown :

    <PDM_MACRO name=dtlDropdown hdr="<PDM_I18N>New Status</PDM_I18N>" attr=status colspan=2 default="!default_trans_sym!" evt="onBlur=\\\"detailSyncEditForms(this)\\\" onChange=\\\"clear_config_item(this);clear_zenvironment_item(this)\\\"" factory=crs_in initial="!default_trans_code!">



  • 2.  RE: Clearing a field when status update is Resolved

    Posted Mar 18, 2024 07:17 AM

    hi,

    function clear_zenvironment_item(e) {
    	if(e.options[e.selectedIndex].value == "RE") {
    		document.main_form.elements["KEY.zenvironment"].value = "";
    		document.main_form.elements["SET.zenvironment"].value = "";
    		detailMakeReq("zenvironment");
    	}
    	else {
    		detailMakeReq("zenvironment", true);
    	}
    }

    add this to the existing loadActions function:

    function loadActions()
    {
       if ( _dtl.edit ) {
    	   
    	<pdm_if "$args.status" == "RE">
    		detailMakeReq("zenvironment");
    	</pdm_if>