I am trying to make a custom text field read-only on the edit screen of jira using javascript, but looks like below code is not working.
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e,context) {
var projectName = AJS.$("#project-name-val").text();
console.log("RFC projectName "+projectName);
if (projectName == "RT")
{
callReadonlyFunction();
}
}
});
function callReadonlyFunction(){
$('#edit-issue').click(function() {
console.log("Edit Button Clicked Start");
AJS.$("#customfield_13911").attr("readonly", true); //text field
console.log("Edit Button Clicked End");
});
}
In the console log, I do see messages but for some reason, the field is not set to read-only.
Why are you trying to do it with JS if you have Scriptrunner?
Go to "add-on" page and in the left panel you have "behaviours".
There you can determine a field with 3 options:
Required (Optional)
Writable (Readonly)
Shown (Hide)
So choose the "Writable (Readonly)" for your field.
I am even trying to set 'nfeed' field readonly through javascript during clone. ANy idea on how it can be done?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I didn't understand what you said.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Nir Haimov
On the announcement banner during clone operation , I am trying to set an "Element Connect " type of field to readonly.
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e, context, reason) {
var isCloneIssuePage = AJS.$('#clone-issue-dialog').is(':visible');
var issuetype=AJS.$('#issue-create-issue-type').text();
if (isCloneIssuePage == true || AJS.$('#content .aui-page-header-main h1').text() == "Clone") {
alert('clone')
if(issuetype =="Customer Product SKU"){
alert(issuetype)
AJS.$('#customfield_15003').attr("readonly", true); //nfeed field
}
}
});
But the above code is not setting field to readonly
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't know what is an "Element Connect ".
Any way, when do you want to make the field read-only?
Clone is an action, where new issue created, do you want the field to be read only in the original issue, or cloned issue or both?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Nir Haimov
I want to make field readonly during clone operation. ie, on clone screen i want the field to appear as readonly. I dont want to do anything for original issue. just make it readonly on cloned issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OK, Can you please send a screenshot of your clone screen and mark the field you want to make read-only?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you using "Clone Plus for Jira" or any other plugin that extend the clone screen?
Because Jira by default don't allow you to set fields when clone, only the summary is changeable.
My point is, if you are using 3rd party plugin that extend the clone screen, my guess is that this plugin not fire the NEW_CONTENT_ADDED event, so your code block where you bind to this event JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function.... not gets executed (means, everything in the bind function not executed), did you try to debug and check if your function inside the bind works? does your code gets inside the bind?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Nir Haimov
Yes we are using "Clone plus for JIra". Alerts inside JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function .. are working. I am getting both 'clone' and 'issuetype' alert values.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OK, so simply try to change this line:
AJS.$('#customfield_15003').attr("readonly", true); //nfeed field
to this:
AJS.$('#customfield_15003').attr("disabled", true); //nfeed field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.