locked
Is the entity saved? RRS feed

  • Question

  • Is there an easy way, or complex for that matter, to determine if an instance of an entity has been saved.  I need to stop some activity on my custom entity form if the instance has not yet been saved.  Sound simple.  I have a feeling it is not.

    Thanks,
    Jodi
    Wednesday, September 2, 2009 8:23 PM

Answers

  • Will this work? if(crmForm.FormType == 1 )

    Wednesday, September 2, 2009 9:09 PM
  • you could also use the example below.

    // if it is a create form
    if(crmForm.FormType == 1)
    {
    crmForm.all.new_project_id.Disabled = true;
    }
    // if it is update form
    else if(crmForm.FormType == 2)
    {
    crmForm.all.new_referringcontactid.DataValue = null;
    }

    http://mscrmblog.net
    Microsoft Certified Business Management Solutions Specialist
    Microsoft Certified CRM Developer
    • Proposed as answer by ckeller Tuesday, September 8, 2009 10:45 AM
    • Marked as answer by Donna EdwardsMVP Wednesday, September 9, 2009 8:14 PM
    Thursday, September 3, 2009 2:53 AM
  • Thursday, September 3, 2009 2:15 PM

All replies

  • Isn't it interesting how when you say it out loud the light goes on?

      if (crmForm.objectid == null)
    Wednesday, September 2, 2009 8:45 PM
  • Hi
    I am not sure what you are looking for, but whenver an instance of an entity is saved. The Post Create/Update Plugin for that entity is fired. So you can put your logic there. I think the Post event is not fired in case of exception of pre create/update.
    i hope it helps or let me know what exactly are you looking for?
    Wednesday, September 2, 2009 8:48 PM
  • Thanks Muhammah,
    But I think I am looking for something very simple.  I have a report button that executes some javascript on the load of my custom entity.  The javascript creates a url and runs a report.  I do not want to run the report if the entity instance is new( on create ).  
    Wednesday, September 2, 2009 9:06 PM
  • Will this work? if(crmForm.FormType == 1 )

    Wednesday, September 2, 2009 9:09 PM
  • Yep, that worked.  Sorry for the stupid question.  It has been a long day.
    Wednesday, September 2, 2009 9:14 PM
  • you could also use the example below.

    // if it is a create form
    if(crmForm.FormType == 1)
    {
    crmForm.all.new_project_id.Disabled = true;
    }
    // if it is update form
    else if(crmForm.FormType == 2)
    {
    crmForm.all.new_referringcontactid.DataValue = null;
    }

    http://mscrmblog.net
    Microsoft Certified Business Management Solutions Specialist
    Microsoft Certified CRM Developer
    • Proposed as answer by ckeller Tuesday, September 8, 2009 10:45 AM
    • Marked as answer by Donna EdwardsMVP Wednesday, September 9, 2009 8:14 PM
    Thursday, September 3, 2009 2:53 AM
  • Thursday, September 3, 2009 2:15 PM