Multiple Persons for a Opportunity

By | June 11, 2010

The standard SageCRM allows a user to link an opportunity with a single Person. But there could be a scenario where an opportunity can be linked to more than one person. It’s pretty simple. Here is how you can do it.
• Create a multi-select field in the opportunity to store the persons related to that opportunity/company.
• On the Person OnChange event populate the multi select field to set all the persons excluding the primary person that is already selected.

//’Initialisation
var strURL = “”;
var lc_PrimaryCompanyId = 0;
var lc_PrimaryPersonId = 0;

//’get url associated person asp page
strURL = new String(document.EntryForm.hdnUrlLinkedPerson.value);

//’get primary company id
if(document.EntryForm)
{
if(document.EntryForm.oppo_primarycompanyid)
{
lc_PrimaryCompanyId = document.EntryForm.oppo_primarycompanyid.value
if(lc_PrimaryCompanyId == “” || lc_PrimaryCompanyId == “undefined”)lc_PrimaryCompanyId = 0;
}
else
{
if(document.getElementById(“_HIDDENoppo_primarycompanyid”))
{
lc_PrimaryCompanyId = document.getElementById(“_HIDDENoppo_primarycompanyid”).value
if(lc_PrimaryCompanyId == “” || lc_PrimaryCompanyId == “undefined”)lc_PrimaryCompanyId = 0;
}
}

//’get primary person id
if(document.EntryForm.oppo_primarypersonid)
{
lc_PrimaryPersonId = document.EntryForm.oppo_primarypersonid.value
if(lc_PrimaryPersonId == “” || lc_PrimaryPersonId == “undefined”)lc_PrimaryPersonId = 0;
}
else
{
if(document.getElementById(“_HIDDENoppo_primarypersonid”))
{
lc_PrimaryPersonId = document.getElementById(“_HIDDENoppo_primarypersonid”).value
if(lc_PrimaryPersonId == “” || lc_PrimaryPersonId == “undefined”)lc_PrimaryPersonId = 0;
}
}

//’pass strURL from server side to client side
strURL += “&compid=”+lc_PrimaryCompanyId+”&personid=”+lc_PrimaryPersonId

//’get IFrame object & set href of IFrame as above url
if(typeof(document.IFrame)==’object’)
{
document.IFrame.location.href = strURL
}

If you find this content useful, Please drop us an email at crm@greytrix.com.