Search Select Advanced: only people with business email address

I have a two-part problem, currently being addressed through some kludgy scripting.

We need:

1. A search select advanced field that only shows the names of people who have business email addresses; and

2. A second field that populates with the business email address of the person selected in #1.

#2 would be a pretty straightforward client-side script, but it seems like something that should be possible using a lookup rather than coding.

Forgot to mention: using SageCRM 7.1g, and the fields are on a quote screen. And despite displaying email addresses (or lack thereof) in the selection, users somehow manage to choose people with no email address surprisingly often.

Thanks!

  • 0

    I should add that our current solution is a tablescript, and it's working, but it's unbelievably slow. It makes us miss the old days when email addresses were stored in the Person table.

  • 0

    Worked out the answer to part 1 - a Search SQL string in the field definition. After a bit of trial and error, this worked:

    With no muss or fuss, this limits selections to only people with business email addresses.

    #2 - populating a "client admin email" field with the email address of the selected person - is giving me some difficulty. I expected a simple onchangescript would work, but am having trouble working out the syntax.

  • 0

    Hi,

    You can give the following a try.

    Put the following in one of the field's CreateScript

    Caption = "

    Caption += "function updateEmail(pID) { ";

    Caption += "e = ''; ";

    Caption += "switch (pID) { ";

    pRec = CRM.CreateQueryObj('select Pers_PersonId, Pers_EmailAddress from vSearchListPerson where Comp_CompanyId = ' + CRM.GetContextInfo('opportunity', 'oppo_primarycompanyid'), '')

    pRec.SelectSql();

    while (pRec.Eof != true) {

    Caption += "case '" + pRec("pers_personId") + "': ";

    Caption += "e = '" + pRec("pers_emailaddress") + "'; ";

    Caption += "break; ";

    pRec.NextRecord();

    }

    Caption += "} ";

    Caption += "document.EntryForm.quot_description.value = e; ";

    Caption += "} ";

    Caption += "" + "cript> Test:";

    And put the following for the On Change Script for the quot_admin

    javascript:updateEmail(document.EntryForm.quot_admin.value);

    Hope this helps.

    Kristi Feng

  • 0

    Kristi -

    Thanks for your answer.

    We ended up using Search SQL in the field definition of the quot_admin field (shown above), and a CreateScript in the quot_adminemail field. The CreateScript is a little kludgy, so we're looking for a better option.