A typical customer request is for email created from a Case to default to send to the Responsible Contact instead of its default behavior which is to send it to the Customer.
Since the Responsible Contact isn't even on the Case form by default and a customer could be a contact, MS chose this default behavior. However most of my installations to date have an Account as the Customer and one of many Contacts related to that Account as a Responsible Contact.
This is actually something very easy to change.
Please Note: This is an unsupported modification, and any patch could overwrite this.
There is a JavaScript file, cases.js, in the following folder.
C:\Program Files\Microsoft Dynamics CRM Server\CRMWeb\_static\CS\cases
It contains a function called locAddActTo that fills the To: activity party variables that are sent in the QueryString to the activity like the URL below.
http://crmserver1:5555/MicrosoftCRM/activities/email/edit.aspx?
pId={E0F2E676-7FE2-DD11-9AE8-0003FF517B20}
&pType=112
&pName=CaseTitleGoesHere
&partyid={0EDF3D7E-E3E0-DD11-A5F9-0003FF517B20}
&partytype=1
&partyname=AccountNameGoesHere
&partyaddressused=&contactInfo=
What we care about are the partyid, partytype and partyname arguments.
function locAddActTo(iActivityType, sContentId) { var sParentId = null; var sParentType = null; var sPartyId = null; var sPartyType = null; var sPartyName = null; var sPartyLocation = null; sParentId = crmFormSubmit.crmFormSubmitId.value; sParentType = crmFormSubmit.crmFormSubmitObjectType.value; if (iActivityType != Task) { var customerId = crmForm.all.customerid.DataValue; if (!IsNull(customerId)) { if (!IsNull(customerId[0])) { sPartyId = customerId[0].id; sPartyType = customerId[0].type; } } sPartyName = crmForm.customerid.parentElement.previousSibling.innerText; sPartyLocation = ""; }
As you can see this information is being pulled from the case form customer field crmForm.all.customerid.DataValue
So all we have to do is change this to crmForm.all.responsiblecontactid.DataValue
and change the sPartyName assignment.
sPartyName = crmForm.customerid.parentElement.previousSibling.innerText;
to
sPartyName = customerId[0].name;
You can just replace the above function with the one below if you would like.
function locAddActTo(iActivityType, sContentId) { var sParentId = null; var sParentType = null; var sPartyId = null; var sPartyType = null; var sPartyName = null; var sPartyLocation = null; sParentId = crmFormSubmit.crmFormSubmitId.value; sParentType = crmFormSubmit.crmFormSubmitObjectType.value; if (iActivityType != Task) { var customerId = crmForm.all.responsiblecontactid.DataValue; if (!IsNull(customerId)) { if (!IsNull(customerId[0])) { sPartyId = customerId[0].id; sPartyType = customerId[0].type; sPartyName = customerId[0].name; } } sPartyLocation = ""; }
After you have saved the change, run iisreset to flush the cache.
That's it.
10 comments:
We are trying a following scenario. It seems like your solution might work here as well. Thoughts/guidance?
----
We want to use all 3 e-mail addresses - emailaddress1, emailaddress2 and emailaddress3 for a contact. By default, when we try to send email from CRM (using workflow), email will always be sent to "emailaddress1". It is sent to "emailaddress2/3" only and only if if "emailaddress1" is empty. How can I enable CRM to include all e-mail addresses when sending out an e-mail to a CRM contact?
Thanks, works like a charm!
(and showed me where the raw JS is :-)
For all those interested, when using CRM3.0, the file in question is (by default) located in "C:\Inetpub\wwwroot\CS\cases"
Hey Mark, I found the file you identified and made the changes as stated and recycled iis but the code is just not getting executed. I just see the default behaviour. Any ideas?
I've run into this before. Sometimes js files will stay cached in your browser. Have you exited your browser and cleared your cache?
Cool trick, Mark. Any ideas for how to apply a similar concept to custom entities so that using the Send Email button will default the To: address to a contact or list of contacts associated with the custom entity through a N:1 or 1:N relationship?
James,
I haven't looked at custom entities yet. With an N:1 or lookup, it shouldn't be too hard. However a 1:N would require a fetch from JavaScript, which can be done, but is a bit harder.
You may have to modify CRMWeb/userdefined/edit.aspx
There is an function called addActivityTo(... ) that may help you.
I'm a
Thanks for this info - I used this information to do something completely difefrent, but the code was a big leap forward to help me achieve the goal.
We used this with great success on CRM 4.0 , any idea how to do it again in CRM 2011 which we have just upgraded to? any help appreciated as we had forgotten we had worked around it before.
I just came across the need to do this but we are on CRM 2011, Rollup 12 (on premise). Do you know if it's possible to do this in 2011? I don't see this function in the case.js file in the folder path that you gave.
I have not looked at making JavaScript changes to CRM since 2011 was released since a lot of people are using CRM Online which would not allow this type of modification.
I would be more likely to attack this from another angle like modifying the ribbon to have a Send Email button that pulled from the Contact lookup when it generated the URL to create a new email message.
Post a Comment