Push a value into a customField in jira with Node JS


#1

Hi,

var request = require('request');

var options = {
   method: 'GET',
   url: 'https://actility.atlassian.net/rest/api/2/issue/SCII-1',
   headers: {
      'Accept': 'application/json',
      'Authorization': 'Basic <****>'
   }
};
request(options, function (error, response,issue) {
   if (error) throw new Error(error);
   console.log(
      'Response: ' + response.statusCode + ' ' + response.statusMessage
   );
   var json = JSON.parse(issue);
   
    //********* Priority Algorithm (var score1) ******** */
    //********* Actility Expected Value Algorithm (var score2) ******** */
    //********* Customer CR Algorithm (var score3)******** */
    //********* Effort Estimate Algorithm (var score4) ******** */
    //********* PM Weight Algorithm (var score5) ******** */   
    //********* Computed Score Card ******** */ 
    var score6 = +80;

   // OUTPUT
   var total = score1+score2+score3+score4+score5+score6;   //!\ How can I push this value into the customfield_14038
   console.log("total: "+total)

});

In my script, i have a variable (var total) with a value and I want to push this value into a customField.
I’m using Node JS.

Thank you in advance for your help

Best regards,
Noreez


#2

Hello @noreez.ulhassanshah,

If I understood your question correctly, you want to put the computed value to the issue’s custom field. The Edit issue REST API might be able to help you out there. You’ve already done a successful REST API call when you did GET so do a PUT and pass the request body with the computed total, something like this

{
  "fields": {
    "customfield_14038": <theComputedTotal>
  }
}

Cheers,
Ian


#3

Understand, Thank you