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
Tera Patron

Hi @CDJ 

 

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

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

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/atul_grover_lng [ Connect for 1-1 Session]

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

Sandeep Rajput
Tera Patron
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
}