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.

Parameters to use with reflistOpen?

DarkAvenger
Kilo Expert

Hi,

would anyone know what the parameters are that can be used with reflistOpen()?

cheers

4 REPLIES 4

adiddigi
Tera Guru

I'm pasting the entire function for you :



function reflistOpen(target, elementName, refTableName, dependent, useQBE, refQualElements, additionalQual){
var url = reflistOpenUrl(target, target, elementName, refTableName, dependent, useQBE, refQualElements, additionalQual);
popupOpenStandard(url, "lookup");
}


code of reflistOpenUrl:


function reflistOpenUrl(target, targetElementID, elementName, refTableName, dependent, useQBE, refQualElements, additionalQual) {
var url;
if (useQBE == 'true')
url = new GlideURL(refTableName + '_search.do');
else
url = new GlideURL(refTableName + '_list.do');
url.addParam("sysparm_target", target);
var et = gel(targetElementID);
if (et)
url.addParam("sysparm_target_value", et.value);
var dspEl = gel("sys_display." + targetElementID);
if (dspEl && !et.value)
url.addParam("sysparm_reference_value", dspEl.value);
url.addParam("sysparm_nameofstack", "reflist");
url.addParam("sysparm_clear_stack", "true");
url.addParam("sysparm_element", elementName);
url.addParam("sysparm_reference", refTableName);
url.addParam("sysparm_view", "sys_ref_list");
url.addParam("sysparm_additional_qual", additionalQual);
var v = getDependentValue(target, dependent);
if (v != null)
url.addParam("sysparm_dependent", v);
var refQual = getRefQualURI(target, refQualElements);
return url.getURL() + refQual;
}


Also there is one more _refListOpen with a capital L, which is meant to be a private method( but private methods are not supported in JS anyway, so you can use it too)



_refListOpen: function(evt) {
var te = this.tableElement;
this._setDependent();
var url = reflistOpenUrl(this.refName, this.id, te.getName(), te.getReference());
for (var n in this.additionalValues)
url += "&" + n + "=" + encodeText(this.additionalValues[n]);
if (this.dependentInput)
url += "&sysparm_dependent=" + escape(this.dependentInput.value);
popupOpenStandard(url, "lookup");
return false;
}


http://www.servicenowguru.com/system-definition/advanced-templates/ : Search for reflistOpen, You will find its usage in a script.

Hope this helps!


This was super helpful. You can create so many unique buttons using these functions. I have many use cases for custom applications where a normal SN form is not used, but the user must pick a record from a list.


"I know this post is from 6 years ago, but hoping someone can shed some light on this - I tried hardcoding the sysid of a group in the dependent parameter in the reflistOpen and it does not seem to work, has anyone been able to successfully use the "dependent" parameter here: 

function reflistOpen(target, elementName, refTableName, dependent, useQBE, refQualElements, additionalQual)

The problem I have is that the sysids that I return from a script include in the additionaQual parameter is too long and is not supported by the browser, when I try the OOB assigned to field and look at the url the sysparm_dependent field is being populated with the sysid of the assignment group, trying to replicate something similar in aUI page

 

DarkAvenger
Kilo Expert

Thank you Abhiram.