Create service request through attachment

Vishnupriya15
Tera Contributor

Hello,

I have a requirement to create a service request from another catalog item XYZ.

If XYZ catalog item will be submitted with Attachment(This attachment has data to create request like  user name and hardware details) and post approval of this XYZ request, we need to create RITM's automatically based on the data given in the attachment. If this attachment has 4 Rows of data - we need to create 4 RITM

 

Any help Appreciated!!

 

Thanks!!

3 ACCEPTED SOLUTIONS

Ubada Barmawar
Giga Guru

Hi @Vishnupriya15 

 

I really hope this solution will workout.

 

its better to use flow designer for this task

 

step 1 : trigger flow on catalog item, get catalog variables if wanted.

step 2 : use a custom action with script to check if the submitted record has any attachment(glide to sys_attachment table and filter by current sys_id)

step 3 : upon approval, copy the attachments from submitted record to the data source(create data source, transform map, and scheduled data import(inactive), and include post import script to delete the attachments after import) and execute the scheduled import.

 

this may help: Automate Data import from Excel File Attachment vi... - ServiceNow Community

 

for scoped: post import script can be:

 

var dataSourceSysId = data_source.getValue('sys_id');
var attObj = new GlideRecord('sys_attachment');
attObj.addQuery('table_name', 'sys_data_source');
attObj.addQuery('table_sys_id', dataSourceSysId);
attObj.query();
if (attObj.next()) {
    attObj.deleteMultiple();
}

 

please mark as accepted if this helps, Im very sure that this will workout.

 

regards,

Ubada Barmawar.

 

View solution in original post

the no of rows doesnt matter, all rows will be imported. just copy the attachment to data source using 

 

var attachment = new GlideSysAttachment();
var attached = attachment.copy('table_name', 'TablesysID', 'sys_data_source', 'datasource_sysID' );
    if(attached){
            gs.executeNow('Scheduleimportrecord');//execute the scheduled data import
        }
 
 
 

map all the data in excel to the target record properly using transform map and Import set, you'll get the import set execution in scheduled data import related list

 

please mark this as accepted and helpful

View solution in original post

yes, you can achieve this through BR, just need to find a way to trigger it on approval. same scripts can be used with little to no changes.

View solution in original post

6 REPLIES 6

yes, you can achieve this through BR, just need to find a way to trigger it on approval. same scripts can be used with little to no changes.

Hi, 

 

1. Created a Catalog item - Name- XYZ

2. Created a data source and transform map - to create new Bulk catalog item named as- ABC

3. Created a scheduled import

4. Created business rule to copy attachment from RITM to Datasource and run schedule import.

The above scenario is working fine

 

Please help in the scripting below final requirement:

 

After the data import, copy the import status from sys_import_set_run table to the RITM work notes (XYZ - catalog) and mark the RITM as "Closed Complete"