how to pass string filed value into HTML filed which show as HTML value only.

keshav77
Tera Contributor

Hi All,

 

I am getting value through script include from backed  the filed type is string and placing that value in HTML filed but the value coming in this HTML filed  as string value But I want that value as HTML how I can do that

2 REPLIES 2

sejal1107
Tera Guru

Hi @keshav77 

 

Please add below code in client script

function onLoad() {
    //Type appropriate comment here, and begin script below
    var ga = new GlideAjax('GetHTMLData');
    ga.addParam('sysparm_name', 'getLink');
    ga.getXMLAnswer(updateLink);
}
function updateLink(answer) {
var s = '<p><a href=' + answer + ' target="_blank">sejal</a></p>';
g_form.setValue('u_html', s);
}

Script include

var GetHTMLData = Class.create();
GetHTMLData.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getLink: function() {
    return 'https://google.com';
    },
    type: 'GetHTMLData'
});

 OUTPUT

Screenshot 2025-03-28 at 3.21.16 PM.png

Please Mark Helpful and Correct if it really helps you.
Regards,
Sejal Chavan

Please check and Mark Helpful and Correct if it really helped you.
Thanks & Regards
Sejal Chavan

Ankur Bawiskar
Tera Patron
Tera Patron

@keshav77 

if value you are getting from script include is string then it will only set string.

did you try to append the HTML tags?

please share what value you are getting and what should be set in target field?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader