How to create an incident if the import set state is complete with errors

Dhanu1
Tera Contributor

Hi Team,

In our instance we have created scheduled jobs with import sets , If import set state is complete with errors then it should generate an incident like below requirement.

If any of the jobs fail to download the csv file from SFTP data source an incident should be generated and sent to Service Desk as  assignement group. This incident should contain details of the error and exception. This can be due to missing files, wrong credentials or any number of issues.

Thanks

6 REPLIES 6

Arun_S1
Tera Guru
Tera Guru

@Dhanu1 on the transform map of the import set

1. you can write an "onComplete" which should query on the import set table for the records created with the same import set number.

2. check if there are failures and trigger the incident incident creation process.

 

Please mark the appropriate response as correct answer and helpful.

Thanks!!

weizheng
Tera Contributor

Hello @Arun_S1 ,
   I need create new incident automatically when the transform map is failed with state 'Complete with errors'. So  I create onBefore script and set error = true in it, then I run the transform map. Unfortunately,when the state is 'Compete with error', onComplete will not be triggered.   The onComplete script is only trigger when the transform state is 'Complete'. Do you know how to trigger onComplete script when the transform state is 'Complete with errors'?  Thanks in advance.

ShubhamGarg
Kilo Sage

Hello @Dhanu1 ,

Not sure if your issue already got resolved. However, this requirement is easily achievable by following steps -

1. Create a Business Rule which runs on Transform History table [sys_import_set_run] when state changes to 'Complete with Errors'. Update flag = true; Insert flag = false.

Note -

Transform History is a M2M table and it not only gives the import set number but tranform map and data source reference also.

 

2. Put this code in Script section - 

var grInc = new GlideRecord('incident');
grInc.initialize(); 
grInc.short_description = 'Import set number: ' + current.set + 'got failed';
//More field values can be adapted as required. grInc.insert();

 

Let me know if it helps or you need any further help on this.

 

Mark this as Accepted Solution/Helpful if applicable.

 

Regards,

Shubham

Hi @ShubhamGarg ,

 

Thanks for this post.I used this approach.This is working but I have few doubts.

1.  if applying condition on BR state changes to complete .As import state changes to complete OR clasue total is 150 as imported data count is 150..When job is running ,Duplicate incidents are being created.

2.I have one on complete script as below.But I am getting total count as 100 in logs  instead of correct one.As i have 150 records with import set and all are updated correctly with import run. Could you please help me on this also.