g_approval_form_request and $sp.getRecord(); in EC Pro

Nagashree5
Tera Contributor

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

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Nagashree5 

Did you check at which line it threw the error?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@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)

Nagashree5_0-1697694833868.png

 

 

@Nagashree5 

try this

data.tableLabel = gr.getClassDisplayValue();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@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();