在我的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。 关于如何修改我的JavaScript代码,保持,因为它克隆的URL的方式的任何想法是得到完全相同的信息被复制的唯一途径,因为他们在原来的,但保存为一个新的领导而不是原来在微软CRM 。 谢谢!