How to add placeholder for work notes & additional comments?

Rahul63
Tera Contributor

I have added placeholder by writing client script but script only works for new record. Not for the old once or also for any record after created. SO how can I make this script work for new record and old record also?

onload script - 

function onLoad() {

var workNotes = g_form.getControl("work_notes");
if(workNotes) {
workNotes.placeholder = "Internal Notes for ITIL users. Not visible to customer.";
}

var comments = g_form.getControl("comments");
if(comments) {
comments.placeholder = "Shared with customer.";
}

}

 

find_real_file.png

find_real_file.png

8 REPLIES 8

 

Hello Ankur,

Im trying to achieve the same in agent workspace "short description" field but couldn't get it

I want to keep a place holder and hover message(guess not possible) for short description field

 

var Shortdesc
if(g_form.isNewRecord()){
alert('New Record');
Shortdesc = g_form.getControl("short_description");
if(Shortdesc){
Shortdesc.placeholder = "Maximum 100 Characters";

}
}} else {
//alert('Old record');
setTimeout(alertFunc, 1000);
function alertFunc() {
Shortdesc.placeholder = 'Maximum 100 Characters';
}


}

Kartik Sethi
Tera Guru
Tera Guru

Hi @Rahul 

 

There is no direct way to accomplish this. When you create a new record then the fields work_notes and comments are available on the form hence your client script is setting the placeholder.

 

But for already created records these fields are removed/hidden from the form and replace with Activity fields whose IDs (on Incident Table) are:

Worknotesactivity-stream-work_notes-textarea

Commentsactivity-stream-comments-textarea

 

To accomplish your requirement you need to have DOM Manipulation logic added (not at all Recommended😞

function onLoad() {
    var worknotes,
        comments;

    if (g_form.isNewRecord()) {
        //alert('New record');
        worknotes = g_form.getControl("work_notes");
        if (worknotes) {
            worknotes.placeholder = "Internal Notes for ITIL users. Not visible to customer.";
        }

        comments = g_form.getControl("comments");
        if (comments) {
            comments.placeholder = "Shared with customer.";
        }
    } else {
        //alert('Old record');
        setTimeout(alertFunc, 1000);

        function alertFunc() {
            worknotes = document.getElementById("activity-stream-work_notes-textarea");
            comments = document.getElementById("activity-stream-comments-textarea");

            worknotes.placeholder = 'Internal Notes for ITIL users. Not visible to customer.';
            comments.placeholder = 'Shared with customer.';

            //alert(worknotes.placeholder);
        }
    }
}

Remark: DOM manipulation is not supported and it will create a performance issue. Also, you need to put Isolate Script = False on the client script.

Also note that, we need to delay the client script for Activity Fields to get loaded on the already created records


Please mark my answer as correct if this solves your issues!

If it helped you in any way then please mark helpful!

 

Thanks and regards,

Kartik

Hi @Rahul 

 

Is your issue resolved or are you still stuck somewhere?

 

Thanks and regards,

Kartik

Hello Karthik,

Im trying to achieve the same in agent workspace "short description" field but couldn't get it

I want to keep a place holder and hover message for short description field

 

var Shortdesc,
if(g_form.isNewRecord()){
alert('New Record');
Shortdesc = g_form.getControl("short_description");
if(Shortdesc){
Shortdesc.placeholder = "Maximum 100 Characters";

}
}} else {
//alert('Old record');
setTimeout(alertFunc, 1000);
function alertFunc() {
Shortdesc.placeholder = 'Maximum 100 Characters';
}


}