Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Take user to record producer when New button clicked

krr
Mega Guru

Is there an OOTB method to direct users to a Record Producer when they click the New button on a related list, or is only achieved through an onLoad Client Script and use g_navigation.open method?

1 ACCEPTED SOLUTION

Rajesh Kannan G
ServiceNow Employee
ServiceNow Employee

There are many approaches, if you want to redirect only when clicking New button in a related list then you can create "New" UI Action on that table with Action Name "sysverb_new" to override the existing UI Action, use this as condition to display the UI Action for just Related Lists current.canCreate() && !RP.getListControl().isOmitNewButton() && RP.isRelatedList() && !RP.isManyToMany() and in script you can redirect to the Record Producer using action.setRedirectURL(recordProducerUrl);

If you want to redirect everywhere in the Platform UI then use Navigation Handler. Refer this documentation for details about Navigation Handler and use below sample script

https://docs.servicenow.com/bundle/orlando-platform-user-interface/page/administer/navigation-and-ui...

(function() {
	var recordProducerUrl = '';
	var sysId = g_request.getParameter('sys_id');
	if (gs.nil(sysId) || !isValidRecord(sysId)) 
		return g_uri.toString(recordProducerUrl));
	
	return "";
})();

function isValidRecord(sysId) {
	var gr = new GlideRecord(your_table);
	return gr.get(sysId);
}

Regards,

Rajesh

View solution in original post

1 REPLY 1

Rajesh Kannan G
ServiceNow Employee
ServiceNow Employee

There are many approaches, if you want to redirect only when clicking New button in a related list then you can create "New" UI Action on that table with Action Name "sysverb_new" to override the existing UI Action, use this as condition to display the UI Action for just Related Lists current.canCreate() && !RP.getListControl().isOmitNewButton() && RP.isRelatedList() && !RP.isManyToMany() and in script you can redirect to the Record Producer using action.setRedirectURL(recordProducerUrl);

If you want to redirect everywhere in the Platform UI then use Navigation Handler. Refer this documentation for details about Navigation Handler and use below sample script

https://docs.servicenow.com/bundle/orlando-platform-user-interface/page/administer/navigation-and-ui...

(function() {
	var recordProducerUrl = '';
	var sysId = g_request.getParameter('sys_id');
	if (gs.nil(sysId) || !isValidRecord(sysId)) 
		return g_uri.toString(recordProducerUrl));
	
	return "";
})();

function isValidRecord(sysId) {
	var gr = new GlideRecord(your_table);
	return gr.get(sysId);
}

Regards,

Rajesh