Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Work notes field not displaying placeholder text in the existing incidents

kandulek
Tera Expert

Hi All,

 

We have a requirement to add a placeholder text to the work notes field in the incident records. It is possible to add a placeholder text to any new record before submitting it. However, unfortunately, in case of already existing incidents the placeholder text flashes for a second and then disappears. Could anyone advice on what could be modified in the below onLoad Client Script?

 

function onLoad() {
        var placeholderText = "This is a placeholder text";
        var workNotes = g_form.getControl("work_notes");
        var streamNotes = g_form.getControl("activity-stream-work_notes-textarea");
 
        // If this is a *new* incident
        if (g_form.isNewRecord()) {
            if (workNotes) {
                workNotes.placeholder = placeholderText;
            }
        }
        // If this is an *existing* incident
        else {
            if (streamNotes) {
                streamNotes.placeholder = placeholderText;
            }
        }
    }

 I would be grateful for any hints, or suggestions!

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@kandulek 

by giving timeout of 2 seconds it worked for me in new and existing record both

function onLoad() {
    setTimeout(function() {

        var placeholderText = "This is a placeholder text";
        var workNotes = g_form.getControl("work_notes");
        var streamNotes = g_form.getControl("activity-stream-work_notes-textarea");

        // If this is a *new* incident
        if (g_form.isNewRecord()) {
            if (workNotes) {
                workNotes.placeholder = placeholderText;
            }
        }
        // If this is an *existing* incident
        else {
            if (streamNotes) {
                streamNotes.placeholder = placeholderText;
            }
        }
    }, 2000);
}

Output:

placeholder text for work notes new and existing record.gif

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Hi Ankur,

 

Works like a charm! Thank you very much for the suggested modification and this gif. Very helpful 😊