在我的Microsoft CRM中,我需要创建一个复制铅的克隆按钮,这样我的用户就可以修改其中的少量数据然后保存它。我成功地将按钮添加到功能区并按照以下代码设置克隆我的潜在客户:
Webresource:
<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中的原始信息。 谢谢!