How to get text value from text field created on UI page with HTML

akshaybhardwaj
Mega Guru

Hi All,

I have created textarea field on ui page

<textarea type="text" style="margin: 0px;width:300px;height: 64px;" > </textarea>

and a submit button  

<button class="listactions" type="submit" onClick="return submit();" id="submit" name="submit" > ${gs.getMessage('Submit')} </button>

On clicking of the submit button the text in the text field should get added in serviceNow custom table.

How I can achieve this?

Kindly help..

Regards,

Akshay

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Akshay,



Have an id attribute for the text area tag. Use document.getElementById("textAreaId").value to fetch the value of the text area field.



Perform the above in client script of ui page. When you are using the submit button, call a onSubmit method add add the above code in that method in client script section. you can then query the table using gliderecord and update whatever field you want with the value present in text area.



Mark my reply as Correct and also hit Like and Helpful if you find my response worthy.


Thanks


Ankur


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

View solution in original post

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Akshay,



Have an id attribute for the text area tag. Use document.getElementById("textAreaId").value to fetch the value of the text area field.



Perform the above in client script of ui page. When you are using the submit button, call a onSubmit method add add the above code in that method in client script section. you can then query the table using gliderecord and update whatever field you want with the value present in text area.



Mark my reply as Correct and also hit Like and Helpful if you find my response worthy.


Thanks


Ankur


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

Thanks Ankur,



Will give a try


Hey Ankur,



Is it possible to update the field from client script or I have to use script include to update my custom table field


Hi Akshay,



You can use GlideRecord query in client script and update the record. That should be fine.



Mark my reply as Correct and also hit Like and Helpful if you find my response worthy.


Thanks


Ankur


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