Skip to main content

Notifications

Service | Customer Service, Contact Center, Fie...
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. 
  • 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

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