Live Field Error as "Live Field not configured for the Project

Sarika February 11, 2021

Hi ,

I have Created a webitem in the issue screen as below 

<web-item name="jiraButton" i18n-name-key="jiraButton.name" key="jiraButton" section="operations-top-level" weight="1">
<description key="jiraButton.description">The jiraButton Plugin</description>
<label key="Create Jira Project"></label>
<link linkId="jira-button-link"/>
<tooltip key="Automatically create a new Jira project with information of the displayed Jira Issue"/>
<conditions type="AND">
<condition class="com.ebmpapst.jira.projectcreator.ProjectVisibleCondition">
<param name="Project-Management">Project Management</param>
</condition>
<condition class="com.ebmpapst.jira.projectcreator.ProjectMemberVisibleCondition">
<param name="Project-members">Projectmembers</param>
</condition>
</conditions>
</web-item>

 

It has related java script file as below 

var baseUrl=window.location.origin;

AJS.$(document).ready(function()
{

AJS.toInit(function () {

AJS.$("#jira-button-link").click(function (eve) {
//eve.preventDefault();

getFunction();
});
});

});

function getFunction()
{
AJS.$.ajax
({

url: ((baseUrl=='http://localhost:2990')?(baseUrl+'/jira'):(baseUrl)) +'/rest/api/2/issue/'+ encodeURI(JIRA.Issue.getIssueKey()),
type: "GET",
timeout: 0,
dataType: 'json',
processData: false,
headers: {
"Content-Type": "application/json; charset=utf-8"
},

success: function (response)
{
console.log(JSON.stringify(response));
// console.log(JSON.stringify(response.fields.assignee.key));
if(response.fields.assignee == null){
alert("Jira project can't be created. Please assign the issue to an active Jira user!");

}
else{

if (!hasProject(response.key.toString())) {
createProject(response.key.toString(), response.fields.summary, response.fields.assignee.name, ((baseUrl == 'http://localhost:2990') ? (baseUrl + '/jira') : (baseUrl)) + '/browse/' + encodeURI(JIRA.Issue.getIssueKey()));
}


}

console.log(((baseUrl=='http://localhost:2990')?(baseUrl+'/jira'):(baseUrl)) +'/browse/'+encodeURI(JIRA.Issue.getIssueKey()));
},

error: function (response)
{
console.log(response);
}

});
}
//This Project checks whether the project already exist
function hasProject(keyValue) {

keyValue = keyValue.replace("-", "");

AJS.$.ajax
({

url: ((baseUrl=='http://localhost:2990')?(baseUrl+'/jira'):(baseUrl)) +'/rest/api/2/project/' + encodeURI(keyValue) ,
type: "GET",
timeout: 0,
dataType: 'json',
processData: false,
headers: {
"Content-Type": "application/json; charset=utf-8"
},

success: function (response) {
console.log(JSON.stringify(response));
alert("Jira project can't be created. Project already exists!");
return true;
},

error: function (response) {
console.log(response);
// alert("Jira project has error in creating ");
return false;

}
});
}

function createProject(keyValue,summary,lead)
{
var originalKeyValue = keyValue;

keyValue = keyValue.replace("-","");
console.log(keyValue);


summary = summary.trim();
console.log(summary);

AJS.$.ajax
({

url: ((baseUrl=='http://localhost:2990')?(baseUrl+'/jira'):(baseUrl)) +'/rest/project-templates/1.0/createshared/'+
((baseUrl=='http://localhost:2990')?('10000'):('13303')),
type: "POST",
timeout: 0,
dataType: 'json',
processData: false,
headers: {
"Content-Type": "application/json; charset=utf-8"
},
data: JSON.stringify({
"key": keyValue,
"name": originalKeyValue+" "+summary,
"lead": lead,
"projectTypeKey": "business"
}),


success: function (response) {
console.log(JSON.stringify(response));
alert("Jira project has been created. Now you will be navigated to the project summary screen.");
window.location.replace(((baseUrl=='http://localhost:2990')?(baseUrl+'/jira'):(baseUrl)) +'/projects/'+ keyValue +'/summary');
},

error: function (response) {
console.log(response);
}
});
}

 

The webitem works only in the view issue screen 

but it dosnot work in the Project view page as this is related to Live Field configuration

 

Please help me in this case 

 

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events