Add attachment to MultiRow Variable Set

Community Alums
Not applicable

Hi,

I have a requirement to add attachment to multi-row variable set. When I was searching, I found this link. I am unable to completely edit the script as required. I am not sure about the table name. Kindly help.

 

https://www.servicenow.com/community/itsm-articles/how-to-remove-blocked-datatypes-and-also-allow-th...

 

multirowvariableset.png

 

 

 

var Restrict_types_for_table_variable_set = Class.create();
Restrict_types_for_table_variable_set.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	updateAttachmentData: function(recordID) {
	var attachment = new GlideRecord('sys_attachment');
        attachment.addQuery('table_sys_id', '430feb9a87e09254cc58c846cebb35d2'); //  MRVS Sys ID
        attachment.query();
        while (attachment.next()) {
            attachment.table_sys_id = recordID.toString();// Newly created record sys_id
            attachment.table_name = '<Type your table name>';
            attachment.update();
        }
    },

    type: 'Restrict_types_for_table_variable_set'
});

 

 

 

 

Regards

Suman P.

 

 

6 REPLIES 6

Brad Bowman
Kilo Patron
Kilo Patron

Use 'sc_req_item' if your MRVS is on a Catalog Item, or the Record Producer table.

Community Alums
Not applicable

Hi @Brad Bowman ,

 

What would be table_sys_id? How would we get it?

 

attachment.addQuery('table_sys_id', '<MRVS Sys_id>'); //  MRVS Sys ID

 

Regards

Suman P.

I suspect this is why attachment type variables are excluded from MRVS, or there's another good reason.  If you want to keep the attachments associated with the MRVS, not the RITM or new record on the RP table, you don't have to do anything - the attachments will stay associated with the MRVS.  If you want them to appear at the top of the RITM or RP record as other attachments, you need to change the table_name to sc_req_item or the RP table, and table_sys_id to the new record sys_id instead of the MRVS sys_id.  A thumbnail is created in the attachment table when you do this, so the attachments still appear in the MRVS.

 

In a Record Producer script on the incident table, you can call the Script Include like this:

 

new MRVSUtils().updateAttachmentData(current.getUniqueValue(), 'd372f4ec533d5a10324c17c0a0490e8f', 'incident');

 

Where the middle parameter is the sys_id of the MRVS with an attachment variable.

For Catalog Items, create a before Insert Business Rule on the sc_req_item table with this script:

 

(function executeRule(current, previous /*null when async*/) {
	new MRVSUtils().updateAttachmentData(current.getUniqueValue(), 'd372f4ec533d5a10324c17c0a0490e8f', 'sc_req_item');
})(current, previous);

 

Then change the Script Include function call to accept 3 arguments

updateAttachmentData: function(recordID, mrvsID, tableName)

Najmuddin Mohd
Mega Sage

Hi @Community Alums ,

OOB, you can able to access URL Field in ServiceNow for MRVS

NajmuddinMohd_0-1731067738413.png



If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.