Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

java script

Posted on by Microsoft Employee

Hi Guys i have a question.

Is it possible to filter a text field based on lookup field?

Ex: when a lookup value is selected based on that a tech filed value should be populated, is it possible?

please give possible resolution.

Thank you.

*This post is locked for comments

  • Suggested answer
    Ivan Ficko Profile Picture
    Ivan Ficko 1,380 on at
    RE: java script

    I can suggest you to store additional information (district, sales rep, district manager, manager) on territory entity. Then you need to add Javascript function on change attribute of territory field on the form that will fetch exact territory with additional data via Web API query. After you get your territory with data you can easily populate those fields like Aric suggested in the upper post.

    My favorite tool for generating Web API queries is CRM REST Builder by Jason Lattimer, so you can check it on the link:

    github.com/.../CRMRESTBuilder

    If you need additional information about my suggestion feel free to ask.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: java script

    Thank you Aric. I will try this

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: java script

    Should be simple enough:

    Use the following to get the text value of the lookup:

    function setTextFields()

    {

      var lookupText = getLookupName("new_lookupcontrolname");

      if (lookupText != '')

      {

         Xrm.Page.getAttribute("new_textfieldcontrolname").setValue(lookupText);

      }

    }

    function getLookupName(fieldName) {

       var field = Xrm.Page.getAttribute(fieldName);

       if (field != null) {

           var fieldId = field.getValue();

           if (fieldId != null)

               return fieldId[0].name.toString();

           else

               return '';

       }

    }

    Hope this helps.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: java script

    Territory will be a Pick List. We will populate District, Sales Rep, District Manager & Manager (These columns are always disabled) based on Territory.

  • Suggested answer
    Ivan Ficko Profile Picture
    Ivan Ficko 1,380 on at
    RE: java script

    Yes it is possible by executing simple Javascript SDK functions. You can explain you case more in detail so maybe we can drop some code samples.

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans