Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Javascript for lookup

Posted on by 1,942

Hi all,

In appointment entity i am trying to set regarding field (party list type) to look for only user record instead of other entities. Based on the user selected in the party list, i have update the activity record owner to it.

How do i do this using JS?

Please advise

*This post is locked for comments

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: Javascript for lookup

    If it does not work with the filer, I am guessing you might add a custom field(a look-up to the user entity),hide regarding on the form, and use that new field instead.. just make sure you also have a javascript, a workflow, or a plugin, to copy that new look-up selection to the regarding field.

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Javascript for lookup

    Hi,

    I am not sure that the addPreSearch solution will work for the case that you are looking for.

    The presearch allows filtering when you know what you are looking for within the entity.

    Xrm.Page.getControl("contactid").addPreSearch(function () {

        addContactLookupFilter();

    });

    function addContactLookupFilter()

    {

       var fetchXml = "<filter type='and'><condition attribute='lastname' operator='eq' value='james' /></filter>";

       Xrm.Page.getControl("contactid").addCustomFilter(fetchXml);

    }

    In this particular case you want to restrict the values to only one entity.

    It is possible that if you have a field in the contact entity that is unique to this, you might be able to achieve it with the addPreSearch. Worth a test.

    Try it out...

  • Suggested answer
    PranavShroti Profile Picture
    PranavShroti 4,510 on at

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans