The CreatorCon Call for Content is officially open! Get started here.

Write any HTML code back to HTML Variable (TinyMCE) in Record Producer

georgechen
Kilo Guru

Hi folks,

I was wondering any advice to write values back to a HTML variable in a record producer within a Widget under a Service Portal.

find_real_file.png

The HTML object is one of the Record Producer variables; when record producer loads, it displays as a HTML editor as below

find_real_file.png

It has no values by default (see above screenshot), and my goal is to dynamically populate table (see a prototype below) into this HTML object.

find_real_file.png

Firstly, I will have to fetch this HTML object. which I know is rendered under a body id=tinymce (see below element inspections)

find_real_file.png

Therefore below is the Widget client Controller (Client Script) to populate the table, I have tried a various ways to write a dummy value back to this HTML object, but none of them have seemed to work so far.

find_real_file.png

find_real_file.png

I was wondering if anyone could help;   It would be much appreciated for your feedback.

Kind regards,

George

1 ACCEPTED SOLUTION

Gaurav Bajaj
Mega Sage

Hi George,



I think you can achieve it by accessing the element from scope data and I am afraid that's the only way to achieve it at present as other javascript objects are not accessible within a client script in widgets.



You just need t replace the sysId here with the sys_id of your HTML variable. I tried and it worked out for me.



$scope.data.sc_cat_item._fields["IO:4a6410e80fa90300e42306bce1050ec5"].value = "place your dummmy value";


//replace IO:4a6410e80fa90300e42306bce1050ec5 : "IO:sys_id" of your variable




PS: You can also try with catalog client script to populate it.




Please mark correct/helpful based on the impact of the response.




Thanks


Gaurav


View solution in original post

3 REPLIES 3

Gaurav Bajaj
Mega Sage

Hi George,



I think you can achieve it by accessing the element from scope data and I am afraid that's the only way to achieve it at present as other javascript objects are not accessible within a client script in widgets.



You just need t replace the sysId here with the sys_id of your HTML variable. I tried and it worked out for me.



$scope.data.sc_cat_item._fields["IO:4a6410e80fa90300e42306bce1050ec5"].value = "place your dummmy value";


//replace IO:4a6410e80fa90300e42306bce1050ec5 : "IO:sys_id" of your variable




PS: You can also try with catalog client script to populate it.




Please mark correct/helpful based on the impact of the response.




Thanks


Gaurav


Hi Gaurav


Much appreciated your helpful advice.   This works like a charm!


1) Copy sys_id of the HTML variable


find_real_file.png



2) populate the variable as per your suggestion


find_real_file.png



3) Load the Record Producer which loads as expected.


find_real_file.png



You are my champion of the day


Great 🙂
Happy to help you.
Just wanted to add one more thing. I hope you are using this widget only for this cat item as if the syd_id object for the html variable is not found, its gonna run into errors.



Please add a null check before the second link of the code where we are trying to set the default value just to make sure we dont end up breaking other cat items.



Thanks
Gaurav