g_approval_form_request and $sp.getRecord(); in EC Pro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2023 09:48 PM - edited 10-18-2023 09:57 PM
We are working on showing the RITM approvals in My Tasks page-EC pro portal
Using the OOB 'Todos Requested Item Approval' widget in Todos configuration , we are able to show only variables not the fields of the RITM. So trying to show all the variables and fields by using custom widget(which is OOB- Approval record- Global scope).
So in this widget they are using a function
g_approval_form_request = true;
var gr = $sp.getRecord();
data.tableLabel = gr.getLabel();
gs.info("Table name is "+ data.tableLabel);
- when I tried to execute the logs we are getting the Approval as a Table label.
But using the same code in Todos requested item widget(EC core scope) doesn't seem to execute the code . It is throwing an error as ErrorServer JavaScript error Cannot convert null to an object.
So I have a query whether the g_approval_form_request = true or $sp.getRecord(); can be used in other scoped applications? or something g_approval_form_request needs to be setanywhere ? I believe we are not able to get the desired o/p only because of these .
Please suggest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2023 10:22 PM
Did you check at which line it threw the error?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2023 10:53 PM - edited 10-18-2023 10:54 PM
@Ankur Bawiskar - Error is coming from this line data.tableLabel = gr.getLabel();
But from the same line I'm able to get the Table label as 'Approval' in Other custom widget which is in Global scope for serviceportal)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2023 11:04 PM
try this
data.tableLabel = gr.getClassDisplayValue();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2023 11:12 PM - edited 10-19-2023 12:13 AM
@Ankur Bawiskar -Thanks, I tried that but its the same error again.
I've written this line of code --data.tableLabel = gr.getLabel(); just to check what value we are getting in $sp.getRecord();
But Instead of returning the table label as Approval its throwing an error.
Please suggest Is that something issue here - even the log for gr-$sp.getRecord(); is getting the same errors
g_approval_form_request = true;
var gr = $sp.getRecord();