locked
To identifyPotential Customer is linked to which entity - Contact or Account RRS feed

  • Question

  • Hi,

    I have come across the 'Potential Customer' field on Opportunity entity for the first time.I need to find out in my code to which entity the 'Potential Customer' field is linked to.

    Something like the below code -

    function IdentifyPotentialCustomer() {
       var customer= Xrm.Page.getAttribute("customerid").getValue();
       if (customer == "account") {
    
       } else if(customer =="contact"){
    
       }
    }

    I am not aware if there is any field to find this out.
    Any help would be appreciated.

    Thanks in Advance.

    Monday, March 9, 2015 11:47 AM

Answers

  • by JavaScript you need to check the entityType property, in addition the value is a lookup so you need to check the 0 index:

    function IdentifyPotentialCustomer() {
    var customer= Xrm.Page.getAttribute("customerid").getValue();
    if (customer != null) {
       if (customer[0].entityType == "account") {
          // is account
       } else {
         // is a contact
       }
    }
    }


    My blog: www.crmanswers.net - Rockstar 365 Profile

    Monday, March 9, 2015 12:20 PM