How to use document.getElementById in RP client script

Mohammad1
Tera Contributor

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?

 

2 REPLIES 2

Anurag Tripathi
Mega Patron
Mega Patron

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

-Anurag

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.