Modifying the values of User Select field of Email Editor Screen in Sage CRM

By | August 1, 2017

One of the most helping feature of Sage CRM Email editor screen is the User Select field which helps to select and add the CRM user in To, CC and Bcc fields. This feature reduces the efforts of CRM User to remember or re-type the Email ids every time they open the New Email screen. But this feature proves helpful for internal purpose only. What if you need to send emails to the Person’s associated with the Company?

New Stuff: Allow users to edit additional user preferences options on their own.

The New Email Screen when opened from within the context of any Case or Opportunity record; displays the Person Email Id which is linked with the record in To field by default.

In order to list out All the Person’s names associated with the Company follow below steps –
1. Login into CRM.
2. Go to Administration -> Customization -> Communication -> Screens.
3. Then open EmailFilingBox screen and add following Create Script on Action field.
var sCompanyId=”0″;
sCompanyId =HasValue(eWare.GetContextInfo(“Cases”,”Case_PrimaryCompanyId”));
if(sCompanyId==””)
{
var sCaseId=”0″;
sCaseId = HasValue(eWare.GetContextInfo(“Communication”,”Comm_CaseId”));
if(sCaseId==””)
{
var sSelectPQL=”SELECT Case_PrimaryCompanyId FROM Cases(NOLOCK) WHERE Case_Deleted IS NULL AND Case_CaseId='”+sCaseId+”‘”;
RecCases = eWare.CreateQueryObj(sSelectPQL);
RecCases.SelectSql();
if(!RecCases.eof)
{
sCompanyId=HasValue(RecCases(“Case_PrimaryCompanyId”));
if(sCompanyId==”null”||sCompanyId==”undefined”||sCompanyId==””)sCompanyId=””;
}
}
}
if(sCompanyId!=””)
{
var sFullName=””;
var sEmailAddress=””;
var sSelectFullNameSQL=” SELECT (SELECT STUFF((Select ‘,’+ CAST(RTRIM(ISNULL(Pers_FirstName, ”)) + ‘ ‘ + RTRIM(ISNULL(Pers_LastName, ”)) AS NVARCHAR(MAX)) FROM vPerson(NOLOCK) WHERE Pers_Deleted IS NULL AND ISNULL(Pers_EmailAddress, ”)<>” AND Pers_CompanyId=”+sCompanyId+” ORDER BY Pers_PersonId FOR XML PATH(”)),1,1,”)) AS Pers_FirstName,(SELECT STUFF((Select ‘,’+ CAST(Pers_EmailAddress AS NVARCHAR(MAX)) FROM vPerson(NOLOCK) WHERE Pers_Deleted IS NULL AND ISNULL(Pers_EmailAddress, ”)<>” AND Pers_CompanyId= “+sCompanyId+” FOR XML PATH(”)),1,1,”)) AS Pers_EmailAddress “;
var RecPersFullName = eWare.CreateQueryObj(sSelectFullNameSQL);
RecPersFullName.SelectSql();
if(!RecPersFullName.eof)
{
sFullName=new String(RecPersFullName(“Pers_FirstName”));
sEmailAddress=new String(RecPersFullName(“Pers_EmailAddress”));
if(sFullName==”null”||sFullName==”undefined”||sFullName==””)sFullName=””;
if(sEmailAddress==”null”||sEmailAddress==”undefined”||sEmailAddress==””)sEmailAddress=””;
}
if(sFullName!=”” && sEmailAddress!=””)
{
Caption+=”Action: <input type=hidden name=HDNFullName id=HDNFullName value='”+sFullName+”‘>”
Caption+=” <input type=hidden name=HDNEmailAddress id=HDNEmailAddress value='”+sEmailAddress+”‘>”
}
}
function HasValue(px_Value) {
ll_Return = “”;
lc_Value = new String(px_Value);
if(lc_Value != “” && lc_Value != “undefined” && lc_Value != “NaN”) {
ll_Return = lc_Value;
}
return ll_Return;
}
4. Click on Save Button.
5. Create a JavaScript page (e.g. Communication.js) with below jQuery Code in “<installation path>”\WWWRoot\js\custom” folder.
crm.ready(function()
{
var sAct=crm.getArg(“Act”,crm.url());
if(sAct==”” || sAct==”null” || sAct==”undefined”)sAct=””;
var sKey0=crm.getArg(“Key0″,crm.url());
if(sKey0==”” || sKey0==”null” || sKey0==”undefined”)sKey0=””;
if(sKey0==”8″ && sAct==”1500″)
{
CommunicationOnLoad();
}
});
function CommunicationOnLoad()
{
if($(‘#HDNFullName’) && $(‘#HDNEmailAddress’))
{
var FullName=$(‘#HDNFullName’).val();
var EmailAddress=$(‘#HDNEmailAddress’).val();
if(FullName!=”” && EmailAddress!=””)
{
var text = $(‘#comm_userid :selected’).val();
if (text == ‘-None-‘) return;
$(‘#comm_userid :not([value^=”‘+ text +'”])’).remove();
$(‘#comm_userid [value^=”1″]’).remove();//For remove System Administrator
var substrFullName = FullName.split(‘,’);
var substrEmailAddress = EmailAddress.split(‘,’);
for ( var i=0; i<substrFullName.length; i++ )
{
var sMailId=substrFullName[i] +” <“+ substrEmailAddress[i] + “>”
InsertIntocomm_userid(sMailId,sMailId);
}
}
}
}
//Add option
function InsertIntocomm_userid(FirstValue,SecondValue)
{
var option1=document.createElement(‘option’);
option1.value=FirstValue;
document.EntryForm.comm_userid.options.add(option1);
option1.innerText = SecondValue;
}
6. Go to Administration -> System -> Metadata.
7. Check Refresh All checkbox and click on Execute Refresh button.
User select field will now list out all the Person’s name as shown below.

About Us
Greytrix a globally recognized Premier Sage Gold Development Partner is a one stop solution provider for Sage ERP and Sage CRM needs. Being recognized and rewarded for multi-man years of experience, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third party add-on development and implementation expertise.

Greytrix has some unique integration solutions for Sage CRM with Sage ERPs (Sage Enterprise Management (Sage X3), Sage Intacct, Sage 100Sage 500 and Sage 300).We also offer best-in-class Sage ERP and Sage CRM customization and development services to Business Partners, End Users and Sage PSG worldwide. Greytrix helps in migrating of Sage CRM from Salesforce | ACT! | SalesLogix | Goldmine | Sugar CRM | Maximizer. Our Sage CRM Product Suite includes Greytrix Business Manager, Sage CRM Project Manager, Sage CRM Resource Planner, Sage CRM Contract Manager, Sage CRM Event Manager, Sage CRM Budget Planner, Gmail Integration, Sage CRM Mobile Service Signature and Sage CRM CTI Framework.

Greytrix is a recognized Sage Rockstar ISV Partner for GUMU™ Sage Enterprise Management – Sage CRM integration also listed on Sage Marketplace.

For more information on our integration solutions, please contact us at sage@greytrix.com. We will be glad to assist you.