Item ID in jsvascript

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
armin o
Posts: 21
Joined: Sun Jan 17, 2016

12 Feb 2016

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

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

12 Feb 2016

Are you trying to get the current entity ID when you're on a form? Try this:

Code: Select all

GetUrlKeyValue('ID'); 

armin o
Posts: 21
Joined: Sun Jan 17, 2016

12 Feb 2016

Rostislav,

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

BEst wishes,

ARmin

armin o
Posts: 21
Joined: Sun Jan 17, 2016

12 Feb 2016

GetUrlKeyValue('ID'); i ment

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

12 Feb 2016

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.

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

12 Feb 2016

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.

armin o
Posts: 21
Joined: Sun Jan 17, 2016

12 Feb 2016

Hi Rostislav,

Code: Select all

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


-Armin

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests