locked
Can i only store GUID in lookup field? RRS feed

  • Question

  • Hi,

    I have created a lookup field based on custom view.

    I have a table named Property Master entity  in which PropertyId is unique Key.

    But in my Lookup in second entity i need to display Unit number from property master which is not unique field.

    i wrote a view to display unit number in lookup and on selection of unit number, i couldnt save unit number in Form

    It throws errror that "[FormatException: Guid should contain 32 digits with 4 dashes"

    So what i did in my lookup i have changed 

      "<row name='result' id='new_unitnumber'>" +

    to

      "<row name='result' id='new_propertymastid'>" +

    Now record gets saved but once the record saved instead of showing my unit number which is just 3 digits it shows propertymasterid in the entity.

    I need unit number to be displayed there and not proertymasterid

    Wednesday, April 3, 2013 7:22 AM

Answers

  • Hello,

    Every entity have one primary field (mostly name) which will be displayed in lookup field in another entity.

    Now if you want to show non primary field in lookup in your case unit number I hope so you have two option

    1. you could store unitnumber in your primary field in you are not using that field.

    2. You can write javascript to show unit number in lookup instead of your primary field value (refer: http://www.mindfiresolutions.com/How-to-change-display-text-of-a-lookup-field-in-Dynamics-CRM-2011-using-JavaScript-1568.php);

    let us know if you need more info in this.


    Contact Me
    Follow me on Twitter
    My Facebook Page
    Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Proposed as answer by HIMBAPModerator Wednesday, April 3, 2013 3:13 PM
    • Marked as answer by mc.gem Monday, April 8, 2013 5:13 AM
    Wednesday, April 3, 2013 3:13 PM
    Moderator

All replies

  • Lookups only store Guids, and when updating the value, you have to save the Guid. The data that is displayed for a lookup attribute is the primary name attribute of the referenced entity (by default this is the name attribute)

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    • Proposed as answer by VidhiyaM Wednesday, April 3, 2013 12:41 PM
    Wednesday, April 3, 2013 7:44 AM
    Moderator
  • Hello,

    As DavidJennaway said, in lookup you will be able to see only your primary attribute. In think in your case new_unitnumber is not a primary attribute, so for a workaround you can use your primary attribute to store your unitnumber.


    Contact Me
    Follow me on Twitter
    My Facebook Page
    Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Proposed as answer by VidhiyaM Wednesday, April 3, 2013 12:41 PM
    Wednesday, April 3, 2013 8:26 AM
    Moderator
  • Hello,

    As DavidJennaway said, in lookup you will be able to see only your primary attribute. In think in your case new_unitnumber is not a primary attribute, so for a workaround you can use your primary attribute to store your unitnumber.


    Contact Me
    Follow me on Twitter
    My Facebook Page
    Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Thanks for the reply..

    How to do this?

    "you can use your primary attribute to store your unitnumber." 

    Wednesday, April 3, 2013 9:33 AM
  • Hi,

    I need unitnumber to be display and not proertyid in my lookup...

    Any ideas please...


    • Edited by mc.gem Wednesday, April 3, 2013 12:19 PM
    Wednesday, April 3, 2013 12:18 PM
  • Hi,

    Primary attribute is the one which is created when you create a entity. it is a text field. just set your unit number to that field using j script.

    Hope this helps!

    This might be helpful, if so mark this as "Answer" or "Vote as helpful"


    Sindu M

    Wednesday, April 3, 2013 12:22 PM
  • Hi sindhu,

    So do i need to create another attiribute in second entity and when ever a lookup value is selected i need to set unit number and store it in that new Attribute?

    Wednesday, April 3, 2013 12:38 PM
  • Hi,

    you are not supposed to create any attribute. it gets created when you created your entity itself. just add it in your look up view, if it doesn't there and store your unit number over there. 


    Sindu M

    Wednesday, April 3, 2013 12:44 PM
  • Hello,

    Every entity have one primary field (mostly name) which will be displayed in lookup field in another entity.

    Now if you want to show non primary field in lookup in your case unit number I hope so you have two option

    1. you could store unitnumber in your primary field in you are not using that field.

    2. You can write javascript to show unit number in lookup instead of your primary field value (refer: http://www.mindfiresolutions.com/How-to-change-display-text-of-a-lookup-field-in-Dynamics-CRM-2011-using-JavaScript-1568.php);

    let us know if you need more info in this.


    Contact Me
    Follow me on Twitter
    My Facebook Page
    Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Proposed as answer by HIMBAPModerator Wednesday, April 3, 2013 3:13 PM
    • Marked as answer by mc.gem Monday, April 8, 2013 5:13 AM
    Wednesday, April 3, 2013 3:13 PM
    Moderator
  • Hi Mahender,

    Thanks for the link...Will try the script given there and will post the result

    Thursday, April 4, 2013 6:21 AM