locked
Help Needed RRS feed

  • Question

  • Hi all,

    I have a custom entity in CRM. I have insert, delete and update the records in this entity from outside (from .net page) not from CRM. How can I do it?

    Regards,
    GF
    Wednesday, July 15, 2009 12:47 PM

Answers

  • Sorry Fish, saw the id suffix and assumed it was a relationship attribute.

    Do this and everything should become clearer:

    http://support.microsoft.com/kb/907490

    I guess the authentication could be the issue, but the trace file will make it clearer.
    Wednesday, July 15, 2009 1:53 PM

All replies

  • You will have to use the CRM SDK to achieve that.

    This article might be helpful to you : http://technet.microsoft.com/en-us/library/cc151183.aspx
    Wednesday, July 15, 2009 12:54 PM
  • You don't explain much about what you are trying to do from where, but to creat a record in CRM from .NET (outside the CRM environment) is simple. Here is an example of an audit record being created by a C# DLL.


    // Create a audit record and populate it with details from the plug-in entity.
    DynamicEntity auditRecord = new DynamicEntity();
    auditRecord.Name = "Entity Name";
    auditRecord.Properties["new_name"] = string.Format("{0} created on {1}", entityName, DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss"));
    auditRecord.Properties["new_datelogged"] = new CrmDateTime(DateTime.UtcNow.ToString("u"));
    
    // Create the audit record.
    Guid auditId = service.Create(auditRecord);
    
    Hope this helps.

    Steve
    Wednesday, July 15, 2009 12:57 PM
  • Hi steve,

    I have written the following code. I am getting 'Server was unable to process your request error'. Is it required to add 'CRM Web reference'. Please tell me the steps.

     CrmService crmService = GetCrmService("B2BLIVE8", "b2bsrv-25:5555");
            
                // Create the DynamicEntity object.
                DynamicEntity emp = new DynamicEntity();
                emp.Name = "new_employeedetails";

                emp.Properties["new_name"] = string.Format("{0}",TextBox1.Text);
                emp.Properties["new_employeeid"] = string.Format("{0}", TextBox2.Text);
                emp.Properties["new_designation"] = string.Format("{0}", TextBox3.Text);
                emp.Properties["new_salary"] = new CrmMoney(decimal.Parse(TextBox4.Text));
                emp.Properties["new_dateofjoin"] = new CrmDateTime(DateTime.UtcNow.ToString("u"));
                emp.Properties["new_address"] = string.Format("{0}", TextBox6.Text);
               
            Guid auditId = crmService.Create(emp);

    Wednesday, July 15, 2009 1:35 PM
  • Hi Fish

    The employeeid is a lookup property so it cannot be stored the way you are doing it.
    Check the SDK but I think the syntax is something like:

     = new Lookup("attribute name", {guid Value});

    That is defintely one of your problems. Do a search for CRM Tracing. Its a buch of reg keys that allows all errors caused by the platform to be written to disk. This has helped me loads of times find the real cause of an error.


    Cheers

    Steve

    Wednesday, July 15, 2009 1:42 PM
  • id is not lookup value. its a custom attribute created by me.
    Wednesday, July 15, 2009 1:48 PM
  • Sorry Fish, saw the id suffix and assumed it was a relationship attribute.

    Do this and everything should become clearer:

    http://support.microsoft.com/kb/907490

    I guess the authentication could be the issue, but the trace file will make it clearer.
    Wednesday, July 15, 2009 1:53 PM