1. As many of you already know that the CRM lookup field saves the GUID of the related entity. Let's have a deep view of the lookup field. When you create a relationship between two entities, one entity can reference the other entity through a lookup field. However it's not just create one attribute in the database, it means although you can only see one relationship created in CRM interface, there are some invisible attributes for internal/customizer use. Let's see an example, we know that we can reference some values from a lookup fields:
crmForm.all.regardingobjectid.DataValue[0].id; // The GUID of the lookup.
crmForm.all.regardingobjectid.DataValue[0].name; // The text value of the lookup.
crmForm.all.regardingobjectid.DataValue[0].typename; // The entity type name.
But how CRM get those values? Actually when user open a CRM record, those attributes are downloaded from CRM database to the 'containers' which can be seen from entity's customization.xml, it's a complex structure which I don't want to explain in this post. So when you create a relationship between two entities, the CRM system will create more than 2 'containers'(attributes) in the database to keep other information about the lookup field(e.g. id, typename etc).
2. Set the default value for a lookup field, let's take a look at the special lookup field again: regardingobjectid
In many cases, the regardingobjectid is default to Account, but how can we change the default value to Contact?
In the onLoad() event, you can set the default attributes by using setAttribute method which is unsupported by Microsoft, however it's a standard XML DOM method.
Let's see some examples:
crmForm.all.regardingobjectid.setAttribute("lookuptypes", "1,2"); //only show account and contact
crmForm.all.regardingobjectid.setAttribute("lookuptypeIcons", "/_imgs/ico_16_1.gif :/_imgs/ico_16_2.gif"); //set the icons
crmForm.all.regardingobjectid.setAttribute("defaulttype", "2"); //default to contact
Instead of using setAttribute method, you can also use CRM method directly:
crmForm.all.regardingobjectid.lookuptypes = "1,2";
crmForm.all.regardingobjectid.lookuptypeIcons = "/_imgs/ico_16_1.gif:/_imgs/ico_16_2.gif";
crmForm.all.regardingobjectid.defaulttype = "2";
3. If you have a look of the URL when you open a lookup window, you may see how CRM calls a lookup:

/lookupsingle.aspx?class=ActivityRegarding&objecttypes=1,2,3,4&browse=0&ShowNewButton=1&ShowPropButton=1&DefaultType=0
lookupsingle.aspx has some parameters which can be referenced by our developers, those parameters are:
Objecttypes : Entity code, e.g. Objecttypes = "1, 2" //show account and contact
DefaultType : the default lookup entity, e.g. DefaultType = "2" //default to contact
Browse : bool, 0 = show the "Look for" bar; 1 = browse model, hide the "Look for " bar.
ShowNewButton : bool, 0 = hide the "New" button; 1 = show the "New" button.
ShowPropButton : bool, 0 = hide the "Properties" button; 1 = show the "Properties" button.
In an IFRAME or a ISV solution, if you don't want users to see the 'New' Button, you can just set the URL to:
/lookupsingle.aspx?class=ActivityRegarding&objecttypes=1,2,3,4&browse=0&ShowNewButton=0&ShowPropButton=1&DefaultType=0
It's cool so far! But how about if want to hide the 'New' button in CRM?
You can't just say: crmForm.all.regardingobjectid.ShowNewButton = 0; it doesn't work. But what you can do is in the onLoad() event, use attachEvent method to attach a setadditionalparams event for the regardingobjectid. Again, those methods are all unsupported customisations, however, those are widely used in the Web development.
/*
Function: show/hide the 'New' button of lookup
bShow = 0 : hide the New Button
bShow = 1 : show the New Buton
*/
function NewButton(bShow)
{
return function()
{
crmForm.all.regardingobjectid.AddParam("ShowNewButton", bShow);
}
}
crmForm.all.regardingobjectid.attachEvent("setadditionalparams",NewButton(0));

11 comments:
Hi, thanks for this article. The only thing I am not sure about - where to add the addtional JavaScript Code?!
The Lookup View of a specific entity doesn't have an editable onLoad event ? Or did you mean to just add this snippet to the lookupsingle.aspx to set the default Item to what we want?
Thanks, yours renew
It's in entity's onLoad() event.
I am using the /_controls/lookup/lookupsingle.aspx from a custom aspx page and a custom 'lookup style' text box server control. It all works fine but i can't seem to make the Remove Value button enabled. Any ideas?
Thanks
Ant
I have tried to add the Campaign entity as a lookuptype to the regarding object of a phone call. It puts it into the list in the lookup dialog, but when I select it gives a crm error dialog and writes nothing the the event log?
Any Ideas
Catch the wow gold star that holds your gold in wow destiny,cheap wow gold the one that forever maplestory money twinkles within your heart. Take advantage of precious opportunities while they still sparkle before you. Always believe that your buy maplestory mesos ultimate goal is attainable cheap mesos as long as you commit yourself to it.maple money Though barriers may sometimes stand in the way of your dreams, remember that your destiny is hiding behind them.wow gold kaufen Accept the fact that not everyone is going to approve of the choices Maple Story Accounts you've made. Have faith in your judgment.wow gold farmen Catch the star that maple story money twinkles in your heart and it will lead you to your destiny's path. Follow that pathway and uncover the sweet sunrises that await you. Take pride in your accomplishments, as they are stepping stones to your dreams. Understand that you may make mistakes, powerlevelbut don't let them discourage you.ms mesos Value your capabilities and talents for they are what make you truly unique. The greatest gifts in life are not purchased, but acquired through hard work and determination.maplestory mesos Find the star that twinkles in your heart?for you alone maplestory powerleveling are capable of making your brightest dreams come true
If you wow gold were in wow gold any doubt buy wow gold that the buy wow gold God Wars cheap wow gold Dungeon was cheap wow gold challenge enough wow power leveling for you, wow power leveling look no further power leveling than the giant power leveling demon, K’ril wow gold Tsutsaroth. Once buy wow gold thought of as cheap wow gold nothing more world of warcraft gold confirm his existence.
Looking wow gold for thrilling weapons, wow gold items and new pets? Beating wow gold the more powerful and wow gold 5000 crueler giants? Becoming the cheers of your clanbuy wow gold 5000and impressing your friends? wow gold All in http://www.masswowgold.com, We are the wow gold best alliance of the online wow goldgame players! We have: 24×7 online wow gold support;50,000+ registered users;10,000+ Paypalcheap WOW goldreputations;4 years professional service provider;We get wow gold gold from the players cheap WOW gold who do not need them any more or wow gold 5000 collect them from the direct cheap WOW gold gold farmers with wow gold lower price. Now the sell wow gold WOW gold is under big promotion. sell wow gold Registered Member will get 10% bonus.wow gold 5000 Most of the orders can be completedv sell wow gold in 3 hours. And we will give our customers the extra 5% gold if wow gold 5000 we can not complete the order in cheap WOW gold 24 hours.We deliver cheap WOW gold the gold by sell wow gold face-to-face trade wow gold 5000 in game only. Full refund will be warranted if wow gold 5000 we can not complete the cheap WOW gold orders in cheap WOW gold time.
runescape
runescape gold
runescape money
runescape powerleveling
runescape power leveling
runescape
runescape gold
runescape money
runescape powerleveling
runescape power leveling
runescape
runescape gold
runescape money
lotro
lotro gold
lotro powerleveling
lotro power leveling
lotro money
lotro
lotro gold
lotro money
lotro powerleveling
lotro power leveling
world of warcraft money
world of warcraft gold
wow gold
wow money
maplestory mesos
maple story mesos
maplestory mesos
maple story mesos
runescape
runescape gold
runescape money
runescape
runescape gold
runescape money
China Highlights
China Highlights
China Tours
China Hotels
China Attractions
Beijing China Travel
Shanghai China Travel
Xi'an China Travel
Guilin China Travel
Yangshuo China Travel
Weekends to people ig2tmean that they can have a two-day wowgold4europe good rest. For example, people [url=http://www.gameusd.org]gameusd[/url]can go out to enjoy themselves or get meinwowgold together with relatives and friends to talk with each storeingame other or watch interesting video tapes with the speebie whole family.
Everyone spends agamegold weekends in his ownmmofly way. Within two days, some people can relax themselves by listening to music, reading novels, or watching ogeworld films. Others perhaps are more active by playing basketball, wimming or mmorpgvip dancing. Different people have different gamesavor relaxations.
I often spend weekends withoggsale my family or my friends. Sometimes my parents take me on a visit to their old friends. Sometimesgamersell I go to the library to study or borrow some books to mmovirtex gain much knowledge. I also go to see various exhibition to broaden rpg trader my vision. An excursion to seashore or mountain resorts is my favorite way of spending weekends. Weekends are always enjoyable for me.
酒店經紀PRETTY GIRL 台北酒店經紀人 ,禮服店 酒店兼差PRETTY GIRL酒店公關 酒店小姐 彩色爆米花酒店兼職,酒店工作 彩色爆米花酒店經紀, 酒店上班,酒店工作 PRETTY GIRL酒店喝酒酒店上班 彩色爆米花台北酒店酒店小姐 PRETTY GIRL酒店上班酒店打工PRETTY GIRL酒店打工酒店經紀 彩色爆米花
Post a Comment