Retrieve MVRS values using OOB REST APIs

karanpreet
Tera Guru

Hello,

I have a requirement to retrieve MVRS table values using the REST API. I tried looking into the sc_multi_row_question_answer table but somehow I don't have access to view or query that table although I can see the list/table in the task and request and am able to see the required entries.

Shouldn't I already have access since I'm able to view it on the TASK UI but not the table? Also, directly trying to access the table also produces a security restriction.

Is there any way I can get the variable values for the task including the MVRS using the OOB REST APIs? 

Thanks,
Karan

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@karanpreet 

which user you are using? did you try to visit "sc_multi_row_question_answer" directly using this syntax sc_multi_row_question_answer.LIST

are you able to see the data?

you can get the MRVS json if you consume the Table API on sc_req_item table

Another way is this to use Scripted REST API

How to fetch Multirow variables on RITM/SCTASK using REST api 

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

I'm using a user with limited permissions that mostly has ITIL and Event Management role.

 

Directly trying to access the table sc_multi_row_question_answer gives me "Security constraints prevent access to requested page"

 

Can you elaborate on how "you can get the MRVS json if you consume the Table API on sc_req_item table"?

I tried to get the sc_req_item with the sysparm_fields including variables.<table_var> but get a blank field as a result.

@karanpreet 

you can use scripted REST API for this

RITM Variables SRAPI 

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

Pranesh072
Mega Sage
Mega Sage

OOB API will use the authentication user role to fetch these values. If you are using itil or basic role, they will having limited access and not able to access the sc_multi_row_question_answer

var gr = new GlideRecord('sc_req_item');

if (gr.get('<SYS_ID OF RITM>'))
{
// Syntax for this is gr.variables.table_var which returns JSON array value as String
gs.log( "1.variables "+ gr.variables.server_build_list);
}

// Syntax for this is gr.variables.table_var.getRow(<ROW NUMBER [i]>) which returns ith row from the multi row variable
// and we are trying to access a cell out of it as below

var row = gr.variables.server_build_list.getRow('1');
gs.log( "Fetching Row 1 "+ row.u_data_center);

// Syntax for this is gr.variables.table_var.getRowCount( ) which returns current row count
gs.log( "Row Count "+gr.variables.server_build_list.getRowCount())

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0743684