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.

Get HTML value

Claudio6
Tera Expert

Hi team community.

I'm trying to get html value on html_template fields. I can get for uncomments lines, but I would like to get comments lines as well.

Use case: Template field in sp_ng_template table contents this value:

<!--

<div class='blmWrapper'>
<div style='background-color:#fde11b;color:black;font-size: medium;padding:10px;margin:10px'>

-->

<p>I can get this text</p>

<!--The scheduled maintenance will now happen from 6:00 PM to 11:00 PM Pacific Time on 2/19, and there will be some slowness during this time. -->

 

so, if I want to get the value for the Template field, I just got "I can get this text", and I want to get all the text.

I tried using getValue(), getDisplayValue, and getHTMLValue(). None of them work. How could I retrieve all the text?

 

Thanks.

Claudio.

 

 

 

1 ACCEPTED SOLUTION

AnveshKumar M
Tera Sage
Tera Sage

Hi @Claudio6 ,

Where you are trying to get this value? I just ran a background script, and it fetched the commented values too. I think you are loosing the actual HTML markup while displaying it. May I know the use case, so that I can try to get some solution.

 

 

var gr = new GlideRecord('sp_ng_template');
gr.addQuery('id', 'cxs-result-pinned');
gr.query();
if(gr.next()){
    gs.print(gr.getValue('template'));
}

 

 

Thanks,
Anvesh

View solution in original post

2 REPLIES 2

AnveshKumar M
Tera Sage
Tera Sage

Hi @Claudio6 ,

Where you are trying to get this value? I just ran a background script, and it fetched the commented values too. I think you are loosing the actual HTML markup while displaying it. May I know the use case, so that I can try to get some solution.

 

 

var gr = new GlideRecord('sp_ng_template');
gr.addQuery('id', 'cxs-result-pinned');
gr.query();
if(gr.next()){
    gs.print(gr.getValue('template'));
}

 

 

Thanks,
Anvesh

Claudio6
Tera Expert

Hi Anvesh!

I was using Xplore for running the script, I tried on Script Background and it worked. Looks like Xplore don't support the Html values.

 

Thank you!