Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to set an editable default text in a string field?

gracjan
Tera Guru

How to set an editable default text in a string field, Dictionary filed, such as "Description" (sort of a help text)? I am trying to add a default text that a user will be able to change. Is there a way to do it under "Change"? Please helpfind_real_file.png

1 ACCEPTED SOLUTION

So, for the description field, you're not able to use HTML formatting. It only accepts plain text. 

You might consider using a template. 

https://docs.servicenow.com/bundle/orlando-platform-administration/page/administer/form-administrati...

Once you create the template, you can apply it on a record using javascript. 

https://docs.servicenow.com/bundle/orlando-platform-administration/page/administer/form-administrati...

That would at least let you create the value "as you would see it" on the form inside your template, instead of trying to format using javascript. 

I hope this helps!

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

View solution in original post

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Maybe you mean something like a placeholder?

Can you try:

find_real_file.png

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Michael Jones -
Giga Sage

You can set a default value using a client-script onload - check to see if the field has a value and if blank, set the value to your default text. 

var msg = 'Some Default Text';
if(g_form.getValue('short_description') == '') {
g_form.setValue('short_description', msg);
}

There are other ways to go about it as well, but this is probably the simplest. 

I hope this helps!

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

Hi. I have a large text that I need to add to the Description box (sort of a template) so the user only add the text. Is there a way to do that? This gives me something but does not allow me to use html like <br> or <p>. Is there a way to do that?

g_form.getValue

So, for the description field, you're not able to use HTML formatting. It only accepts plain text. 

You might consider using a template. 

https://docs.servicenow.com/bundle/orlando-platform-administration/page/administer/form-administrati...

Once you create the template, you can apply it on a record using javascript. 

https://docs.servicenow.com/bundle/orlando-platform-administration/page/administer/form-administrati...

That would at least let you create the value "as you would see it" on the form inside your template, instead of trying to format using javascript. 

I hope this helps!

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!