New Case Populate Account and Contact Fields

Dec 6, 2010 at 12:56 PM

Hi,

I tagged this onto the end of a post last week with no reply so I thought I had better post again just incase it was missed.

We have customized our Cases entity in CRM for the purposes of reporting and we now have a 'Customer' and 'Reported By' field. We put the 'Account' into the 'Customer' field and then we use a lookup on the 'Reported By' field to fill in the contact who reported the case.

I would like to know if it is possible to customize the portal so that these fields are automatically populated based on the user logged in to the portal? If no does anyone have any ideas how I can achieve this?

Thanks
David

Dec 6, 2010 at 3:06 PM

You can accomplish this by adding a line or two to the code-behind on the create_case.aspx page.  The case is inserted into CRM using the following code:

var incident = new Incident
{
	Title = TitleTextBox.Text,
	PriorityCode = int.Parse(PriorityCode.SelectedValue),
	CaseTypeCode = int.Parse(CaseType.SelectedValue),
	SubjectId = subject.ToEntityReference(),
	CustomerId = Contact.ToEntityReference(),
	Adx_CreatedByUsername = Contact.FullName,
	Adx_CreatedByIPAddress = Request.UserHostAddress,
};
You can adjust the code to associate the case through your reported by relationship instead of the customerid.  You can also walk up from the contact to the account and set the customerid to the account.  
To use your custom relationships, you will want to regenerate the xrm.cs file using crmsvcutil.
Shan
Dec 6, 2010 at 3:17 PM

Hi Shan,

Thank you for your reply again, sorry for asking this but could this be explained in step by step basic terms as this is my first experience with this kind of thing.

Thanks
David

Dec 10, 2010 at 2:57 PM

Anyone willing to offer some more advice on this, unfortunately I have never writen this kind of code and need some assistance.

Thanks

Apr 6, 2011 at 5:34 AM

Did you ever figure this out?