通过Javascript打开CRM预约提示

时间:2014-11-13 14:27:55

标签: javascript outlook dynamics-crm-2011

我使用ActiveXObject(" Outlook.Application")来显示新的约会窗口。项目类型是olAppointment(http://msdn.microsoft.com/en-us/library/office/ff869291(v=office.14).aspx)。

现在客户真的要求它不应该是默认约会而是CRM Appointment项目。有没有办法,如果用户安装了Outlook CRM插件,那么它是可能的吗?

代码:

this.setAppointment = function (data) {
try {
    out = new ActiveXObject("Outlook.Application");
    appt = **out.CreateItem(1);** //here I'd love to have CRM Apointment type
    appt.Subject = data.Subject;
    appt.Location = data.Location;
    appt.Start = formatDateForOutlook(data.Start);
    appt.ReminderMinutesBeforeStart = data.ReminderMinutesBeforeStart;
    appt.Display();
} catch (err) {                 
    if (console && console.error) {
        console.error(err);
    } else {
        alert(err);
    }
}
        }

当我说" CRM Appointment item"我的意思是这个观点 Desc

编辑:

我发现我唯一需要做的就是自动设置"关于"领域。因此,如果我能做到这样的话会很棒:

this.setAppointment = function (data) {
   try {
    out = new ActiveXObject("Outlook.Application");
    appt = **out.CreateItem(1);** //here I'd love to have CRM Apointment type
    appt.Subject = data.Subject;
    appt.Location = data.Location;
    appt.Start = formatDateForOutlook(data.Start);
    appt.ReminderMinutesBeforeStart = data.ReminderMinutesBeforeStart;
    appt.RegardingObjectId = { Id: {guid}, LogicalName: "EntityName" } //Ofc it's not working because of error: "Object doesn't support this property or method" 
    appt.Display();
  } catch (err) {                   
        if (console && console.error) {
        console.error(err);
  } else {
        alert(err);
  }

}                 }

非常感谢任何帮助或建议或解决方法

1 个答案:

答案 0 :(得分:0)

appt.RegardingObjectId = { Id: {guid}, LogicalName: "EntityName" }

您尝试引用哪种对象?如果是这样的话应该是

appt.RegardingObjectId = { Id: {guid}, LogicalName: "incident" }

和soforth等等。关注对象需要知道ID属于哪个实体。

编辑:此外,你可以使用类似的东西从javascript中提取实体名称

entityname = Xrm.Page.getAttribute("<FIELD>").getValue()[0].typename;