在我的 Microsoft CRM 中,我需要创建一个复制潜在客户的克隆按钮,以便我的用户可以修改其中的少量数据然后保存。我成功地将按钮添加到功能区并按照以下代码的设置克隆了我的潜在客户:
网络资源:
<RibbonDiffXml>
<CustomActions>
<CustomAction Id="My.MSCRM.incident.form.Clone.Button.CustomAction" Location="Mscrm.Form.incident.MainTab.Collaborate.Controls._children" Sequence="0">
<CommandUIDefinition>
<Button Command="MSCRM.incident.form.Clone.Command" Id="MSCRM.incident.form.Clone.Button" Image32by32="$webresource:My_Clone32" Image16by16="$webresource:My_Clone16" LabelText="$LocLabels:MSCRM.incident.form.Clone.Button.LabelText" Sequence="0" TemplateAlias="o1" ToolTipTitle="$LocLabels:MSCRM.incident.form.Clone.Button.ToolTipTitle" ToolTipDescription="$LocLabels:MSCRM.incident.form.Clone.Button.ToolTipDescription" />
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
</Templates>
<CommandDefinitions>
<CommandDefinition Id="MSCRM.incident.form.Clone.Command">
<EnableRules/>
<DisplayRules>
<DisplayRule Id="MSCRM.incident.form.Clone.DisplayRule" />
</DisplayRules>
<Actions>
<JavaScriptFunction FunctionName="cloneCase" Library="$webresource:My_CustomRibbonJavascript" />
</Actions>
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules>
<DisplayRule Id="MSCRM.incident.form.Clone.DisplayRule">
<FormStateRule State="Create" InvertResult="true" />
</DisplayRule>
</DisplayRules>
<EnableRules/>
</RuleDefinitions>
<LocLabels>
<LocLabel Id="MSCRM.incident.form.Clone.Button.LabelText">
<Titles>
<Title description="Clone Case" languagecode="1033" />
</Titles>
</LocLabel>
<LocLabel Id="MSCRM.incident.form.Clone.Button.ToolTipDescription">
<Titles>
<Title description="Clone Case" languagecode="1033" />
</Titles>
</LocLabel>
<LocLabel Id="MSCRM.incident.form.Clone.Button.ToolTipTitle">
<Titles>
<Title description="Clone Case" languagecode="1033" />
</Titles>
</LocLabel>
Javascript:
function GetContext() {
var _context = null;
if (typeof GetGlobalContext != "undefined")
_context = GetGlobalContext();
else if (typeof Xrm != "undefined")
_context = Xrm.Page.context;
return _context}
function cloneCase() {
if (Xrm.Page.data.entity.getId() == null) {
alert('First save the record before Clone Case')
}
else {
var CRMContext = GetContext();
var serverUrl = CRMContext.getServerUrl();
var caseid = Xrm.Page.data.entity.getId();
caseid = caseid.replace('{', '').replace('}', '');
//Below URL is for CRM online
var url = serverUrl + 'main.aspx?etc=112&extraqs=%3f_CreateFromId%3d%257b' + caseid + '%257d%26_CreateFromType%3d112%26etc%3d112%26pagemode%3diframe&pagetype=entityrecord';
Window.open(url, 900, 600, 'toolbar=no,menubar=no,resizable=yes');
}
}
问题是,当我保存克隆的潜在客户时,由于我要复制的是带有原始潜在客户 ID 的 URL,所以当我保存它时,它不会保存为新潜在客户,而是保存而不是原始潜在客户,因为它具有相同的 id。关于如何以保持 URL 克隆的方式修改我的 JavaScript 代码的任何想法,因为它是获取与原始信息完全相同的信息的唯一方法,但保存为新潜在客户而不是 Microsoft CRM 中的原始信息. 谢谢!