Assigning a variable in Javascript to equal a calculated value on form

  • 5 January 2021
  • 1 reply
  • 34 views

Badge +2

Hello,

I am trying to reference a calculated value on my form (Client ID JS variable name = calcID) and set that value equal to varID in the javascript code in order to concat a URL based on the ID. Could someone help? When I hard code in an ID, it works, but I need it to be dynamic. 

 

9794iACD651675D276AC8.png

Thanks!


1 reply

Userlevel 5
Badge +14

Your url property for the ajax object looks incorrectly set to the value of:


{url: _siteUrl + "/_api/web/lists/getbytitle('" + listname + "')/items(id)"}

 


which does NOT concat the id variable to the string as it's within the ending Double Quote.


 


It should likely be: 


{url: _siteUrl + "/_api/web/lists/getbytitle('" + listname + "')/items(" + id +")"}

 


Does this help?

Reply