Customfield Rendering on issue details view screen

Hello All,
I’m trying create a new custom field in JIRA. My intention is to modify the name of the field depending on the value. I’m using Javascript to render the new name of the custom field on customfield view screen.
I did achieve it using JavaScript. But, I noticed that when my script is executed, it displays the original name for a micro second and then update to the new name.
Here is the script which I’m using, I would really appreciate if you can provide me with any advice on changing my script to overcome this display lag.
I noticed that this issue occurs only when I refresh the issue details page.

#set($nameofthefield = $value)
#set($actualname = $customField.name)
#set($fieldid = $customField.id)

#if ($value)
    $value
#end

<script type="text/javascript">

AJS.$(function() {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
var cf = "$fieldid";
var cfid = "#rowFor" + cf;
if (AJS.$(String(cfid)).length) {
var actualname = "${actualname}";
                                      console.log("Actual Name:" + actualname);
                                      var CFname = "${nameofthefield}"
                                      
                                      var mainnode = AJS.$(String(cfid));
                                      console.log(mainnode);

                                      var children = mainnode[0].childNodes;
                                      console.log(children);

                                      var res = children[1].childNodes[1];
                                      console.log(res);
                                      res.innerHTML = CFname+":";
}
});

Hi,
I have been similiar problem. But in my case I tried to hidden the panel of “traceability”. I used JS to set “dysplay:none”. After I changed of some field, JIRA updated other fields and showed “traceability” again.
I resolved it just parent.removeChild(“traceability”).

You may try JS to set wrong ID of the field. And JIRA will not be able to find/update field.

@jkirankumar1993 are you using custom field type from jira fields, or creating your custom type?

Yes, he is using custom field type

I am using selectCF custom field type. Thanks.

I didn’t understand.

I mean

document.getElementById('myCF').id = 'myCFb';

And after that JIra cannot find of the element.

It’s a pain that this has to be done client-side. I’ve been trying to find a way to do this is the custom field type definition but I don’t think it’s doable.