locked
How to check from which entity the create form is loaded in MS CRM 2015? RRS feed

  • Question

  • Hi All,

    Can anyone please help me to achieve the below requirement?

    I need to validate the create form of an entity checking from where the form is loaded.

    For example:

    I need to validate the appointment create form with some business validations(on-load) only if it is created from Contact entity grid. If it is created from any other parent entity or menu list, I should not do any validations on the create form.

    How can I check from where the Create form is loaded?

    Thanks,

    Sri

    Monday, June 22, 2015 9:32 AM

Answers

All replies

  • inside your onload event you need to check if the form is create and the regarding is a contact

    function OnLoad() {

    if (Xrm.Page.ui.getFormType() ==1 && Xrm.Page.getAttribute("regardingobjectid").getValue() != null && Xrm.Page.getAttribute("regardingobjectid").getValue()[0].entityType =="contact") {

    // your code here

    }

    }


    My blog: www.crmanswers.net - CRM Theme Generator

    Monday, June 22, 2015 9:51 AM
  • Hi Gudio,

    Thanks for the reply.

    The above code is fine but I was not referring only to only appointment-contact, its just I quoted an example.

    I have 3 entities

    Entity1 - Parent

    Entity2 - child of Entity1

    Entity3 - child of Entity1 & 2

    I can create Entity3 from Entity1 or Entity2. Here, I wanted validate from which entity the record (Entity3) is loaded?

    I cannot use regarding lookup as I will be getting the lookup values of both Entity1 and Entity2 using mappings. So, I want some other way where I could figure out from which entity the form has been loaded and perform the validations accordingly.

    Thanks,

    Sri

    Tuesday, June 23, 2015 6:16 AM
  • Hi Srinivas,

    Did you check the below blog:-

    https://community.dynamics.com/crm/f/117/t/155787?pi51685=1#responses

    Looks similar to your question. There is an answer right at the end (Page 2).

    Hope this helps!!!

    Thanks,

    Prasad

    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Marked as answer by K_Srinivas Friday, July 10, 2015 9:38 AM
    Wednesday, June 24, 2015 7:27 AM