Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Tuned Listener
Posts: 67
Registered: ‎11-29-2011

Open Contact in Code

Hi,

 

On my Contact Form, I have a dropdown list which contains some other contacts associated to the current contact. I would like to add a event handler to the dropdown list which when one contact in the list is selected, the contact form will jump to show the selected contact information. How should I implement this in Code? Or more specifically, how to open the contact form with contact id in code?

 

Thanks a lot!

Bronze Super Contributor
Posts: 129
Registered: ‎06-09-2009

Re: Open Contact in Code

Server side:

Response.Redirect("Contact.aspx?entityid=" + strSelectedContactID);

 

Client Side:

window.navigate("Contact.aspx?entityid=" + strSelectedContactID);

Raul A. Chavez
http://raul.chavez.com
http://www.crmbi.com
Tuned Listener
Posts: 67
Registered: ‎11-29-2011

Re: Open Contact in Code

Thanks a lot for your suggestion.

 

When I use System.Web.HttpContext.Current.Response.Redirect("CONTACT.aspx?entityid=" + associatedId), I got errors as below:

 

An exception occurred executing the dynamic method ContactDetails.lbPropertyName_OnChange.

 

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.

 

Do you know what is wrong?

Tuned Listener
Posts: 67
Registered: ‎11-29-2011

Re: Open Contact in Code

Additional Information. I am handling this is a business rule method like below 

 

public static void lbPropertyName_OnChange(IContactDetails form, EventArgs args)
{
IContact contact = (IContact)form.CurrentEntity;
string associatedId = Utils.DBUtil.getAssociatedContactID(contact.Id.ToString(), form.lbPropertyName.Text);
System.Web.HttpContext.Current.Response.Redirect("CONTACT.aspx?entityid=" + associatedId);
}

 

 

Bronze Super Contributor
Posts: 129
Registered: ‎06-09-2009

Re: Open Contact in Code

That explains the error.

The quick workaround is to use a C# snippet Action instead of the Code Snippet Action.

 

 

 

If you have a reflection tool, you may want to look at the PanelRefreshService. It has a method called SetContextAndRefresh, it seems as if you can set the Type and ID and have the Client refresh, but I have not tried this myself.

Raul A. Chavez
http://raul.chavez.com
http://www.crmbi.com
Tuned Listener
Posts: 67
Registered: ‎11-29-2011

Re: Open Contact in Code

Hi,

 

Which dll is the PanelRefreshService in? Thanks!