How to change field value font styles in ServiceNow? - servicenow

Is it possible to change field value font styles on OnLoad in servicenow ? I was able to change field label styles using below code.
// Custom field label colors
var stateLabel = g_form.getLabel('short_description');
stateLabel.style.color= 'red';
stateLabel.style.fontWeight='bold';
I tried to change field value font styles in similar way but no luck.
var stateValue = g_form.getValue('short_description');
stateValue.style.color= 'red';
stateValue.style.fontWeight='bold';
above code does not do any good , any thoughts on getting this to work?
Thanks in advance

The API call you're using g_form.getValue(...) is just going to return the string value of whatever field you're asking for.
To get access to the Element (like with getLabel) you can use g_form.getControl(...)
Example:
var el = g_form.getControl('short_description');
el.style.color = 'red';
el.style.fontWeight = 'bold';
However, I'd advise that instead of doing direct DOM manipulation with client-side javascript, that you use Field Styles instead:
Field styles allow administrators to declare individual CSS styles for
a field in a list or form. The CSS can:
Change the color.
Change the font attributes (bold, italics, underline).
Change the padding and alignment of text.
Field Styles allow you to specify a particular field, and apply arbitrary CSS.
To take it a step further, it even allows you to specify javascript to conditionally apply the Style based on something like the state of the record.

I would advise you to look at the VIP Callers on the Incident form, the field value color is sat to Red when the Caller.VIP = True
if this is your requirement, I would be happy to look it up for you.

Related

InDesign does not apply the paragraph styles correctly even when mapped to the same working paragraph styles

Was wondering if anyone knew why this may be happening? I've set up an InDesign document importing from Word with the correct formatting but then when I import the same document from Word with this time using the style mapping it doesn't retain and apply the styling.
I imported it - fixed all the necessary formatting issues and then made sure to save the paragraph styles for use later. I've then went back to the beginning and imported the word document again and this time used the customized style mapping to match the corresponding word styles with the now-correct InDesign styles. When I then place this document, however, it doesn't seem to retain the styling. Some styling does get transferred over but then some, such as indentation, does not.
This is it what it looks like on the correct document
Correct image
And then when I import it again with the styles mapped to the same styles they use it doesn't work.
Incorrect image
For example the sub heading is now numbered and indented wrong and the box on the left is now gone but it is the active applied style, with changes (I presume from the +?) If I then reapply it does work fine?
I'm not 100% sure why the paragraph style is there and works but does not seem to apply properly?
It can be fixed to a degree if you perform Find/Change for all your styles:
blank field with style --> blank field with the same style
for every single paragraph style.
It can be done manually, but since we're here I'd propose this script:
var doc = app.activeDocument;
var styles = doc.paragraphStyles;
var s = styles.length;
while (s--) {
app.findGrepPreferences.findWhat = '';
app.findGrepPreferences.appliedParagraphStyle = styles[s];
app.changeGrepPreferences.changeTo = '';
app.changeGrepPreferences.appliedParagraphStyle = styles[s];
doc.changeGrep();
}
app.findGrepPreferences = NothingEnum.nothing;
Probably the same is applied to character styles as well.

How does one add a class name to a v-text-fields label tag

Vuetify has a v-text-field input which is basically combines an HTML form <input type=text...> with a <label> and packs it up in various nested <div> tags(https://vuetifyjs.com/en/components/text-fields/).
By default it has the label sharing the same space as where the value is entered. They developed a behavior so that when a user starts typing in the text field, the label floats above the text field.
There is a property called 'single-line' which prevents floating of the label. I want the opposite effect, where the label is always floating above the text field regardless of whether or not there is input. Is this possible to do?
When I inspect the HTML I notice that the label (when floating) has a class appended to it called 'v-label--active'. I am not sure how to attach that class name to the label since I don't have direct access to the label tag. Instead, I have a <v-text-field > HTML tag which auto generates the HTML <label> tag when compiled.
From what I've read in the documentation there does not seem to be an option for your desired behaviour.
However a work around could be as follows:
When the text field is focused this applies the v-label--active class on the label element as you mentioned. This class applies the css property transform: translateY(-18px) scale(.75).
With your own custom css/scss you can target the v-label class and apply the same transform: translateY(-18px) scale(.75) on it. This will generate your desired effect. When you focus on the input field the text will turn blue (or whatever active state colour you have set).
See example: https://codepen.io/jt-totty/pen/WNoKNmM

Remove header/filter-button columns from Telerik UI RadDataGrid

Much what the title says. When creating a RadDataGrid using TelerikUI in Xamarin.Forms, we get a "header column".
I know the style of can be set via the HeaderStyle property, and the text itself can be hidden by setting HeaderText to an empty string, but how do we actually remove the row of columns itself? Is this possible, with or without custom renderers?
We've tried setting the HeaderStyle to different attributes in hope that it'll fix it (hidden, collapsed etc), we've also tried emptying different properties/tags to try to achieve something similar to CSS's display: none but nothing has given us results as of yet. Any and all help appreciated!
Thanks.
If you want to hide the dots, you can set the Header Style:
<telerikDataGrid:DataGridTextColumn PropertyName="Country">
<telerikDataGrid:DataGridTextColumn.HeaderStyle>
<telerikDataGrid:DataGridColumnHeaderStyle OptionsButtonTextColor="Transparent"
BorderColor="#D9D9D9"
BorderThickness="1"/>
</telerikDataGrid:DataGridTextColumn.HeaderStyle>
</telerikDataGrid:DataGridTextColumn>
In addition, if you don't use any sorting or filtering, you can disable it through these properties
UserGroupMode="Disabled"
UserFilterMode="Disabled"
UserSortMode="None"

How to apply formatting to content of a span

With CkEditor, When I create an A tag and later apply some custom formatting (like color text for instance), the resulting source looks like this:
<p><span style="color:#1abc9c;">some text</span></p>
As you can see, the formatting is around the text but INSIDE the A tag.
I have a personal plugin that outputs a SPAN tag with a specific class. In the wysiwyg editor, when I select the text and apply the same formatting, I get this:
<p><span style="color:#1abc9c;"><span class="command3d">Some text</span></span></p>
This time, the formatting is not simply around the text. It is applied around the SPAN tag.
How can I control this behaviour? I would like to get this result instead:
<p><span class="command3d"><span style="color:#1abc9c;">Some text</span></span></p>
Thanks
Unfortunately there is no ability to control the order of inline styles (based on span tags) inside editor's instance. The only sensible way to achieve desired result is to start with applying text color and then apply your custom style.
However there are two methods to convert output of the editor to the correct format. The first is to add custom handler to editor's data processor via toDataFormat event to check ancestors of span.command3d and swap them in places if necessary. However it's a little bit troublesome as you must traverse through all content, therefore it's easier way: add element callback to editor's filter. Example.

How to disable pasting inline styles on CKEditor?

How do I disable contents for styles when pasting to CKEditor?
Overview, I'm trying to fix width styles on my DOMPdf, but inline styles pasted to CKEditor is messing up with the styles I've set up in DOMPdf.
I've applied what was posted here https://docs.ckeditor.com/#!/guide/dev_disallowed_content.
And so far, here's some of what I tried
CKEDITOR.config.disallowedContent = "table(width)",
CKEDITOR.config.disallowedContent = "table[style]"
But when I copy and paste from word docs or customized html strings, styles or width would still be pasted. Any tips? Thanks!
First of all if you want to remove the width style from the table, you need to use:
CKEDITOR.config.disallowedContent = 'table{width}';.
The rule CKEDITOR.config.disallowedContent = "table(width)" will remove the width class from the table and CKEDITOR.config.disallowedContent = "table[style]" will not do anything because styles are defined in {} and not in [].
Read more about the format of Allowed Content Rules here: https://docs.ckeditor.com/#!/guide/dev_allowed_content_rules
But when I copy and paste from word docs or customized html strings,
styles or width would still be pasted.
Please open the Full preset editor sample and try bolding the text or using some inline styles from the Styles dropdown. You will see tags like strong, code, big or span etc. are being used. In order to disallow them your ACF rule would need to look like so for example:
var editor = CKEDITOR.replace( 'editor1', {
disallowedContent : 'span;code;strong;big'
});
Please note that above rule disables span, strong, code and big tags completely in CKEditor. If you still wish to use these tags in the editor but filter content only during pasting, you should use paste events and regex to change the incoming HTML:
https://docs.ckeditor.com/#!/api/CKEDITOR.editor-event-paste
https://docs.ckeditor.com/#!/api/CKEDITOR.editor-event-afterPasteFromWord

Resources