Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

C# Creating Incidents(Cases)

$
0
0

Hi all,

I've successfully created a Case from an incoming Email using C#, but I have a few fields/entities I'm unable to add to this newly created case.  So far here is what I have:

            Entity returnCase = new Entity("incident");
            returnCase.Attributes.Add("title", emailMessage["subject"]);
            returnCase.Attributes.Add("customerid", emailMessage["regardingobjectid"]);
            returnCase.Attributes.Add("caseorigincode", new OptionSetValue(2));
            returnCase.Attributes.Add("casetypecode", new OptionSetValue(3));

Which works fine; but my requirements are that I also attach the original email to this new Case.  

My other requirement is that I set the subject to a default.  (I've used the same code as "customerid", but it will not set the lookup to what I specify)

Does anyone know how to do these things for a case?

Thanks,

Bmckie

EDIT: HALF-SOLVED, HALF!

The solution to attaching the email to the Case was to add the following: 

Relationship relationship = new Relationship("Incident_Emails");
            EntityReferenceCollection relatedEntities = new EntityReferenceCollection();
            relatedEntities.Add(new EntityReference("email", emailRef.Id));
            service.Associate("incident", caseId, relationship, relatedEntities);


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>