Open utterances-bot opened 2 years ago
I love this and I am working through your 4 suggestions for better approvals. I did run into a problem on the Server Script (and I'm not good enough at js yet to figure it out). I added your code as suggested but then on my line 62 I get an error. The line is "data.items = items" and the error is "Expected ')' to match '(' from line 1 and instead saw 'data'." Any ideas?
Awesome post. Thanks for the info.
I note however this shows ALL the fields on the table, including the 'additional comments', 'work notes' etc. These are always blank as it's now showing the activity stream. How would you go about amending the code to note display a field on the form?
Disregard my comment above. Shortly afterwards i realised i was looking at a view. I've setup a portal view to only show the fields I require. Thanks again for the post.
I would love to get this suggestion in flight - however, running into issues as tdsutherland and I get "no record found" when I try to view. Can I get some help with this? Can anyone send/share the entire code the got this to work?
Thank you!
Hi David,
This is exactly wht I'm looking for. but have a couple of issues
Similar to mosesvil issue, I only want it to display the approval view to match the Service-Now main in this widget, but not sure how to proceed. I do need the full version of my forms in another part of the portal. Any Suggestions appreciated
The other issue is if the Req has more than one RITM the approval request will only display the 1st one. This I solved myself by first checking the rows return and if greater than 0 ran the original code Here is my modified version
var rowCnt = itemsGR.getRowCount();
if (rowCnt > 0) {
//original code Start
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) {
item.variables = new GlobalServiceCatalogUtil().getVariablesForTask(itemsGR, true);
item.variableSummarizerWidget = $sp.getWidget('sc-variable-summarizer', {
'variables': item.variables,
'toggle': false,
'task': t.number.value
});
}
items[idx] = item;
idx++;
} //original code end
} else {
// Get fields of a non-RITM record.
// The "task" variable should already be a
// GlideRecord of what is being approved.
data.table = task.getTableName();
data.f = $sp.getForm(task.getTableName(), task.sys_id);
for (var prop in data.f._fields) {
data.f._fields[prop]["sys_readonly"] = true;
}
}
I figured out the view issue, I needed to create a new view called 'sp', then cofigure this view to only show what I wanted. (I assume the view name needs to match the name your portal)
Gday @rpcallan. No worries, happy you found what was going on there. Yea the sp-form wiget will first try to use the "sp" form view by default. Fun fact is that you can specify the form view you want to use when your widget server code configured the widget, but typically creating a view for "sp" does the job.
Hello, thank you for this guide. It worked perfectly but I am still experiencing an issue.
Initially I only have default view, so it displayed all fields. I've since created an 'sp' view, but the page continues to display default view. How do I specify the view to display?
Better SN Approvals #2 - Full Form, Not Summary
ServiceNow approvals are incredibly useful, but they do have some rough edges out-of-the-box, such as the approval page not showing all of the details.
https://davidmac.pro/posts/2021-01-30-approval-page-form/