Skip to main content

Notifications

Announcements

No record found.

Customer Service forum
Suggested answer

Show a field when Customer lookup is an Account

Posted on by 4
Hello Dynamics fellas, what should I do to show a field when Customer lookup is an Account? I don't think it can be achieved with business rule. 
Categories:
  • Suggested answer
    Leah Ju Profile Picture
    Leah Ju Microsoft Employee on at
    Show a field when Customer lookup is an Account
    Hi Partner,
    You can use javascript to achieve it.
    1.Get lookup field:
    Required Attributes of lookup fields:
    id: The GUID of the item. Required for set.
    name: The name of the item to be displayed. Required for set.
    entityType: The entity name of the item. Required for set.
    2.Hide or show fields:
    function getLookupDetails(executionContext)
    {
    // Getting Form Context
    var formContext = executionContext.getFormContext();
    // Getting the value of customer id
    var customerId = formContext.getAttribute(“customerid”).getValue();
    // Getting the GUID of the lookup record
    var Id = customerId[0].id;
    // Getting Name of the lookup record
    var Name = customerId[0].name;
    // Getting Entity Name of the lookup which entity, the lookup record is belonging to.
    var EntityType = customerId[0].entityType;
    
    if(EntityType == "account")
     formContext.getControl("fieldname").setVisible(true);
    else
     formContext.getControl("fieldname").setVisible(false);
    }

    I hope you can verify my answer if it helps you! If you have any questions, please feel free to contact me.
    Regards,
    Leah

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,420 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,672 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans