Snowfun

导航

 

需求:在潜在商机上增加分配按钮,分配按钮只对创建者可用,当创建者新建潜在商机并录入责任人后,点击分配按钮时,系统自动发送邮件通知被分配的责任人.

APPLET:Lead Detail Form Applet(Detail)        Lead Detail Form Applet*Detail*
BC:Lead

1.CHECK OUT APPLE后加上分配按钮,按钮触发事件APEX_Allot

2.设置按钮只对创建者可见,WebApplet_PreCanInvokeMethod

    if(MethodName=="APEX_Allot")//分配
    {
     
        this.BusComp().ActivateField("Created By");
        var     CreatedUser=this.BusComp().GetFieldValue("Created By");
        if(CreatedUser==TheApplication().LoginId())
        {
            CanInvoke="TRUE";
        }
        else
        {
            CanInvoke="FALSE";
        }
        return (CancelOperation);
    }

3.发送邮件功能

    if(MethodName == "APEX_Allot")//调用分配方法
    {
        TheApplication().TraceOn("D:\\temp\\trace.txt", "Allocation", "All");    
            this.BusComp().ActivateField("Id");//【Id】
            this.BusComp().ActivateField("Assigned To Position Id");//责任人Id
        //    LoginId = TheApplication().LoginId();
        //    this.BusComp().SetFieldValue("Retire Comment",LoginId);
            var sAssigned = this.BusComp().GetFieldValue("Assigned To Position Id");
            var serviceId=this.BusComp().GetFieldValue("Id");
            var sEmailAddr = Fun_SearchEmail(sAssigned);
        TheApplication().Trace("sEmailAddr"+sEmailAddr);
            var sBoName = TheApplication().ActiveBusObject();
            var sEmailIn = TheApplication().NewPropertySet();
            sEmailIn.SetProperty("TemplateName","APEX Call ResponseMan");//模板名称
            sEmailIn.SetProperty("BusObjName","Lead");//对旬名称
            sEmailIn.SetProperty("Id",serviceId);
            sEmailIn.SetProperty("MsgToList",sEmailAddr);//发送对象
            Fun_SendEmail(sEmailIn);
            sBoName = null;
            sEmailIn = null;
            return (CancelOperation);
    }
function Fun_SearchEmail(positionid)//20170610 查询邮箱地址
{
    TheApplication().Trace("sEmailAddr1111111111111111111111111");
    try{
        var oEmployee = TheApplication().GetBusObject("Employee").GetBusComp("Employee");
        oEmployee.SetViewMode(AllView);
        oEmployee.ActivateField("Id");
        oEmployee.ActivateField("EMail Addr");
        oEmployee.ClearToQuery();
        oEmployee.SetSearchSpec("Primary Position Id",positionid);
        oEmployee.ExecuteQuery(ForwardOnly);
        if(oEmployee.FirstRecord())
        {
            var ParentEmail = oEmployee.GetFieldValue("EMail Addr");
        TheApplication().Trace("ParentEmail"+ParentEmail);
            return ParentEmail;
        }
        else
        {
            TheApplication().RaiseErrorText("ERR:获取邮件地址失败!");
        }
        

    }
    catch(e)
    {
        throw(e)
    }
    finally
    {
        ParentEmail=null;
        oEmployee = null;
    }
}


function Fun_SendEmail(sEmailIn)
{
    
    {
        var sEmailBS;
        var sEmailOut;
        sEmailOut=TheApplication().NewPropertySet();
        sEmailBS=TheApplication().GetService("SPI HET Communication Service");
        sEmailBS.InvokeMethod("SendEmail",sEmailIn,sEmailOut);    
    }
    catch(e)
    {
        throw(e);
    }
    finally
    {
        sEmailIn=null;
        sEmailOut=null;

    }
    return true;
}

4.增加邮件模块

 4.加编:Lead Detail Form Applet(Detail)

posted on 2017-06-08 20:39  Snowfun  阅读(165)  评论(0)    收藏  举报