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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested Answer

Show a field when Customer lookup is an Account

(0) ShareShare
ReportReport
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. 
I have the same question (0)
  • Suggested answer
    Leah Ju Profile Picture
    Microsoft Employee on at
    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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
11manish Profile Picture

11manish 36

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 32 Most Valuable Professional

#2
Mallesh Deshapaga Profile Picture

Mallesh Deshapaga 32

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans