Jump to content
Sign in to follow this  
henning1518

Open/save rootcause form in reading-mode?

Recommended Posts

Hi,

is it possible to open the rootcause "selection form" in reading-mode when the rootcause is empty and someone is clicking the SOLN-Button?

Button:

ImgBtnCreate("btnSOL", "Solution", 'openrootcause();', 1, 0);
openrootcause()
{
<PDM_IF "$args.rootcause" == "">
1. open rootcause selection
2. Update and save ticket
}
 

Thanks a lot :)

Share this post


Link to post
Share on other sites

Found a solution from cdtj that changes the ticket status with a button. I adapted it with my needs and know it´s really ugly (Hope it will not causes problems in future):

function empty_rootcause() {
	 alert("First enter a rootcause!");
	 window.localStorage.setItem('rootcause_empty', 'yes');
	 console.log(localStorage);
	 var status = 'KE';
     var query_str = cfgCgi + "?SID=$prop.SID+FID=$prop.FID+OP=UPDATE" +
     "+FACTORY=cr+PERSID=" + "$args.persistent_id" + "+KEEP.new_status=" + status;
     browseWithURL(query_str);
}


function open_rootcause() {
	<PDM_IF "$args.rootcaue" == "" && "$prop.form_name_3" == "edit">
     function emptytrue() {
          if (currentAction == 0 && localStorage.getItem("rootcause_empty") == "yes") {
               clearInterval(myInterval);
               ahdframe.document.getElementsByName('SET.status')[0].value = "$args.KEEP.new_status";
			   jQuery("label[for='df_5_2']")[0].click();
			   window.localStorage.removeItem('rootcause_empty');
			   console.log(localStorage);
          }
     }
     if (('$args.KEEP.new_status' != '') && ('$prop.form_name_3' == 'edit')) {
          var myInterval = setInterval(emptytrue, 100);
     }
	 </PDM_IF>
}
ImgBtnCreate("btnSOLN", "Solution", 'empty_rootcause();', 1, 0);
<body class="detailro" onload='loadActions();open_rootcause();' onunload="unloadActions()">

Thanks @cdtj :)

Edited by henning1518

Share this post


Link to post
Share on other sites

Looks a bit strange but good if works :)

Don't forget to remove console.log or add check that console is object (typeof console != "undefined") or code will fail on IE.

Also you're passing unique variable in KEEP array so you can avoid localStorage which also browser specific (nothing bad could happen if IE7 which is million years old is not used in your company):

function empty_rootcause() {
	var status = 'KE';
	var query_str = cfgCgi + "?SID=$prop.SID+FID=$prop.FID+OP=UPDATE" +
		"+FACTORY=cr+PERSID=" + "$args.persistent_id" + "+KEEP.new_status=" + status;
	browseWithURL(query_str);
}

function open_rootcause() {
	<PDM_IF "$args.rootcaue" == "" && "$prop.form_name_3" == "edit" && "$args.KEEP.new_status" != "">
		function emptytrue() {
			if (currentAction == 0) {
				clearInterval(myInterval);
				jq('[name=SET.status]').val("$args.KEEP.new_status");
				jq("label[for='df_5_2']")[0].click();
			}
		}
		<PDM_IF "$args.KEEP.new_status" != "" && "$prop.form_name_3" == "edit">
			var myInterval = setInterval(emptytrue, 100);
		</PDM_IF>
	</PDM_IF>
}

PS: More PDM_IF tags less onform code for client

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×