getFormElement not working unable to set label in onload script

Rakesh50
Mega Sage

Hi,

 

We want to set the label for journal type field called internal work. Internal work value we are passing to work notes field. And Internal work will show all previous entries. Now we want to show the label "history" for all entries. tried below code but not working. can anyone have a look and suggest any modifications ?

 

 

function onLoad() {
    var tableName = g_form.getTableName();
    var recordSysId = g_form.getUniqueValue();
    var checkWN = new GlideRecord('sys_audit');
    checkWN.addQuery('documentkey', recordSysId);
    checkWN.addQuery('tablename', tableName);
    checkWN.addQuery('fieldname', 'work_notes');
    checkWN.query();
 alert("hi");
    if (checkWN.next()) {
        var wn = g_form.getFormElement('element.x_123_table.internal_work').querySelector("div[id='element.x_123_table.internal_work'] > div[class*='input_controls']");	
        if (wn)
            wn.insertAdjacentHTML('beforebegin', '<div style= "font-size:15px ; margin: 0px 0px 0px 15px">Internal Work History</div>');
    }

 

 

1 ACCEPTED SOLUTION

Rakesh50
Mega Sage

I have removed the GlideRecord query in onload script and created Script include and return the "true" value .

Now i'm able to see the Label for all journal entries.

View solution in original post

3 REPLIES 3

Harshal Aditya
Mega Sage
Mega Sage

Hi @Rakesh50 ,

 

Hope you are doing well.

g_form.setLabelOf('your field name', 'Text');

 

As checked you have user GlideRecord API in client script and it is not recommended could you please glideAjax instead. 

 

Please mark this response as correct or helpful if it assisted you with your question.

Regards,
Harshal

hi @Harshal Aditya 

Thanks for the reply. I'm doing good.

If I use setLabelOf, it will show the all entries with label. But I required like below

Rakesh50_0-1683306933837.png

 

Rakesh50
Mega Sage

I have removed the GlideRecord query in onload script and created Script include and return the "true" value .

Now i'm able to see the Label for all journal entries.