I am using Google Scripts to try and read worklog entries. I can get to most of the issues fields but get an undefined error when I try to access worklog related fields. I have time tracking turned on and I have the permissions for time entry set. What am I doing wrong?
var fetchArgs = {
contentType: "application/json",
headers: {"Authorization":"Basic "+encCred},
muteHttpExceptions : true
};
var jql = "?jql= issuetype=task order by created DESC";
Logger.log("jql = " + jql);
var httpResponse = UrlFetchApp.fetch(baseURL + jql, fetchArgs);
Logger.log("httpResponse = " + httpResponse);
if (httpResponse) {
var rspns = httpResponse.getResponseCode();
switch(rspns){
case 200:
var data = JSON.parse(httpResponse.getContentText());
var issuessss = [];
for(var id in data["issues"])
{
// Check the data is valid and the Jira fields exist
if(data["issues"][id] && data["issues"][id].fields) {
var status = data["issues"][id].fields.timespent;
Logger.log("timeSpent = " + timeSpent);
var worklogdate = data["issues"][id].fields.worklogdate;
Logger.log("worklogdate = " + worklogdate);
var type = data["issues"][id].fields.issuetype.name;
var reporter = data["issues"][id].fields.reporter.displayName;
var summary = data["issues"][id].fields.summary;
Logger.log("type = " + type + "-" + reporter + " " + summary);
issuessss.push([type,reporter,summary]);// adding each issue data to 2D array
}
}
Hi @Sigmund VanDamme -- Welcome to the Atlassian Community!
One way to check the names of the fields, and what is supported, is to make a call to the REST API and then parse the JSON to see what is there. So pick a Jira issue you know has the data you want and use that issue.
Here is the how-to for that method:
https://support.atlassian.com/jira-software-cloud/docs/find-the-smart-value-for-a-field/
Best regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.