How to use document.getElementById in RP client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2020 07:08 AM
Hello,
I have a client script in a record producer. I have the following line of code:
var val = document.getElementById('field_name');
However, it doesn't work and instead it shows this error:
There is a JavaScript error in your browser console
I know that there are alternatives to getElementById, but in my case I need to use this function. Do you have an idea why it's not working?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2020 07:10 AM
Hi,
Why dont you just use g_form.getValue('field name');
Lets try to see if we can work it ut without DOM, else we will fall on that. For DOM i think you need to click on 'isolate script' check box on the client script.
-Anurag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2020 12:43 AM
Hi Anurag,
Thanks for trying to help. Please note that g_form.getValue doesn't work for me because I have a special case where I need to read data from a field in a variable set from another variable set. Please check this for details: https://community.servicenow.com/community?id=community_question&sys_id=a0227d58dbeb84d0d58ea345ca96...
Where do I click on "Isolate Script"? I couldn't find it in the client script form.