How to display data from a client script to an HTML widget and display its value in a text field.

John Clyde Ap_a
Giga Expert

I have a custom with label variable in a record producer that is connected to this widget and I am trying to display data from a value that has been set in the client script. (green box)

find_real_file.png

How to implement it so it will show the value in a text field? 

 

1 ACCEPTED SOLUTION

okay @John Clyde Ap[as ,

i think i got your requirement now .

you are storing total cost in total cost variable .

If yes then do like this

in client controller add this line

c.data.cost=totatCost;

HTML

<div>

<input type="text" value ={{c.data.cost}}>

</div>

try this and let me know

View solution in original post

14 REPLIES 14

Anil Lande
Kilo Patron

Hi,

Please check below links:

You need to use two way data binding to update values in fields created in HTML part.

https://community.servicenow.com/community?id=community_question&sys_id=17e87a34db7d7b04feb1a851ca96...

https://www.youtube.com/watch?v=0gz3XzBM-Gs

I guess g_form will not work as you are not using OOB form widget to display record. This API is only supported with OOB form widget.

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hello Anil,

I have checked it but I am still confused. Can you give an example on its implementation regarding in my case? I apologize as I am still new. 

 

Additionally, the alerts in the script are working but I am not really sure as to why It's not displaying its value in a text field.

Mohith Devatte
Tera Sage
Tera Sage

hellp @John Clyde Ap[as ,

you can try this  in HTML

<div>

<input type="text" value ="c.data.label"/>

</div>

In client controller store the value in a variable like below

c.data.label = $scope.page.g_form.setValue('total_amount',totalCost);

MARK MY ANSWER CORRECT IF IT HELPS YOU

 

Hello Mohith,

I have tried it and this is what it's showing and no value is showing up.

find_real_file.png