CRM 4.0 Delect entity form in javascript that lookup was generated from

Answered CRM 4.0 Delect entity form in javascript that lookup was generated from

  • Wednesday, February 13, 2013 3:15 AM
     
     

    Hi

    Can anyone tell how I can detect what type of entity form launched an entity look-up from.

    I need to add some JavaScript to override the standard behaviour so that the standard mandatory fields are changed

    Any help would be much appreciated

    Regards

    Andy May



    • Edited by AndyMaySimpl Wednesday, February 13, 2013 6:25 PM
    •  

All Replies

  • Wednesday, February 13, 2013 5:24 AM
    Moderator
     
     

    Hello,

    Not sure if I understand your question correctly, do you want to check entity name for the lookup ?? if yes you can just use typename property of lookup field like below:

    alert(lookupItem[0].typename)

    check:http://msdn.microsoft.com/en-us/library/cc189833.aspx


    Contact Me
    Follow me on Twitter
    My Facebook Page
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

  • Wednesday, February 13, 2013 6:40 PM
     
     

    Thanks for that,

    No sorry, not the entity being looked up, the entity that the lookup was called from,

    For Example if I had an account record open and clicked the contact lookup for the primary contact, and in the "Look Up Records" form I click new, I need to
    find out what the entity I started from was, in the example it would be account, but in the Create Form for the contact how can I tell that the look up was an
    account, not a lead or an opportunity.

    Obviously I have used out of the box entities in my example because in my case I am looking up a contact from a custom entity, but I need to have different mandatory
    fields on the contact dependant on which entity the contact is being looked up from, or more specifically which entity the new contact is being created from.

    Hope that makes sense.

    Regards

    Andy May



    • Edited by AndyMaySimpl Wednesday, February 13, 2013 6:42 PM
    •  
  • Wednesday, February 13, 2013 8:52 PM
    Moderator
     
     Proposed Answer
    Any way you slice it, this will be an unsupported customization, and you're likely going to run afoul of some scripting security, but I suspect some combination of "window.top" or "window.opener" will allow JavaScript to find its way back to the original page.  Generally, what I recommend in these situations is to create an alternate path for record creation that is easier to monitor and solicit parameters from.  Things like a menu action, or embedded ISV control, will probably streamline the "clickiness" of jumping through all the hoops to associate a new, child-entity-specific template of a parent record.

    Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.com Please follow the forum guidelines when inquiring of the dedicated CRM community for assistance.


  • Wednesday, February 13, 2013 10:16 PM
     
     

    That sounds interesting?

    I was just talking to a collegue, who is a web developer, he suggested using cookies, is that going to work in CRM?

  • Thursday, February 14, 2013 2:54 AM
    Moderator
     
     Answered
    Cookies would work, indeed.  I've even had success in catching a cookie set by the browser, back at the Plugin.  Again, they're well within unsupported territory, and certainly not the most elegant solution, but certainly viable.

    Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.com Please follow the forum guidelines when inquiring of the dedicated CRM community for assistance.

    • Marked As Answer by AndyMaySimpl Tuesday, March 05, 2013 12:40 AM
    •