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 :
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

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 > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 55 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 27 Most Valuable Professional

#3
Soundari Profile Picture

Soundari 15

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans