gpt4 book ai didi

javascript - 将回复电子邮件地址更改为动态 crm 2011 中队列的电子邮件地址

转载 作者:行者123 更新时间:2023-11-27 23:05:56 24 4
gpt4 key购买 nike

我想要做的是,当我们单击回复按钮时,发件人地址字段将填充电子邮件 ID(默认团队的默认队列的电子邮件 ID)。当前场景由登录用户填充。

我在 onLoad 上使用了以下 js 代码,但收到错误消息“对象不支持属性或方法 getAttributeValue

function CheckEnquiryReplyAddress() {
// Only complete this validate on Create Form
var formType = Xrm.Page.ui.getFormType();
var emailStatus = Xrm.Page.getAttributeValue("statecode").getValue();
var emailDirection = Xrm.Page.getAttributeValue("directioncode").getValue();



if (formType == 1 || (formType == 2 && emailStatus == "Open")) {


if (emailDirection == "1"){
var previousEmailId=getExtraqsParam("_InReplyToId", window.parent.location.search);

//getting context from the parent window
var context = Xrm.Page.context;

try {
var serverUrl = context.getServerUrl();
//The XRM OData end-point
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
var query="/EmailSet?$select=ActivityId,ActivityTypeCode,DirectionCode,";
query=query+"ToRecipients,Email_QueueItem/QueueId&$expand=Email_QueueItem&$filter=ActivityId eq guid'" + previousEmailId +"'";
query =serverUrl+ODATA_ENDPOINT+ query;

var request= new XMLHttpRequest();
request.open("GET", query, false);
request.setRequestHeader("Accept", "application/json");
request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
request.onreadystatechange=function(){ CompleteEnquiryReplyCheck(request,serverUrl);}
request.send(null);
}
catch(e) {
alert(e.Description);
}
}
}


}
function CompleteEnquiryReplyCheck(request,url)
{
if (request.readyState==4) {
if(request.status==200) {
var queue=JSON.parse(request.responseText).d.results[0];

if (queue != null) {
var queueId = queue.Email_QueueItem.results[0].QueueId.Id;
var lookup = new Array();
var lookupItem = new Object();

lookupItem.id = queueId;
lookupItem.name = queue.Email_QueueItem.results[0].QueueId.Name;
lookupItem.typename = "queue";

lookup[0] = lookupItem;

Xrm.Page.getAttribute("from").setValue(lookup);
}
}
}
}

最佳答案

获取属性值的方法不正确,要获取属性值,请使用以下方法:

 var attributeValue = Xrm.Page.getAttribute("attributeName").getValue();

所以,在你的情况下,它是:

  var emailStatus = Xrm.Page.getAttribute("statecode").getValue();
var emailDirection = Xrm.Page.getAttribute("directioncode").getValue();

关于javascript - 将回复电子邮件地址更改为动态 crm 2011 中队列的电子邮件地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36581330/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com