locked
Can the ID from a Lookup column be obtained when using SharePoint's Data View Part? RRS feed

  • Question

  • I have a DVWP that has an aggragate datasource.  I am trying to create a joined subview and want to use the ID of the lookup field but the column only has the text and not the ID (doesn't have ID;#Text).

    <xsl:value-of select="@ColumnX"/> 
    This gives the text of the field and not the ID

    <xsl:value-of select="substring-before(@ColumnX, ';#')" />

    so doing this will not work.  How do I get this to work.  How do I get the ID of the Lookup, is there some ddwrt function?

    Thursday, August 18, 2011 3:07 PM

Answers

  • Hi ,

     

    I have another workaround .We can create a number column to store the ID of the look up column and then use the number column in the joined sub view .

    1.       Create a number column and a look up column .

    2.       Create a workflow to start when an item is created or changed on the list where the look up column and the number column exist (We call it list1 here)  .The other column we use is list2 and the look up column get the value from the list2 Title column .

    3.       Choose the action as update list item .Set the number column to get the value of the item ID .The logic is like this :

                                           Set this field ‘number ’to the Value :

                                                                        Source: list2, Field :ID

                                                                                    Find list Item Field: lists2:Title,Value:

                                                                                                                                             Source: Current Item ,Field: look up .

    Then the workflow will automatically set the number column to the ID of the items in lists2 .Then you can use the umber column in the joined sub view .

     

    Thanks,


    Entan Ming
    • Marked as answer by Emir Liu Friday, August 26, 2011 6:28 AM
    Tuesday, August 23, 2011 8:26 AM
    Moderator

All replies

  • Hi ,

     

    I understand that you want to get the ID part of a look up column .You can achieve by taking the following steps:

    1.       Format the lookup column as  label .

    2.       Then use the ddwrt function: <xsl:value-of select=" ddwrt:URLLookup(‘{218F74EE-A2C0-4D22-B8E1-BD91B2F36437}’,'MyContact’, string(@ID))”/> .The string is the GUID of the list which the look up column belongs to .

     

    For more detailed information ,please refer to this site:

    Sharepoint Designer: Fetching ID of Lookup Field from Label: http://abstractspaces.wordpress.com/2009/09/22/sharepoint-designer-fetching-id-of-lookup-field-from-label/

     

    Thanks,


    Entan Ming
    Monday, August 22, 2011 2:38 AM
    Moderator
  • This doesn't work when I add a linked datasource.  It returns the URL when it uses a single datasource but when you add another datasource it returns nothing.

    On the joined subview I want to retrieve the rows with ...[@LookupCol = current()/@ID] instead of ...[@LookupCol = current()/@Title]

    Monday, August 22, 2011 3:08 PM
  • Hi ,

     

    I have another workaround .We can create a number column to store the ID of the look up column and then use the number column in the joined sub view .

    1.       Create a number column and a look up column .

    2.       Create a workflow to start when an item is created or changed on the list where the look up column and the number column exist (We call it list1 here)  .The other column we use is list2 and the look up column get the value from the list2 Title column .

    3.       Choose the action as update list item .Set the number column to get the value of the item ID .The logic is like this :

                                           Set this field ‘number ’to the Value :

                                                                        Source: list2, Field :ID

                                                                                    Find list Item Field: lists2:Title,Value:

                                                                                                                                             Source: Current Item ,Field: look up .

    Then the workflow will automatically set the number column to the ID of the items in lists2 .Then you can use the umber column in the joined sub view .

     

    Thanks,


    Entan Ming
    • Marked as answer by Emir Liu Friday, August 26, 2011 6:28 AM
    Tuesday, August 23, 2011 8:26 AM
    Moderator