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)

How to auto-populate the lookup field depends on the selected- lookup

(0) ShareShare
ReportReport
Posted on by

I try using the workflow but it need to save the transaction before it populate, I try mapping it but doesn't work.

So I have a 3 Entities Expense,Vendor,Transaction.

In Vendor Entity I have a field of Vendor Name and a lookup field for Expense Category(Expense Entity).

In Transaction Entity I have a lookup for Vendor name and Expense Category, so when I select a vendor name in the lookup it will populate the lookup of expense category.

I already used the filter, yes it show the expense category depends on the vendor name selected, but the problem in there is I need to click the lookup field of expense tracker to show the value. I want is it will auto fill the lookup field without clicking it. Thank you

*This post is locked for comments

I have the same question (0)
  • prt33k Profile Picture
    6,907 on at

    Hi,

    You basically want to auto populate a Expense Category whenever the vendor record is selected.

    For this you can write a javascript on onchange event of vendor field. Inside the JS you need to query the Expense Category value using web api. Once you get the guid of expense category, set the lookup field value to it...something like this, where retrievedCategory is object you get after making web API call.

    var value = new Array();

    value[0] = new Object();

    value[0].id = retrievedCategory.results[0].new_Category.Id;

    value[0].name = retrievedCategory.results[0].new_Category.Name;

    value[0].entityType = retrievedCategory.results[0].new_Category.LogicalName;

    Xrm.Page.getAttribute("new_Category").setValue(value;)

    Let me know if this help..

    Thanks,

    PS

  • Community Member Profile Picture
    on at

    Hi prt33k

    once I clicked the add a pop  up message appear, it said I should have atleast one library

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at
  • Meena Kannan Profile Picture
    232 on at

    Hi,

    Before adding an event handler please create a webresource that have your retrieve functions and associate this webresource to the specific form. Then call your specific function to the event handler.

    Thanks,

  • Suggested answer
    Community Member Profile Picture
    on at

    You need to create a javscript function. You can get data of Expense Category Lookup on Vendor Entity using the guid of Vendor Lookup on Transaction.

    Use this tool to generate the code for API.

    github.com/.../releases

  • Suggested answer
    Community Member Profile Picture
    on at

    Use this tool to generate the code to get values from Vendor Entity

    github.com/.../releases

  • Community Member Profile Picture
    on at

    Can you link any article creating a websource about retrieving function

  • Community Member Profile Picture
    on at

    Hi Mohd

    I tried your link, but it doesn't work, it stuck up, is there any login or change in the code?

  • Suggested answer
    Nausher Sayeed Profile Picture
    522 on at

    Hi,

    It seems that you want to filter the lookup field value based on another lookup field. Check below.

    crmpankaj.blogspot.in/.../crm-2015-javascript-lookup-filtering.html

  • Community Member Profile Picture
    on at

    Hi  Nausher

    I'm already have a filter that every time the user select a vendor name(lookup) , it will filter the expense category(lookup), my problem is I want to auto fill the field

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