Import set still updating record even though no changes have been made

DanielCordick
Mega Patron
Mega Patron

I have integrated with Jira and i im using an import set/transform map to the incident table. I am coalescing on the Number field as i am storing the number in Jira. I am bringing over the comments in jira and transforming to the work notes section. However i am finding that even though no changes have been made, no new comments, nothing new entered on the Jira side, the work notes keep updating with the exact same comment. Shouldn't the record be ignored if no new update have been found?

 

 

Scheduled job i am running to get the info from jira

 

try {

// this will Call the REST Message

var r = new sn_ws.RESTMessageV2('Jira', 'GET-2');

var response = r.execute();

if (response.getStatusCode() == '200') {

var responseBody = response.getBody();

gs.log("REST Call success");


//this will parse the Response

var parser = new JSONParser();
var parsed = parser.parse(responseBody);

var z = parsed["issues"];
//Parse Issues and save to variable "z"

for (i = 0; i < z.length; i++) {

 

//this should create a new record on each loop

var gr = new GlideRecord('u_jira_incident');

gr.initialize();

 

//Map JSON fields to web service table fields
gr.u_description = parsed.issues[i].fields.description;
gr.u_status = parsed.issues[i].fields.status.name;
gr.u_key = parsed.issues[i].key;
gr.u_summary = parsed.issues[i].fields.summary;
gr.u_servicenowurl = parsed.issues[i].fields.customfield_11001;
gr.u_team = parsed.issues[i].fields.customfield_10108;
gr.u_key = parsed.issues[i].key;
gr.u_project_id = parsed.issues[i].id;
gr.u_comments = parsed.issues[i].fields.customfield_10816;
/*Uncomment for debugging

gs.log("ISSUE being sent to the map: " + parsed);

*/

gr.insert();

}

}

} catch (ex) {

var message = gs.info();

}

2 REPLIES 2

Tony Cattoi
Mega Guru

Hi Danny,

Yes, you are correct that typically when updating a record it doesn't update if there are no new changes.  In this case, I think what is going on here is that since the work notes field is a journal entry field it is always going to add the comment.  The journal entry field doesn't contain the data itself so when it compares that data it is always going to see it is a new update. 

Is there any way you can check to see when the last comment was added in Jira and maybe filter out updates that way?  

If not, you have some options to either search the sys_journal_field table and compare or use the getJournalEntry() command in your script.

Hope that helps to get you started.

Thanks,

Tony

thanks! i'll take a look at those suggestions. maybe using the getJournalEntry() command on an onBefore Transform script to compare may work