Copy link to clipboard
Copied
Is it possible to set line spacing for a text field / variable?
var strWord1 = this.getField("CityName").valueAsString;
event.value = strWord1 +" is hosting an event..."
I've seen that it can't be done within Form Edit mode. Is it possible with JS?
Thanks!
1 Correct answer
Ok, so I actually kept looking and I found this amazing custom keystroke script that worked great!
var spans = event.richValue;
if (spans !== undefined && event.willCommit) {
for ( var i = 0; i < spans.length; i++ ) {
spans[i].textSize = 10; // font size
spans[i].linespacing = 15; // linespacing
// restore line breaks
if (spans[i].endParagraph) spans[i].text += "\r";
// reset styles to default
spans[i].fontStyle = "normal";
spans[i].fontWeight = 400;
spans[i].strikethrough = false;
spans[i].underline = fal
Copy link to clipboard
Copied
Not possible with a script.
Copy link to clipboard
Copied
Hi,
Given the try67's answer I'm not sure to correctly understand the question, but it is possible to set the line spacing of a text field set in rich text! See the attached file...
@+
Copy link to clipboard
Copied
I stand corrected! However, this is an undocumented property, so use it at your own risk... It does work nicely, though.
Copy link to clipboard
Copied
Thank you @bebarth for the answer! Sadly I am not skilled enough to look at this document and know how to add it to my script to make it work. Any additional help would be greatly appreciated!
Copy link to clipboard
Copied
Ok, so I actually kept looking and I found this amazing custom keystroke script that worked great!
var spans = event.richValue;
if (spans !== undefined && event.willCommit) {
for ( var i = 0; i < spans.length; i++ ) {
spans[i].textSize = 10; // font size
spans[i].linespacing = 15; // linespacing
// restore line breaks
if (spans[i].endParagraph) spans[i].text += "\r";
// reset styles to default
spans[i].fontStyle = "normal";
spans[i].fontWeight = 400;
spans[i].strikethrough = false;
spans[i].underline = false;
spans[i].textColor = color.black;
spans[i].alignment = "left";
spans[i].fontFamily = ["Arial"];
}
event.richValue = spans;
}
Thanks also to Alex at https://stackoverflow.com/questions/25380882/linespacing-in-multiline-fields
Copy link to clipboard
Copied
Hi, I'm having this same issue, but the keystroke script is not working. I think it's because I don't have an person typing in the form, but rather the data is being mapped to fields from smartsheet. Is there a script that would work in the Format section instead of the Keystroke section?

