Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Issue Collector - How to gather input fields value on Show Dialog

Maxime Girard June 9, 2022

Hi,

I followed the documentation for Issue Collector and I was able to create a webpage with a button that can now show a Dialog to open a ticket in a specific JIRA project. I am even able to provide Default values for some fields by adding this code:

// ==== default field values ====
fieldValues : {
summary : 'This is the default summary value'
}

 And it is pretty sweet.

However I would like to upgrade this feature and to be able to pass values instead of only defining defaults one with "fieldValues".

In a way, this is what I am trying to do:

// ==== we add the code below to set the field values ====
"fieldValues": {
summary : $('#summary').val(),
description : $('#description').val()
}

<body>

<input id="summary" name="summary" type="text" value="" />
<input id="description" name="description" type="text" value="" />

</body>

 

This is a simplified version of my code, but I think it should shows what I am trying to do.

The problem is that the code $('#summary').val() is not called when we click on the button and trigger the function showCollectorDialog();. So the values I am trying to get from the inputs are never gathered back to the Dialog.

I am at lost to try and find a way to solve this.

Any help is appreciated.

Thank you

1 answer

1 accepted

1 vote
Answer accepted
Maxime Girard June 10, 2022

I have found how to do it.

I will post here, hopefully this will help someone. Atlassian should update their doc on Issue collector as this is not easy at all to understand.

window.ATL_JQ_PAGE_PROPS = {
"triggerFunction": function(showCollectorDialog) {
//Requries that jQuery is available!
jQuery("#feedback-button").click(function(e) {
e.preventDefault();

//This is the new function you need to add
updateFieldValues();

showCollectorDialog();
}
});
},
// ==== Set the default field values if nothing is shared by the user ====
"fieldValues": {
summary : 'A Summary text',
description : 'The description',
priority : '10004',
}
};

function updateFieldValues()
{

// Using JQuery, go gather your values.

window.ATL_JQ_PAGE_PROPS.fieldValues.fullname = $('#fullname').val();

window.ATL_JQ_PAGE_PROPS.fieldValues.components = $('#components').val();

window.ATL_JQ_PAGE_PROPS.fieldValues.description = $('#description').val();

// Etc...

}
Petar Nenkov
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 25, 2023

You are my hero. I have been searching for this for hours.

Suggest an answer

Log in or Sign up to answer