Import Issues is staying in "Processing" state forever / Import Jira issues webhook events are producing error in designer.


Description

For the Jira projects imported from Jira Application, we have given the option to import the project-related work items using the "Import Issues"  button.

And also, in order to achieve bidirectional sync, we have actions triggered to sync the work item whenever it is updated on Jira Application Side.

The payload sent from the Jira application is mapped to internal fields on the ServiceNow side.

During the recent changes on the Jira application, the payload object has been modified for the "Sprint" column.

While importing any work item which is part of any sprint from Jira application, the mappings are not matched with the payload sent from Jira application.


Steps to Reproduce

Import Jira issues webhook events are producing an error in the designer :

Import Issues is staying in "Processing" state forever  :



Workaround

Navigate to Script Include : ImportSprintUtil and function : getSprintRecord

update the code to get the sprint id from the payload to handle a new payload object as well.

The detailed code has been provided below  for the method getSprintRecord: 

getSprintRecord: function(payload, jiraField, instanceGr, projectGr, snowColumn) {

        var sprintId;

        var sprint;

        if (payload['sprint']) {

            sprintId = payload['sprint']['id'];

        } else {

            var sprintArray = payload[jiraField];

            var maxSequence = -1;

            var actualIndex = -1;

            if (!gs.nil(sprintArray) && sprintArray.length > 0) {

                if (typeof sprintArray[0] === 'string') {

                    for (var index in sprintArray) {

                        if (sprintArray[index].indexOf('state=ACTIVE') > -1 || sprintArray[index].indexOf('state=FUTURE') > -1) {

                            actualIndex = index;

                        } else {

                            var sprintStr = sprintArray[index].substring(sprintArray[index].indexOf('sequence=') + 9);

                            var sequenceValue = Number(sprintStr.substring(0, sprintStr.indexOf(',')));

                            if (sequenceValue > maxSequence) {

                                maxSequence = sequenceValue;

                                actualIndex = index;

                            }

                        }

                    }

                    sprint = sprintArray[actualIndex];

                    sprintId = sprint.match(/id=([0-9]+)/)[1];

                } else {

                    for (var objIndex in sprintArray) {

                        var sprintObj = sprintArray[objIndex];

                        if (!gs.nil(sprintObj) && !gs.nil(sprintObj.id)) {

                            sprintId = sprintObj.id;

                            if (!gs.nil(sprintObj.state) && (sprintObj.state.toLowerCase() === 'future' || sprintObj.state.toLowerCase() === 'active')) {

                                break;

                            }

                        }

                    }

                }

            }

        }

        var sprintTableName = this.getSprintTable(snowColumn);

        var commonIntUtils = new sn_int_common.CommonIntegrationUtils(this.integrationTypeGR);

        var externalIDs_GR = commonIntUtils.getExternalIDRecord(sprintTableName, projectGr, "external_id", sprintId);

        var recordExists = false;

        if (externalIDs_GR)

            recordExists = externalIDs_GR.isValidRecord();

        var gr = new GlideRecord(sprintTableName);

        var sprintSysId = '';

        if (!gs.nil(sprintTableName) && recordExists && gr.get(externalIDs_GR.getValue('reference_value'))) {

            var sprintState = gr.getValue('state');

            if (sprintState === '3' || sprintState === '4') {

                var choiceMap = new sn_int_common.ChoiceMapConfig();

                var issueState = choiceMap.getInternalChoice(projectGr.mapping_config.getRefRecord(), sprintTableName, 'state', payload['status']['id'], this.integrationTypeGR);


                if (!gs.nil(issueState) && !this._isCompletedState(sprintTableName, issueState))

                    return sprintSysId;

            }

            sprintSysId = gr.sys_id;

        }

        return sprintSysId;

    }

 

 

This community article has the script include file attached.

https://community.servicenow.com/community?id=community_article&sys_id=b60d29e7db6f1410f21f5583ca9619e9



Related Problem: PRB1427673