TeamDesk Knowledge Base & Support

   Home      FAQ      Forum      Idea Exchange      Ask a Question      My Stuff      Help   
Javascript - Retrieve Field Value
Hello to you all

I am (barely) starting to learn javascript.
I am integrating a third party API ( where one of the API calls has to be made in javascript.
I need to make the call using a the value of some TD field, which I can display on the TD form.

My question is:

how can I retrieve the value of a TD field in my script ?

I understand that the id of a field which is displayed is in the form of f_12345678_value .
In the JS script, I was hoping to get the value of the field using:

but it does not work (I think this does not work as the following alerts reply undefined or [object object]):
alert('the value of the field is : ' +$('f_43406340'.value));
alert('the value of the field is : ' +$('#f_43406340_value').value);
alert('the value of the field is : ' + document.getElementByName('f_43406340'));

Could you please help me make this work ?
or should I use another way to retrieve the value of my field ?

Kind regards,


Date Created
5/12/2023 3:30:27 AM
Date Updated
5/12/2023 8:29:46 AM
Pierre 5/12/2023 5:10:28 AM
I made it work using


not sure this is the best way, though
calvin peters 5/12/2023 5:22:41 AM
Morning Pierre
I've been working with js quite a lot for past year and had similar issues with field values.
So the field/column values on your form ...first of all are best referenced using
$('[name="f_43406340"]').val() to isolate them as the id is a dynamic value so will not always be the same for each edit instance on the form.

With js the column has to be exposed on the form to the DOM to be visible to
The client side script which means the if your form behavior is set to
'hidden' or the column is otherwise not part of the form when it loads
then js script can't use see it to ise it.

Also, you have to ensure that your script doesn't run until the form is finished
loading. To do this begin the script with
$(document).ready(function (){ your stuff inside this function...

js runs much faster than the server and because the load and postback actions in Team Desk are run asynchronously this will ensure all your elements
are rendered before your script tries to find and use them.

It's a bit early in this time zone so eyes are still lacking a
little caffeine enhancement and my fingers are a still a bit clumsy on the keyboard
so forgive any typos...

Hope this helps
Reach out if /when you hit the next snag.
calvin peters 5/12/2023 5:42:54 AM
...forgot to mention, though you may have already caught this part, the .val() property will be retrieved from your form as text so if you need to use it as a numeric value you will need to convert it or 'coax' it to numeric to be able to pass it to something else or use it for maths inside your script. So preface with a '+' like +$('[name="f_43406340"]').val()
or use parseInt() if it's a whole number like: parseInt($('[name="f_43406340"]').val())
or parseFloat() like: parseFloat($('[name="f_43406340"]').val()) if it's a decimal value or contains decimal value

Without converting first any math jobs in your script will treat the $('[name="f_43406340"]').val() as text and concatenate when adding for instance, or return a 'NaN' result if doing something else with it..

Pierre 5/12/2023 6:13:50 AM
I love you Calvin - Thanks for all this

I will certainly be back with more questions in a couple of days

Kind regards,

calvin peters 5/12/2023 8:29:46 AM
Happy to lend some modest assistance...
hope it works as intended for you
Back to Search Results