Showing MRVS on SC_Task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello Community,
I am trying to display MRVS present on catalog item to sc_task genenrated after approving the RITM.
I am using client script and script include, but not able to show MRVS on sc_task.
Only problem is HTML table is not appearing on sc_task by using jQuery or setValue() using the HTML field.
MRVS is appearing on info message when I am using gs.info() to get table.
Please provide insights on how to solve this problem.Help would be greatly appreciated.
Thank you!
Find attached SScreenshot of gs.info() displaying MRVS:
Please find below client script and script include:
Note : script include is Client callable and Client script is on sc_task (Onload) and isolated is unckecked
Script include:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @tanvipalkar
On the server side (Script Include), your logic correctly queries the MRVS and builds a JSON object.
On the client side, you are building the HTML table and trying to inject it into the form (addInfoMessage, jQuery().after(), or setValue() into an HTML field).
The problem is:
- jQuery selectors (#element\\.sc_task\\.project_type) do not always work in the scoped UI of ServiceNow — especially in newer UI (UI16, Workspace).
- HTML fields in forms sanitize or strip injected HTML when using g_form.setValue(). That’s why your table does not render.
- addInfoMessage() works because that API accepts raw HTML.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @Rafael Batistot
Thanks for reply.
How to resolve this problem?
Is there any solution to build html table on sc_task variable section?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @tanvipalkar
May your try use a “Display” field (String/HTML) on sc_task
- Create a new field on sc_task (e.g. u_mrvs_display).
- Populate it with formatted MRVS values when the task is created:
- Use a Business Rule on sc_task after insert (or on the RITM → Task creation logic).
- Server-side, query sc_multi_row_question_answer for the RITM’s MRVS answers.
- Build an HTML table string.
- Set current.u_mrvs_display = htmlString.
- On the form, configure the field to display as HTML type, so the table renders properly.
This avoids client-side injection issues and keeps the MRVS snapshot stored with the task.
2. Use addInfoMessage() onLoad (quick & dirty)
- You already saw this works.
- You can keep using g_form.addInfoMessage(htmlTable) in the onLoad client script.
- Downside: it won’t be stored in the record, and it disappears if the form reloads without the script.
Use a “Display” field (String/HTML) on sc_task
- Create a new field on sc_task (e.g. u_mrvs_display).
- Populate it with formatted MRVS values when the task is created:
- Use a Business Rule on sc_task after insert (or on the RITM → Task creation logic).
- Server-side, query sc_multi_row_question_answer for the RITM’s MRVS answers.
- Build an HTML table string.
- Set current.u_mrvs_display = htmlString.
- On the form, configure the field to display as HTML type, so the table renders properly.
This avoids client-side injection issues and keeps the MRVS snapshot stored with the task.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Why on earth would you go through all of this in an attempt to replicate out of box functionality? If you want to display a MRVS on a Catalog Task, add it to the Catalog Task activity in Workflow Editor or Flow Designer.