web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Setting default value for the look up field

(0) ShareShare
ReportReport
Posted on by

Hi Team,

I have a Look up field filtered by values based on other field selection. the look up field will be always contains only one record. so i want to set that one record to be the default one for the look up field.. how to do that. i used to filter the filed by using the related field filtering option in the field properties.  or how to set the lookup field setting by index?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mahadeo Matre Profile Picture
    17,021 on at

    Might be you  can try Javascript on form load to set this lookup value. 

    www.mscrmconsultant.com/.../get-and-set-lookup-value-using.html

  • Aileen Gusni Profile Picture
    44,524 on at

    Praba,

    What is the field selection?

    If it is a lookup field as well then you can use filtered lookup using properties only, but it wont set the default. Instead, it will need you to click the lookup button first.

    Same as well with setting default view

    bingsoft.wordpress.com/.../default-customer-lookup-to-contact-in-crm-2011

    If you want to really set the default lookup, at first, you need to retrieve the exactly record you want, you said the record always only return one data.

    You can use query using odata, see this link for your reference.

    After that after you get the record, you can use javascript to set the default lookup field,

    Example:

    function SetLookup(fieldName, idValue, textValue, typeValue)

    {

        var value = new Array();

        value[0] = new Object();

        value[0].id = idValue;

        value[0].name = textValue;

        value[0].typename = typeValue;

        Xrm.Page.getAttribute(fieldName).setValue(value);

    }

    see these posts

    jlattimer.blogspot.com/.../setting-default-lookup-values-with.html

    Or you can use query string if passed from somewhere else form

    stackoverflow.com/.../dynamics-crm-2013-setting-default-values-in-a-form-from-an-entity

    Anyway, there is an example to set the default value for your lookup

    missdynamicscrm.blogspot.com/.../Set-Default-Price-List-to-Opportunity-CRM-2011-2013-No-Hardcode.html

    Just change this query to your own query, to return your only one record and set it as default.

    Hope this helps you!

    Thanks.

  • Community Member Profile Picture
    on at

    Thanks Mahadeo,

    The drop down has a record and need to set that as default.  i am not going to set a particular value from list , if so then i can create one object and set it. here it has only one record in the drop down i need to set.

  • Community Member Profile Picture
    on at

    Hey Aileen,

    is there any way to set the first index of the drop down field to set as default? Because, using the ootb i retrieved the data that i need to display in the form. i need to set that as selected one in the dropdown. Instead of "need you to click the lookup button first"

  • Suggested answer
    Aileen Gusni Profile Picture
    44,524 on at

    Praba,

    Not using index.

    You need the guid of the record, because every people, every lookup, every sorting also will give different index.

    To set a default lookup value, crm only accepts guid of that exact record hope that can help you.

    Thanks.

  • Suggested answer
    Archer Mehrab Profile Picture
    186 on at

    Hi Prabagarane

    also there is another way for setting the default value to the lookup list, based on the different scenario , which is using the Workflow ( Real time )

    Create the work flow based on the entity which you have the Lookup filed , on create or on change condition, use update entity and select the field in the update form , and then stop the workflow

    please let me know if you might need any more explanation or screenshot

    Archer

  • Community Member Profile Picture
    on at

    Hi Archer

    I tried doing what u say but didnt suceed .. or didnt understand exactly what to update . Would appreciated your help

    Maya

  • Community Member Profile Picture
    on at

    Hi Archer,

    same here. Can you give some more details as I cannot see how you would achieve this functionality with a workflow.

    Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans