- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2016 04:02 PM
This might be one of the weirdest errors I have encountered so far. The new service portal is throwing nullPointerExceptions when I visit the portal as myself, but if I impersonate anyone else it loads just fine. It logs the scripts that are breaking in my console which I will put below. The only thing I can think of that might have messed it up was importing new users from LDAP earlier today. Maybe my user got corrupted or something?
Offending Scripts:
Script 1:
var t = data;
t.items = [];
t.count = 0;
var u = gs.getUser().getID();
// use record watchers to tell header when to update dropdown counts
t.record_watchers = [];
t.record_watchers.push({'table':'sysapproval_approver','filter':'approver=' + u + '^state=requested'});
var z = new GlideRecord('sysapproval_approver');
z.addQuery("approver", gs.getUserID());
z.addQuery("state", "requested");
z.orderByDesc('sys_updated_on');
z.query();
var link = {};
link.title = gs.getMessage('View all approvals');
link.type = 'link';
link.href = '?id=approvals';
link.items = [];
t.items.push(link);
while (z.next()) {
var a = {};
var rec = getRecordBeingApproved(z);
if (!rec.isValidRecord()) // nothing being approved - hmmm
continue;
a.short_description = rec.short_description + "";
if (rec.getRecordClassName() == "sc_request") {
var items = new GlideRecord("sc_req_item");
items.addQuery("request", rec.getUniqueValue());
items.query();
if (items.getRowCount() > 1)
a.short_description = items.getRowCount() + " requested items";
else if (items.getRowCount() == 1) {
items.next();
a.short_description = items.getValue("short_description");
}
}
$sp.getRecordValues(a, z, 'sys_id,sys_updated_on');
a.number = rec.getDisplayValue();
a.__table = z.getRecordClassName();
a.type = 'approval';
t.items.push(a);
t.count++;
}
function getRecordBeingApproved(gr) {
if (!gr.sysapproval.nil())
return gr.sysapproval.getRefRecord();
return gr.document_id.getRefRecord();
}
Script 2:
(function(){if (input && input.op) {
var app = new GlideRecord("sysapproval_approver");
if (app.get(input.target)) {
app.state = input.op;
app.update();
}
}
var gr = new GlideRecord('sysapproval_approver');
gr.setLimit(50);
var qc1 = gr.addQuery("state", "requested");
if (input)
qc1.addOrCondition("sys_id", "IN", input.ids);
gr.addQuery("approver", gs.getUserID());
gr.orderBy("sys_created_on");
gr.query();
var approvals = [];
var ids = [];
while (gr.next()) {
var task = getRecordBeingApproved(gr);
if (!task.isValidRecord())
continue;
ids.push(gr.getUniqueValue());
var t = {};
t.number = task.getDisplayValue();
t.short_description = task.short_description.toString();
if (task.isValidField("opened_by") && !task.opened_by.nil())
t.opened_by = task.opened_by.getDisplayValue();
// requestor >> opener
if (task.isValidField("requested_by") && !task.requested_by.nil())
t.opened_by = task.requested_by.getDisplayValue();
t.start_date = task.start_date.toString();
t.end_date = task.end_date.toString();
t.table = task.getLabel();
if (task.getValue("price") > 0)
t.price = task.getDisplayValue("price");
if (task.getValue("recurring_price") > 0)
t.recurring_price = task.getDisplayValue("recurring_price");
t.recurring_frequency = task.getDisplayValue("recurring_frequency");
var items = [];
var idx = 0;
var itemsGR = new GlideRecord("sc_req_item");
itemsGR.addQuery("request", task.sys_id);
itemsGR.query();
if (itemsGR.getRowCount() > 1)
t.short_description = itemsGR.getRowCount() + " requested items";
while (itemsGR.next()) {
var item = {};
item.short_description = itemsGR.short_description.toString();
if (itemsGR.getValue("price") > 0)
item.price = itemsGR.getDisplayValue("price");
if (itemsGR.getValue("recurring_price") > 0) {
item.recurring_price = itemsGR.getDisplayValue("recurring_price");
item.recurring_frequency = itemsGR.getDisplayValue("recurring_frequency");
}
if (itemsGR.getRowCount() == 1) {
item.variables = $sp.getRecordVariablesArray(itemsGR);
t.short_description = itemsGR.short_description.toString();
}
items[idx] = item;
idx++;
}
var j = {};
j.sys_id = gr.getUniqueValue();
j.table = gr.getRecordClassName();
j.task = t;
if (task)
j.variables = $sp.getRecordVariablesArray(task);
j.items = items;
j.state = gr.getValue("state");
j.stateLabel = gr.state.getDisplayValue();
approvals.push(j);
}
data.ids = ids;
data.approvals = approvals;
function getRecordBeingApproved(gr) {
if (!gr.sysapproval.nil())
return gr.sysapproval.getRefRecord();
return gr.document_id.getRefRecord();
}
})()
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 09:46 AM
Ok I figured this out. In case anyone was wondering, I had an approval for a record that didn't exist anymore in my approvals. This would cause the getRecordBeingApproved method in the index page of the service portal to freak out and generate that massive stack trace. Deleting the approval fixed the issue!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 08:10 AM
Where would it tell me the line number? I found the stack trace if that helps :
java.lang.NullPointerException: org.mozilla.javascript.JavaScriptException: java.lang.NullPointerException: org.mozilla.javascript.Context.makeJavaScriptException(Context.java:1916)
org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1902)
org.mozilla.javascript.MemberBox.invoke(MemberBox.java:143)
org.mozilla.javascript.FunctionObject.doInvoke(FunctionObject.java:637)
org.mozilla.javascript.FunctionObject.call(FunctionObject.java:581)
org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2574)
org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:85)
org.mozilla.javascript.gen._refname__1811._c_getRecordBeingApproved_2(<refname>:93)
org.mozilla.javascript.gen._refname__1811.call(<refname>)
org.mozilla.javascript.ScriptRuntime.doCall2(ScriptRuntime.java:2645)
org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2582)
org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)
org.mozilla.javascript.gen._refname__1811._c_anonymous_1(<refname>:22)
org.mozilla.javascript.gen._refname__1811.call(<refname>)
org.mozilla.javascript.ScriptRuntime.doCall2(ScriptRuntime.java:2645)
org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2582)
org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:23)
org.mozilla.javascript.gen._refname__1811._c_script_0(<refname>:1)
org.mozilla.javascript.gen._refname__1811.call(<refname>)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:560)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3439)
org.mozilla.javascript.gen._refname__1811.call(<refname>)
org.mozilla.javascript.gen._refname__1811.exec(<refname>)
com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:236)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:107)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:73)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:64)
com.glide.service_portal.SPScriptEvaluator.eval(SPScriptEvaluator.java:36)
com.glide.service_portal.widget.SPScriptRunner.eval(SPScriptRunner.java:185)
com.glide.service_portal.widget.SPScriptRunner.runScript(SPScriptRunner.java:82)
com.glide.service_portal.widget.SPWidget.get(SPWidget.java:109)
com.glide.service_portal.widget.SPWidget.get(SPWidget.java:92)
com.glide.service_portal.SPPage.getColumnRectangles(SPPage.java:278)
com.glide.service_portal.SPPage.getRowColumns(SPPage.java:223)
com.glide.service_portal.SPPage.getContainerRows(SPPage.java:203)
com.glide.service_portal.SPPage.getContainers(SPPage.java:190)
com.glide.service_portal.SPPage.getPage(SPPage.java:100)
com.glide.service_portal.SPPage.get(SPPage.java:55)
com.glide.service_portal.SPRestService.page(SPRestService.java:43)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
com.glide.rest.handler.impl.ServiceHandlerImpl.invokeService(ServiceHandlerImpl.java:41)
com.glide.rest.processors.RESTAPIProcessor.process(RESTAPIProcessor.java:228)
com.glide.processors.AProcessor.runProcessor(AProcessor.java:412)
com.glide.processors.AProcessor.processTransaction(AProcessor.java:187)
com.glide.processors.ProcessorRegistry.process(ProcessorRegistry.java:165)
com.glide.ui.GlideServletTransaction.process(GlideServletTransaction.java:49)
com.glide.sys.ServletTransaction.run(ServletTransaction.java:34)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 08:26 AM
Think I found the line number. js_includes_sp.jsx:71081
EDIT: That line is the console.warn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 09:51 AM
Breyton,
Strange... the first error is a Java stack trace because you're getting a Null Pointer Exception, the second error is in the main js_includes file. In the stack trace I see that the error is coming from the server script of a widget... so the question is which widget. Do you get this on every page? Try going to some various pages and see where you get the error. If you get it on every page, then create a new portal record without a theme and go to the portal and see if you still get an error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 09:46 AM
Ok I figured this out. In case anyone was wondering, I had an approval for a record that didn't exist anymore in my approvals. This would cause the getRecordBeingApproved method in the index page of the service portal to freak out and generate that massive stack trace. Deleting the approval fixed the issue!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 09:52 AM
Good to hear you figured it out.