Can i fetch incidents whose previous or current assignment group as XXXX?

Sayali_9822
Tera Contributor
 
5 REPLIES 5

Moin Kazi
Kilo Sage
Kilo Sage

@Sayali_9822  could you please explain your requirement in details?

 

Regards

Moin

KrishanSharma
Tera Expert

Hi @Sayali_9822,

 

To check for any past values in any field, you can utilize 'sys_audit' table.

You can use a function like this to check for Assignment Group match in the records:

 

getIncidents('YOUR_ASSIGNMENT_GROUP_SYS_ID');

function getIncidents(assignmentGroupID) {
    var incidentIDs = [];
    var audits = new GlideRecord('sys_audit');
    audits.addEncodedQuery('tablename=incident^fieldname=assignment_group^newvalue=' + assignmentGroupID);
    audits.query();
    while (audits.next()) {
        incidentIDs.push(audits.documentkey.toString());
    }
	return incidentIDs.toString();
}

 

 

Note: 'sys_audit' stores huge number of records for all type of audit updates. So, your query might take some time to process.

I hope this helps.

Do i need to create client script or something for this?

 

Can you please share more details on what you're planning to do after fetching those incidents?

 

I've shared a generic script which can be placed in a Script Include function that returns the sys_id of those incident records.