Page 1 of 1

Item ID in jsvascript

Posted: 12 Feb 2016
by armin o
How can i get the ID or uniqId of the current item?

The calculated column workaround is not really a good idea, since i get 62644 from sp.js which is != 62.644 ( the value is get from fd.field('my copy of item ID').value() ).

this thing here also does not solve the problem: The field is empty:

<xsl:value-of select="@ID" />



Thanks, Armin

Re: Item ID in jsvascript

Posted: 12 Feb 2016
by rostislav
Are you trying to get the current entity ID when you're on a form? Try this:

Code: Select all

GetUrlKeyValue('ID'); 

Re: Item ID in jsvascript

Posted: 12 Feb 2016
by armin o
Rostislav,

the new form is triggered from a related items control. GetUrlKeyValue() returns the empty string.

BEst wishes,

ARmin

Re: Item ID in jsvascript

Posted: 12 Feb 2016
by armin o
GetUrlKeyValue('ID'); i ment

Re: Item ID in jsvascript

Posted: 12 Feb 2016
by rostislav
You cannot get the ID of a new item until that new item has been created (as that's when the ID is generated).

However, if you are trying to tie a new item to the current item, you can use the related items control in grid mode for this, check this article: http://spform.com/forms-designer- ... point-form

Otherwise, please tell us what you are trying to achieve and we'll try to help you out.

Re: Item ID in jsvascript

Posted: 12 Feb 2016
by rostislav
Or, if you are trying to get the ID of the parent item from a new item form that is opened in dialog mode, try this:

Code: Select all

window.top.GetUrlKeyValue('ID');
This will work only if the parent form is the topmost form in the browser. There is a way to retrieve the parent form when it is not the topmost, give us a shout if you need it.

Re: Item ID in jsvascript

Posted: 12 Feb 2016
by armin o
Hi Rostislav,

Code: Select all

GetUrlKeyValue('ID');
actually did the trick. Stupidity prevented me from realizing this earlier....Thanks!


-Armin