Help with g_navigation.openPopup

Steve Chapman
Tera Contributor

Hi All,

I have created a UI Action that is designed to allow a Change requester to click a button and see a list of other changes with a specific set of conditions already built in and have it open in a new tab/window.

When i had this as a server side UI Action using action.setRedirect the resultant list showed perfectly as the list of changes with conditions built in, however, our Change function wanted this to open in a new tab/window.

I reworked the UI Action to be 'Client' and swapped the action.setRedirect for g_navigation.openPopup(url) - url added as a var.

Again this was not quite perfect as the new window opened as wanted and a list appeared, however, the conditions were present but needed to be manually run.

My question is, how can i get the conditions to run automatically using the g_navigation approach??

Please see script below and any assistance greatly appreciated;

function scheduleAssist() {

//gs.log("VRS: StartDate == " + g_form.getValue("start_date")+ " EndDate == "+ g_form.getValue("end_date"));
var unparsedValueStart = g_form.getValue("start_date");
var unparsedValueEnd = g_form.getValue("end_date");

var parseStartDate = unparsedValueStart.split(" ");
var parseEndDate = unparsedValueEnd.split(" ");

var parseStartTime = parseStartDate[1].split(":");
var parseEndTime = parseEndDate[1].split(":");

var url = "/change_request_list.do?sysparm_query=start_date%3C%3Djavascript%3Ags.dateGenerate('"+parseEndDate[0]+"'%2C'"+parseEndTime[0]+"%3A"+parseEndTime[1]+"%3A"+parseEndTime[2]+"')%5Eend_date%3E%3Djavascript%3Ags.dateGenerate('"+parseStartDate[0]+"'%2C'"+parseStartTime[0]+"%3A"+parseStartTime[1]+"%3A"+parseStartTime[2]+"')%5Eactive%3Dtrue";


g_navigation.openPopup(url);

}

 

11 REPLIES 11

If you are referring to hard coding the dates i am using as part of the conditions, unfortunately i can't do that as they are going to be different on every change?!

Thanks

Hi Steve,

That should be fine; just check whether the url is formed correctly before it redirects

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Apologies Ankur,

Not sure i am understanding what you mean by "check whether the url is formed correctly before it redirects"

It works perfectly via setRedirect, what would i need to check??

Kind regards

Hi Steve,

try to add alert for the url

var url = "/change_request_list.do?sysparm_query=start_date%3C%3Djavascript%3Ags.dateGenerate('"+parseEndDate[0]+"'%2C'"+parseEndTime[0]+"%3A"+parseEndTime[1]+"%3A"+parseEndTime[2]+"')%5Eend_date%3E%3Djavascript%3Ags.dateGenerate('"+parseStartDate[0]+"'%2C'"+parseStartTime[0]+"%3A"+parseStartTime[1]+"%3A"+parseStartTime[2]+"')%5Eactive%3Dtrue";

alert(url);

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

Have added the alert in as you have suggested and all appears well, it appears to be the same just with the inclusion of the dates required.

Please see below screen snip

Kind regards

find_real_file.png