Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Need to update placeholder text

CDJ
Tera Contributor

Hi,

 

I would like to change the placeholder text in the 'Additional Comments' field. I have tried updating the out-of-the-box script for 'Modify Comments Label,' but it updates both the label and the placeholder. I only want to update the placeholder text to 'Provide your input.

 

Thanks in advance!

 

 

 

 

8 REPLIES 8

Dr Atul G- LNG
Tera Patron

Hi @CDJ 

 

I doubt this can be do-able as you are looking for. 

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Sandeep Rajput
Tera Patron

@CDJ Please update the 'Modify Comments Label' client script for task table as follows.

 

 

function onLoad() {
    if (!g_user.hasRole("itil"))
        return;

    if (!g_form.hasField('comments'))
        return;
    var labelText = g_form.getLabelOf('comments');
    if (labelText.substring(labelText.length - 1) == ':')
        labelText = labelText.substring(0, labelText.length - 1);

    labelText += new GwtMessage().getMessage(' (Customer visible)');
    g_form.setLabelOf('comments', labelText);

    var interval = setInterval(function() {
        var commentField = document.querySelector("textarea[id='activity-stream-textarea']");
        if (commentField) {			
            commentField.placeholder = "Provide your input."; // Change this text
            clearInterval(interval);
        }
    }, 500); // Retry every 500ms until it's found
}

 

 

Here is the output.

 

Screenshot 2025-04-08 at 10.20.00 PM.png

 

Please be informed that the code suggested above customises the OOTB script and falls in the category of DOM manipulation. 

Hi @Sandeep Rajput ,

 

Thank you so much for your response.

 

I tried running this script, but it's showing empty. There is no placeholder text appearing. I'm trying to achieve this for the 'sc_task' table.

@CDJ The script shared previously works for the incident form. For sc_task, comments is a dot walked field which comes from the RITM field. You can choose to create a new onLoad script on the sc_task table and put the following script in it.

 

function onLoad() {	
    if (!g_user.hasRole("itil"))
        return;
	var interval = setInterval(function () {
		debugger
		var commentField = document.querySelector("textarea[id='sc_task.request_item.comments']");
        if (commentField) {			
            commentField.placeholder = "Provide your input."; // Change this text
            clearInterval(interval);
        }
    }, 500); // Retry every 500ms until it's found
}