Monday, 30 September 2013

CRM - Lookup field name vs relationship field name

Today I thought I'd discuss a little gotcha in CRM 2011 that I'm amazed remained as a "feature" for so long! Have you ever seen "foreign key" fields in a CRM system and noticed that some are called "new_ContactId" where as others are called "new_Contact"? There's a fairly simple reason this occurs, it's basically a result of the developer/consultants preference when creating fields. Let's take a quick look at each method.

Old School - Creating relationships

If, like me, you have progressed from CRM 4 or earlier you generally create relationships between entities using the same method as always existed. You open up the entity customizations, navigate to 1:N or N:1 relationships and you get this screen:


You will notice I have highlighted what it will create the field as in the background: "new_ContactId". Most people comfortable with CRM throughout many versions will be familiar with this convention of creating fields.

New School - Lookups

Since CRM 2011 we now have a second way to create relationships. Rather than going via the relationship links on an entity simply pick the entity where you want the "foreign key" field to reside. In our example this is on the entity called "Custom Method". Navigate to the list of fields and simply add a new lookup field. Like this:


This time you'll notice I have highlighted the field name "new_Contact". We're missing the "Id" part!

Old School or New School?

I guess this is the question, which do you prefer? Personally, I prefer the new field naming convention for one simple reason. As CRM developers you don't really have your head in tables and SQL as much any more. Instead you're using plugins and Entities / Entity References. So generally in a plugin you'll use code like this:

var contactReference = (EntityReference)customMethod["new_ContactId"];

This "Id" always bugged me, because of this simple fact - it's not an Id in code, it's a reference. So if you just wanted the "Id" in code you use this:

var contactId = ((EntityReference)customMethod["new_ContactId"]).Id;

Which I don't like, because you're repeating the abbreviation "Id". In my opinion this kind of violates "DRY" so I will avoid it if at all possible. Using the new school way it looks cleaner without this repetition:

var contactId = ((EntityReference)customMethod["new_Contact"]).Id;

So whenever I create a field using the relationship convention I will manually remove the "Id" part.

18 comments:

  1. Internet, RequestLove, Request Love lets you quickly and easily schedule recurring HTTP requests. Get 2 free scheduled ... RequestLove https://requestlove.com/ recurring http request

    ReplyDelete
    Replies
    1. Hello All ▲▲▲ I am Dianna Kent and I live in Nevada, U.S .I am a full member of the Illuminati brotherhood, and am among the 1252 lodge. ▲▲▲ Iwas ordained by the Grand-master to go out to the world and bringmore members to the Illuminati, ▲ so I was requested to get 400Recruits for the brotherhood, I have 210 new recruits already. I amlooking for only 190 more to go,▲I am sure you want to be amongthe 190 people that will be earning $500,000 monthly and a brandnew car, ▲so add me up now so we can achieve this great chanceof being rich ▲. You get to live your dream life on earth filled with luxury. so i urge you not to miss thisGreat opportunity becoming what you long wished for life email: illuminatitemple6634@gmail.com‬ or Whats-app +1(854) 220-5771 for guidance






      Hello All ▲▲▲ I am Dianna Kent and I live in Nevada, U.S .I am a full member of the Illuminati brotherhood, and am among the 1252 lodge. ▲▲▲ Iwas ordained by the Grand-master to go out to the world and bringmore members to the Illuminati, ▲ so I was requested to get 400Recruits for the brotherhood, I have 210 new recruits already. I amlooking for only 190 more to go,▲I am sure you want to be amongthe 190 people that will be earning $500,000 monthly and a brandnew car, ▲so add me up now so we can achieve this great chanceof being rich ▲. You get to live your dream life on earth filled with luxury. so i urge you not to miss thisGreat opportunity becoming what you long wished for life email: illuminatitemple6634@gmail.com‬ or Whats-app +1(854) 220-5771 for guidance






      Hello All ▲▲▲ I am Dianna Kent and I live in Nevada, U.S .I am a full member of the Illuminati brotherhood, and am among the 1252 lodge. ▲▲▲ Iwas ordained by the Grand-master to go out to the world and bringmore members to the Illuminati, ▲ so I was requested to get 400Recruits for the brotherhood, I have 210 new recruits already. I amlooking for only 190 more to go,▲I am sure you want to be amongthe 190 people that will be earning $500,000 monthly and a brandnew car, ▲so add me up now so we can achieve this great chanceof being rich ▲. You get to live your dream life on earth filled with luxury. so i urge you not to miss thisGreat opportunity becoming what you long wished for life email: illuminatitemple6634@gmail.com‬ or Whats-app +1(854) 220-5771 for guidance

      Delete
  2. There may be noticeably a bundle to know about this. I assume you made certain good factors in features also. crm software hong kong, malaysia, singapore

    ReplyDelete
  3. The courts will only allow a lie detector or polygraph test into evidence if both parties agree to the fact lie detectors

    ReplyDelete
  4. We can do this with ease, grace, love, and joy, or through the school of hard knocks. The choice is always ours more info..

    ReplyDelete
  5. Be wary of taking advice from friends or family. These can be well-meaning but there are two downsides https://relationadvisor.com/

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This sort of relationship, the paralleling relationship, bears them bolster, regardless of whether express, adultentertainmentstore.com

    ReplyDelete
  8. The purpose of these activities help to make a "powerful vacuum" that will pull you towards everything that you want, while pulling everything that you want towards you. Indian live chat

    ReplyDelete
  9. Hello everyone....

    Am Mrs Lourens from Scotland
    i want to testify about a great spell caster that help me cast a spell that bring my husband back to me without any delay. I broke up with him with just little misunderstanding hoping we will get back shortly,but things was growing worse until i contacted Dr.Manbela who help me with his historical powers to bring him back, i have never believed in a spell caster until i come across him, it will be of great sin if i should go out from here without dropping the contact of this great spell caster, in case you need the help of this great spell caster you can contact him through his email: once you contact him all your problems will be over ,once again i say very big thanks to you sir for helping me to recover my husband back, and please sir keep your good work because people need your help and in their lives ,once more thank you Dr Manbela

    contact him via; Manbelaspelltemple1@gmail.com or through his WhatsApp number +2348112060023

    ReplyDelete
  10. The great service in this blog and the nice technology is visible in this blog. I am really very happy for the nice approach is visible in this blog and thank you very much for using the nice technology in this blog

    CRM for Small Business

    ReplyDelete

  11. Are you in financial crisis, looking for money to start your own business or to pay your bills? I got mine from Him. My blank ATM card can withdraw € 2,000 daily. I got it from Her last week and now I have €14,000 for free. The blank ATM withdraws money from any ATM machines and there is no name on it, it is not traceable and now i have money for business and enough money for me and my family to live on . *email: int.hackers002@gmail.com

    GET YOUR BLANK ATM CREDIT CARD AT AFFORDABLE PRICE
    *He sell this cards to all our customers and interested buyers worldwide,the card has a daily withdrawal limit of $5000 and up to $50,000 spending limit in stores and unlimited on POS.*

    *email: int.hackers002@gmail.com

    *you can also call or whatsapp us Contact us today for more enlightenment
    +1(301) 329-5298

    ReplyDelete
  12. I ‘d mention that most of us visitors are endowed to exist in a fabulous place with very many wonderful individuals with very helpful things.
    Best CRM System

    ReplyDelete


  13. Binary/bitcoin optional trading!!!!
    Way to success is very narrow,and what makes it narrow is disbelief and doubt in front of opportunity.
    Bitcoin is the real deal.Invest
    $250 - $3000
    $500- $5000
    $1000- $10000
    $1500-$15000
    $2000-$20000
    Get profit in 5 working days
    Interested individuals Contact me if you are interested or WhatsApp +1(301) 329-5298 or email: int.hackers002@gmail.com

    ReplyDelete
  14. Do you need to hack into any, databaseserver spy on Facebook,Emails, Whatsapp, Viber, Snapchat, Instagram and many more.
    I urge you to get in touch with the best people for the job, i have confirm the service when i need to spy on my spouse phone. They are good at Phone Cloning and other hack job.
    Thanks guys for the team work HACKINTECHNOLOGYATGMAILDOTCOM
    +12132951376(WHATSAPP)

    ReplyDelete
  15. It has been just unfathomably liberal with you to give straightforwardly what precisely numerous people would've promoted for an eBook to wind up making some money for their end, basically given that you could have attempted it in the occasion you needed.
    CRM Software

    ReplyDelete
  16. Hello All ▲▲▲ I am Dianna Kent and I live in Nevada, U.S .I am a full member of the Illuminati brotherhood, and am among the 1252 lodge. ▲▲▲ Iwas ordained by the Grand-master to go out to the world and bringmore members to the Illuminati, ▲ so I was requested to get 400Recruits for the brotherhood, I have 210 new recruits already. I amlooking for only 190 more to go,▲I am sure you want to be amongthe 190 people that will be earning $500,000 monthly and a brandnew car, ▲so add me up now so we can achieve this great chanceof being rich ▲. You get to live your dream life on earth filled with luxury. so i urge you not to miss thisGreat opportunity becoming what you long wished for life email: illuminatitemple6634@gmail.com‬ or Whats-app +1(854) 220-5771 for guidance



    Hello All ▲▲▲ I am Dianna Kent and I live in Nevada, U.S .I am a full member of the Illuminati brotherhood, and am among the 1252 lodge. ▲▲▲ Iwas ordained by the Grand-master to go out to the world and bringmore members to the Illuminati, ▲ so I was requested to get 400Recruits for the brotherhood, I have 210 new recruits already. I amlooking for only 190 more to go,▲I am sure you want to be amongthe 190 people that will be earning $500,000 monthly and a brandnew car, ▲so add me up now so we can achieve this great chanceof being rich ▲. You get to live your dream life on earth filled with luxury. so i urge you not to miss thisGreat opportunity becoming what you long wished for life email: illuminatitemple6634@gmail.com‬ or Whats-app +1(854) 220-5771 for guidance



    Hello All ▲▲▲ I am Dianna Kent and I live in Nevada, U.S .I am a full member of the Illuminati brotherhood, and am among the 1252 lodge. ▲▲▲ Iwas ordained by the Grand-master to go out to the world and bringmore members to the Illuminati, ▲ so I was requested to get 400Recruits for the brotherhood, I have 210 new recruits already. I amlooking for only 190 more to go,▲I am sure you want to be amongthe 190 people that will be earning $500,000 monthly and a brandnew car, ▲so add me up now so we can achieve this great chanceof being rich ▲. You get to live your dream life on earth filled with luxury. so i urge you not to miss thisGreat opportunity becoming what you long wished for life email: illuminatitemple6634@gmail.com‬ or Whats-app +1(854) 220-5771 for guidance

    ReplyDelete
  17. Hello, my name is sarai minx I was a victim of fake people posing as  binary options and bitcoin investors,  I lost a sum of $20,000 and 2BTC from my bitcoin wallet to these fakes.I was advised to hire a professional and trusted hacker.Then an in-law of mine recommended to me a specialist with the address - HELPMEHACKER147@GMAIL.COM .He helped me recover my lost bitcoins in less than 72hrs reach out to helpmehackers147@gmail.com for all hacking jobs* RECOVERY OF LOST FUNDS ON BINARY OPTIONS
    * Credit Cards Loading-University grades changing -Bank accounts hack -Erase criminal records hack -Facebook hack -Twitters hack -email accounts hack -Grade Changes hack -Website crashed hack -server crashed hack -Skype hack -Databases hack -Word Press Blogs hack -Individual computers hack -Control devices remotely hack -Burner Numbers hack -Verified Paypal Accounts hack -Any social media account hack -Android & iPhone Hack -Text message interception hack -email interception hack -Untraceable Ip and BANK Account Loading. You can also contact for other Cyber security Attacks And Hijackings,and lots more.reach out to them EMAIL:helpmehacker147@gmail.com you will be glad you did so best regards.

    ReplyDelete