Getting ID from CrossSiteLookup on Displayform
Dear Nikita,
I have a SPO-List called "products" with a lot of columns (>70) and a CrossSiteLookup called "productgroupe".
Originally I created one Form for Edit,New and Dispaly and using Tabs to show/hide the attribute according the productgroupe!
..but over 70 attributes/colums its a problem for SPO (timeout for XLST !!)...
..so now I´m using for each productgroup a formset.
But for example on the Edit-Form I get the ID for the underlaying productgroup with :
var productGroup = fd.field('Productgroupe').value();
The field: "Productgroup" is a CrossSiteLookup!
But on the Displayform I get the Title of the underlaying productgroup !!
How do I get the ID from then CrossSiteLookup called 'Productgroupe' on the Displayform to redirect to the according productgroup-Displayform?
I don´t want to hardcode the productgroup-Titles because of possibel future change!
thx for helping me.
I have a SPO-List called "products" with a lot of columns (>70) and a CrossSiteLookup called "productgroupe".
Originally I created one Form for Edit,New and Dispaly and using Tabs to show/hide the attribute according the productgroupe!
..but over 70 attributes/colums its a problem for SPO (timeout for XLST !!)...
..so now I´m using for each productgroup a formset.
But for example on the Edit-Form I get the ID for the underlaying productgroup with :
var productGroup = fd.field('Productgroupe').value();
The field: "Productgroup" is a CrossSiteLookup!
But on the Displayform I get the Title of the underlaying productgroup !!
How do I get the ID from then CrossSiteLookup called 'Productgroupe' on the Displayform to redirect to the according productgroup-Displayform?
I don´t want to hardcode the productgroup-Titles because of possibel future change!
thx for helping me.
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear gaj,
You can try to retrieve ID from the item's URL, like this:
This should work, though I am not sure it always will.
Alternatively, you can go to List Settings, open Lookup column properties and add ID as an additional field, then you can hide it in the designer by setting field's Style to display:none;
Then use the following code:
You can try to retrieve ID from the item's URL, like this:
Code: Select all
var url = fd.field('FieldName').control()._el().find('a').attr('href');
var csID = url.substring(
url.lastIndexOf("ID=") + 3,
url.lastIndexOf("&")
);
alert(csID);
Alternatively, you can go to List Settings, open Lookup column properties and add ID as an additional field, then you can hide it in the designer by setting field's Style to display:none;
Then use the following code:
Code: Select all
var csID = fd.field('FieldName_x003a_ID').value();
alert(csID);
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 22 guests