Advanced Email Management System

Hi,


I'm looking for some help with the rulesets in the Advanced Email Management system and how to create opportunities from emails.


I've successfully had emails be filed against Person/Company records but when I select the Action as 'Create Opportunity' it won't create the opportunity.

I'm using the communication.js template in which I've placed, under 'Utility Functions';

function createOppo(EntitiyName)
{
var myRecord = CRM.CreateRecord("opportunity");
myRecord.Oppo_PrimaryCompanyId= PersonQuery("pers_companyid");
myRecord.Oppo_PrimaryPersonId= PersonQuery("pers_personid");
myRecord.Oppo_AssignedUserId= AssignedUser;
myRecord.Oppo_ChannelId= AssignedChannel;
myRecord.Oppo_Description= eMail.Subject.substring(0, 39);
myRecord.Oppo_Source= "Email";
myRecord.Oppo_Note= "Please see the attached email";
myRecord.Oppo_Status= "In Progress";
myRecord.Oppo_Stage= "Lead";
myRecord.Oppo_Opened = mydate.getVarDate();

myRecord.SetWorkflowInfo("Opportunity Workflow", "Lead")
myRecord.SaveChanges();
intOppoRecordID = myRecord.oppo_opportunityid;
}


However, it still won't create any opportunities. Am I missing something?

Thanks

  • 0

    Hello Will,

    From what you have provided, the only problem I can see is the function name

    function createOppo(entityname) - should be: function createOppo() { ..

    What have you got under the Start Main Functions?

    Do you also require a communication to be created and filed?

    Regards,

    Penny

  • 0

    Hi Pennv,

    Thanks for that, I'd seen it written like that in some guides so assumed it was needed.

    Under Main Functions;

    //UserQuery

    [code language="sql"]

    SELECT * FROM vUsers WHERE

    user_emailaddress = FromAddress

    OR

    user_mobileemail = FromAddress

    [/code]

    //PersonQuery

    [code language="sql"]

    SELECT * FROM vEmail, vPerson WHERE email_personid

    = pers_personid AND emai_emailaddress = FromAddress

    [/code]

    //CompanyQuery

    [code language="sql"]

    SELECT * FROM vEmail, vCompany WHERE

    emai_companyid = comp_companyid AND

    emai_emailaddress = FromAddress

    [/code]

    //function name must exist in translations (custom_caption) table

    function EbayQuery()

    {

    MsgHandler.Log("EbayQuery function called");

    //check if person exists

    if (!PersonQuery.EOF)

    {

    MsgHandler.Log("Person found");

    createOppo("Opportunity");

    createComm("Communication");

    sendEmail("strsubject");

    }

    else

    {

    //createLead();

    //createComm("Lead");

    //sendEmail();

    }

    }


    I've a createComm function and SendMail function also in the Utility section.

    The purpose of this is that we're going to feed our ebay queries/messages into the Email Manager account and then have them file against Person/Company records in CRM. Therefore we also need the system to auto email the customer to inform them that we've received their message

  • 0

    I've been making some progress with my template.

    However, I'm getting the following error in the MainAction;

    function MainAction()

    {

    jscript error: [SafeCall Exception]: field pers_source not found Line: 287 Char: 0

    if ((!CompanyQuery.EOF) && (CompanyQuery("comp_source")=="ebay")

    || (!PersonQuery.EOF) && (PersonQuery("pers_source")=="ebay")

    )

    I've tried adding the Pers_Source field to the PersonQuery sql statement;

    SQL = "SELECT * FROM vEmail, vPerson WHERE email_personid = pers_personid AND emai_emailaddress = FromAddress AND Pers_Source = 'ebay' ";


    I've added the Pers_Source via my Ruleset so that if either Comp_Source or Pers_Source = to 'ebay' then to create an opportunity etc.


    Where does Pers_source need to be referenced in the js template if not in the SQL statement?

    Edit: it also errors on comp_source.

  • 0

    Hi Will,

    Sorry I haven't had a chance to get back to you on your issue.

    The lead or oppo entity have a field you can use - lead_source = ebay or oppo_source = ebay.

    Isn't an ebay enquiry referred to as a suspect/prospect or lead? I would use the create lead for this.

    For an example, have a look at the support.js or the template.js file if you haven't already.

    There is some training on Advanced email manager available if you are a partner which I would recommend checking out too.

    Cheers Will.

  • 0

    I've rewritten alot of the script and it now create communication records successfully, however when trying to get it to then create an opportunity via the mainaction I get the following;

    I'm not sure why it's stating that a } is required at Line 416 when there is already a } at Line 416.

    I've checked the entire script twice and every set of brackets matches up.

  • 0

    Hi Penny,

    Thanks for getting back to me.

    We're planning on having several Advanced Mail Manager scripts to do several different things. One of which will be creating leads from Ebay queries.

    The one I'm working on currently needs to create a communication against the person/company and then create an opportunity followed by an email sent to the person/company.

    I've got the first step working, but get an error as seen in my previous post when trying to create an opportunity.

    Thanks,

    Will

  • 0

    Hi Penny,

    Good news! I've got the whole script working, it creates a communication, opportunity and sends out an email to the user.

    One question, however, is there a way to get the a copy of the communication to be in the created Opportunity? Would this need to be included in the CreateOppo() function?

    Thanks for your help

  • 0

    this would need to be set in the createcommunication function where you would need to link the opportunity id that has got created. So you would essentially begin with the opportunity creation, use that identifier to be updated into the communication table through the comm_link table.