UI Action create new change and open in new tab

Lkr
Tera Contributor

Hello,

 

I would like to receive some help. I have tried to solve this functionality request, but haven't succeeded, so therefore I am reaching out to this amazing community. 

 

I would like to change our current UI action, which creates a change request from a RITM and transfers some of the RITM fields into the Change fields. The change should now include that it also opens the new change in a new window. Currently the ritm window is being refreshed, as per SN default. However, my colleagues would like to keep having the RITM open while opening the change request. 

So how can I add that functionality of opening the change in a new window tab? 

 

I have tried to include it in the script as per other community post solutions and check the client script, but haven't suceeded yet. Errors keep popping up when trying to include both server and client side script in the same ui action. 

 

Let me know if further info is needed. 

 

Thanks! 

1 ACCEPTED SOLUTION

JohnnySnow
Kilo Sage

Hi @Lkr, In UI actions you can pass value from client to server & not the other way around. To open a URL in new window you can use below code(you might have to tweak as per your requirement though):

 

1. Create a Client callable script include

var ChangePopupTest = Class.create();
ChangePopupTest.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getNewWindow: function() {
		
	var parentID = this.getParameter('sysparm_url');

//below code is from the OOTB Create Change UI action      
  var url = new GlideURL("change_request.do");
       url.set("sys_id", "-1");
        url.set("sysparm_query", "^parent=" + parentID);

 		var finalStr = url.toString();
		return finalStr;
    },
    type: 'ChangePopupTest'
});

 

2. In the original Create Change UI action, select 'Client' checkbox, add call below function in the onClick field & add below code in the script.

JohnnySnow_0-1703029535724.png

 

function fetchURL() {
    var ga = new GlideAjax('ChangePopupTest');
    ga.addParam('sysparm_name', 'getNewWindow');
    ga.addParam('sysparm_url', g_form.getUniqueValue());
    ga.getXML(showPopup);

    function showPopup(response) {
        var newURL = response.responseXML.documentElement.getAttribute("answer");
        g_navigation.openPopup(newURL);

    }

}

 

Please mark helpful and correct if it resolved your issue.

Thanks
Johnny

Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

11 REPLIES 11

@Lkr did it resolve the issue? if yes, please accept it as solution

Thanks
Johnny

Please mark this response as correct or helpful if it assisted you with your question.

Lkr
Tera Contributor

@JohnnySnow Thank you, yes it works! 
Would it be in my script include I can add to your script if I would like it to populate description, short description and other fields from the parent REQItem to the new change? Right now the parent is set, which is very good, but I would like further information to get copied as well. 

@Reddy See solution above from JohnnySnow.