有时需要有一个按钮,它会自动完成并创建一个新的电话,其中旧的一些数据被转移到新的,有一个解决方案。也可以在其他表单上实现此行为。
答案 0 :(得分:1)
创建电话功能区脚本,将在稍后步骤中创建的按钮中使用。
function SaveAsCompleteAndNew() {
// Attempt to save Activity and Mark it as Complete
SaveAsCompleted();
// If the form is not valid
if (!Xrm.Page.data.getIsValid())
return;
var url = "/main.aspx?etn=phonecall&pagetype=entityrecord&extraqs=";
var regardingString = "";
var regardingValue = Xrm.Page.getAttribute("regardingobjectid").getValue();
if (regardingValue != null) {
regardingString += "®arding_id=" + regardingValue[0].id;
regardingString += "®arding_name=" + regardingValue[0].name;
regardingString += "®arding_type=" + regardingValue[0].entityType;
regardingString = encodeURIComponent(regardingString);
}
var descriptionValue = Xrm.Page.data.entity.attributes.get("description").getValue();
var descriptionString = ((descriptionValue != null) ? encodeURIComponent("description=" + descriptionValue) : "");
// The url length is limited to about 2k chars, otherwise the link cannot be opened. Therefore the length has to be limited.
var maxDescriptionLength = 1970 - (url.length + regardingString.length);
if (descriptionString.length > maxDescriptionLength) {
var shortenedText = descriptionString.substr(0, maxDescriptionLength - 25);
// Patt1 checks if it ends with e.g. %1 and patt2 with %. These are not allowed because they have been reduced by
// substr. Correct format is three chars like %20 for white space. If there are not in correct format, url does not work
var patt1 = new RegExp("%\\d$");
var patt2 = new RegExp("%$");
if (patt1.test(shortenedText))
shortenedText = shortenedText.substr(0, shortenedText.length - 3);
else if (patt2.test(shortenedText))
shortenedText = shortenedText.substr(0, shortenedText.length - 2);
descriptionString = shortenedText + encodeURIComponent("\n...shortened...");
}
var extraqsEncoded = descriptionString + regardingString;
window.open(url + extraqsEncoded);
}
注意:如您所见,还定义了图标。将这些图标作为Web资源加载到CRM。