locked
"Creating entity with an invalid parent" Entity appointment referencingattribute regardingobjectid RRS feed

  • Question

  • Hello,

    I am trying to create an appointment. I want to set the attribute "regardingobjectid" .

    This is the code I use :

     

    if (!Row.regardingobjectid_IsNull) // Lookup
        {
          Lookup lookup = new Lookup();
          account oAccount = (account)service.Retrieve(EntityName.account.ToString(), new
            Guid("8E6EA756-8CAB-DF11-A26D-000C29273FE0"), new AllColumns());
          lookup.Value = oAccount.accountid.Value;
          lookup.type = EntityName.systemuser.ToString();
          apt.regardingobjectid = lookup;
        }

     

    I get the following error message :

    "Creating entity with an invalid parent"  Entity appointment referencingattribute  regardingobjectid

    What does that mean ? How does relationship between entities (parent/child) work ?

    Does anyone have an idea ?

    Thanks for helping.

    Wednesday, September 1, 2010 11:28 AM

Answers

  • I suppose that can be any entity, not only appointments...

    But even with all these informations, there's no possibility to retrieve the typename... I'm sorry... Is there any possibility to name the file with the entity type?

    Just a remarks, you should have precise from the beginning that you were working with SSIS, that should have helped...

     


    My blog : http://mscrmtools.blogspot.com

    All my tools on my new dedicated site: MSCRMTools Repository
    Wednesday, September 1, 2010 3:57 PM
    Moderator

All replies

  • You simply try to link to a user (lookup.type = EntityName.systemuser.ToString();) with an accountid...

     

    try this

    if (!Row.regardingobjectid_IsNull) // Lookup
      {
       Lookup lookup = new Lookup();
       account oAccount = (account)service.Retrieve(EntityName.account.ToString(), new
        Guid("8E6EA756-8CAB-DF11-A26D-000C29273FE0"), new AllColumns());
       lookup.Value = oAccount.accountid.Value;
       lookup.type = EntityName.account.ToString();
       apt.regardingobjectid = lookup;
      }
    


    My blog : http://mscrmtools.blogspot.com

    All my tools on my new dedicated site: MSCRMTools Repository
    Wednesday, September 1, 2010 11:31 AM
    Moderator
  • well,

    i replaced the line

     

    lookup.type = EntityName.systemuser.ToString();

     

    with

     

    lookup.type = EntityName.account.ToString();

     

    And it works.

    However, I want this regardingobjectid attribute to be dynamically assigned. So that means the input of the method is a GUID but the type is not passed. It could be an account, a contact, a deal ...

    How do i dynamically retrieve the type of the entity, based on the GUID, so that i can assign the correct type to the lookup type class ?

    Thanks.

    Wednesday, September 1, 2010 11:36 AM
  • you can't...

    You have to know what is the typecode of the object


    My blog : http://mscrmtools.blogspot.com

    All my tools on my new dedicated site: MSCRMTools Repository
    Wednesday, September 1, 2010 11:40 AM
    Moderator
  • you can't...

    You have to know what is the typecode of the object


    My blog : http://mscrmtools.blogspot.com

    All my tools on my new dedicated site: MSCRMTools Repository

    ok.

    Then is there a way to know the typecode of the object, based on the received GUID ?

    Maybe with the retrieve() method of the CrmService class ?

    Thanks

    Wednesday, September 1, 2010 12:38 PM
  • I already answer that, you can't...

    And if you really want this, you should query each entity to check if the GUID is in there... performance killing...

    The best advice I can give you is to pass the entity name as a parameter...


    My blog : http://mscrmtools.blogspot.com

    All my tools on my new dedicated site: MSCRMTools Repository
    Wednesday, September 1, 2010 12:46 PM
    Moderator
  • I already answer that, you can't...

    And if you really want this, you should query each entity to check if the GUID is in there... performance killing...

    The best advice I can give you is to pass the entity name as a parameter...


    My blog : http://mscrmtools.blogspot.com

    All my tools on my new dedicated site: MSCRMTools Repository

    ok.

    Do you have some sample code that does such thing  ? That is loop through a list of entities and check if the type of the object matches one of them.

    Previously, the type of the entity has been retrieved, based on the GUI passed as a parameter.

    Thanks.

    Wednesday, September 1, 2010 3:14 PM
  • It's quite difficult as I don't know how exactly you get the information about the entity to link...

     


    My blog : http://mscrmtools.blogspot.com

    All my tools on my new dedicated site: MSCRMTools Repository
    Wednesday, September 1, 2010 3:19 PM
    Moderator
  • By the way, isn't the DynamicEntity class supposed to help doing that ?

    thanks

    Wednesday, September 1, 2010 3:25 PM
  • no, you still need to know the entity name when working with DynamicEntity
    My blog : http://mscrmtools.blogspot.com

    All my tools on my new dedicated site: MSCRMTools Repository
    Wednesday, September 1, 2010 3:28 PM
    Moderator
  • ok.

    Well, the program (SSIS package) uses a file in CSV format.

    It contains the values of the attributes of the appointment entity to insert into the CRM.

    For instance, here is a line of that file :

    subject;location;statuscode;scheduledstart;scheduledend;scheduleddurationminutes;isalldayevent;description;requiredattendees;optionalattendees;regardingobjectid;ownerid;organizer
    Point budget;salle Dali;5;2010-11-29T15:00:00+02:00;2010-11-29T15:30:00+02:00;33;False;la description de la réunion;52439091-1593-DF11-837A-000C29273FE0|80249E5C-9CAB-DF11-A26D-000C29273FE0;6C5B4A47-9CAB-DF11-A26D-000C29273FE0|54674D69-9CAB-DF11-A26D-000C29273FE0;8E6EA756-8CAB-DF11-A26D-000C29273FE0;79AB066A-AC86-DF11-BE3E-000C29BBA875;79AB066A-AC86-DF11-BE3E-000C29BBA875
    

    Then  I can use whatever is available in the CRM SDK to retrieve the type of the entity that matches a GUID.

    Can you now provide a solution with this additional info ?

    Thanks

    Wednesday, September 1, 2010 3:53 PM
  • I suppose that can be any entity, not only appointments...

    But even with all these informations, there's no possibility to retrieve the typename... I'm sorry... Is there any possibility to name the file with the entity type?

    Just a remarks, you should have precise from the beginning that you were working with SSIS, that should have helped...

     


    My blog : http://mscrmtools.blogspot.com

    All my tools on my new dedicated site: MSCRMTools Repository
    Wednesday, September 1, 2010 3:57 PM
    Moderator
  • Adding the entity name would not help.

    Since you could pick up a required participant to an appointment from a list of Accounts and an optional participant to an appointment from a list

    of contacts, for instance.

    Thanks.

    Wednesday, September 1, 2010 4:01 PM