Data Import Using Service Catalog

neethu4
Giga Expert

Hi All,

I want to create a catalog item which will help to import the file to CMDB table.My thought is on submit of the the request trigger the data source and pass the attachment to it.

But don't know how to achieve it.

Please let me know if any suggestion on this

Thanks,

Neethu

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Neethu,



That's correct.


1) Have business rule after insert on RITM table which runs only for that particular Catalog Item.


2) Have a data source, transform map and field map created as usual. coalesce etc will be present


3) Have scheduled import created with this data source with active= false, run as administrator since it will be triggered from script. In left nav type Scheduled Imports and create new


4) in the business rule condition check whether the RITM has attachment then only run the business rule and have following script



Business rule condition:


current.hasAttachments()


//extra check you can have is whether it is csv or xls based on data source attachment file type



Business rule script:



var dataSourceSysId = ''; // sys_id of the data source you created in step 2


var schImp_GR = new GlideRecord('scheduled_import_set');


schImp_GR.addQuery('data_source',dataSourceSysId);


schImp_GR.query();


if(schImp_GR.next()){


gs.executeNow(schImp_GR); // use this if it is in scoped app


//SncTriggerSynchronizer.executeNow(schImp_GR); // if in non-scope app i.e. global



// the above 2 lines will start the import process, etc automatically


}



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

View solution in original post

25 REPLIES 25

Hi Neethu,



Since there is no direct relationship between import log table and RITM table you can't bring it.


But you can try to check in import log table for that specific data source and log created in last 15/30 mins and try to bring some notes and populate in work notes of RITM.



Regards


Ankur


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

Hi Ankur,

I have the same requirement to create records in a table from attachment. But I don't want to copy the attachment to the data source. I'm able to read contents from the attachment.

How to insert the contents into a ServiceNow table.

Could you please help me with this?

 

Hi Deepak,

It would be nice and recommended to attach to data source and let transform map etc do the rest.

Regards

Ankur

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

Hi Ankur,

When the attachment is attached to a catalog item, the content from the attachment should create a record in a ServiceNow table(ex: CMDB). How can I create records from the attachment using the workflow script?

 

Hi Deepak,

I think what you want to perform is already present in the answer marked as correct. you can follow those steps.

you should be able to achieve that.

Regards

Ankur

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