Skip to end of banner
Go to start of banner

Making child fields read-only

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

Sometimes you may want to make the database child information fields read-only. There are two ways for doing this:

  1. The first and simple way of doing it, and portable across JIRA versions, is by using the lfDisable routine from the Live Fields feature of our Power Script for JIRA (formerly known as JJUPIN) plugin.
    Just create a SIL file called Main Script with the following code:

    MainScript.sil
    lfDisable("customfield_xxxxx");

    where customfield_xxxxx is the the id of your dbcf child custom field. You can see the cf id as parameter in the URL when editing its configuration (eg  '.../secure/admin/EditCustomField!default.jspa?id=10701')

    Then create a Live Field Configuration using the above Main Script and associate it to a project, let's call it ProjX.

    Every time we enter on an issue page of ProjX  project, the MainScript.sil is executed and the customfield_xxxxx will be read-only.

    You can find more about Live Fields here, including a configuration example similar to the one above.

  2. Or, as an alternative method you can use javascript injection into the custom field's description.

    You should pay attention that this may not be portable across JIRA versions.

You should add the following javascript code into the dbcf child field description from the field’s configuration:

<script type="text/javascript">
AJS.$('#customfield_10014').attr('readOnly', true);

//the following code is for inline edit only
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e, context, reason) {
    if(reason == JIRA.CONTENT_ADDED_REASON.inlineEditStarted) {
       AJS.$('#customfield_10014', context).attr('readOnly', true);
    }
});
</script>

,where customfield_xxxxx is the the id of your dbcf child custom field. You can see the cf id as parameter in the URL when editing its configuration (eg  '.../secure/admin/EditCustomField!default.jspa?id=10701'):

That's it. Your database child field will now be read-only on all screens.

  • No labels