0

自 4 周以来,我一直在使用 MS CRM 2011。我必须将现有报价复制到新报价。哪种方法是最好的方法?使用 Javascript 或 C# aspx 主页?

有人能给我一个例子吗?

先谢谢了!

托马斯

4

1 回答 1

0

有很多方法可以做到这一点。这里有两个。

网址初始化

http://www.renauddumont.be/en/2011/crm-2011-passing-field-values-to-a-form-using-url-parameters

http://msdn.microsoft.com/en-us/library/gg334436.aspx

http://msdn.microsoft.com/en-us/library/gg334375.aspx

我之前已经为联系人实现了这一点。我的要求最适合 URL 初始化方法。我也可以看到这种技术在引用方面的优势。对于这种方法,我也会推荐Gareth Tucker 的博客文章,其中描述了如何做到这一点。

我使用了 Gareth 帖子的几个元素,但我将我的最终脚本分解为更紧凑的内容。本质上,您使用 javascript 来提取特定字段的值,并将它们作为查询字符串参数排列到特殊形成的 CRM 表单 URL 中。此 url 解压缩查询字符串参数,并以新形式将您传递的值分配给相应的字段。 当您打开一个项目并且想要克隆它并让新表单保持打开状态以供用户编辑时,这非常有用。

我最终从联系表单功能区调用了这个脚本,该脚本作为 Web 资源添加。Gareth 也很好地解释了如何做到这一点。

// Register this namespace to avoid collision with other scripts that may 
// run within this form 
Type.registerNamespace("BF.Contact");

    // Create a function that will be called by a ribbon button.
BF.Contact.Clone = function() {


    var extRaqs = "";

    // ownerid
    extRaqs += "&ownerid=" + Xrm.Page.getAttribute("ownerid").getValue()[0].id;
    extRaqs += "&owneridname=" + Xrm.Page.getAttribute("ownerid").getValue()[0].name;
    extRaqs += "&owneridtype=systemuser"; 

    extRaqs += BF.Contact.Clone.GetValue("address1_line1"); 
    extRaqs += BF.Contact.Clone.GetValue("address1_line2"); 
    extRaqs += BF.Contact.Clone.GetValue("address1_city");  
    extRaqs += BF.Contact.Clone.GetValue("address1_postalcode");    
    extRaqs += BF.Contact.Clone.GetValue("mobilephone");
    extRaqs += BF.Contact.Clone.GetValue("telephone1"); 
    extRaqs += BF.Contact.Clone.GetValue("telephone2");
    extRaqs += BF.Contact.Clone.GetValue("fax");    
    extRaqs += BF.Contact.Clone.GetValue("emailaddress1");
    extRaqs += BF.Contact.Clone.GetValue("address1_county");    

    extRaqs += "&donotsendmm=1"


    var newURL = Xrm.Page.context.getServerUrl() + "/main.aspx?etn=contact&pagetype=entityrecord&extraqs=";

    newURL += encodeURIComponent(extRaqs);

    window.open(newURL , "_blank", "width=900px,height=600px,resizable=1");
}

BF.Contact.Clone.GetValue = function(attributename) {
    var _att = Xrm.Page.getAttribute(attributename);
    var _val = "";


    if (_att == null || _att.getValue() == null ) {
        return "";
    }

    if (_att.getFormat() == "date") {
        _val = _att.getValue().format("MM/dd/yyyy");
    } else {
        _val = _att.getValue();
    }

    return "&" + attributename + "=" +  _val;
}

一些缺点:

  1. 只有在您打开要克隆的项目的表单时才真正有效。
  2. 一次只能工作一项。
  3. URL 有限制,对于非常大的实体/字段,并非所有内容都可以克隆。

工作流/对话框

如果您希望能够克隆多个项目,一种非常快速的方法是创建一个针对您要克隆的实体的工作流或对话框。在工作流中,创建目标类型的新项目。新创建的项目的属性可以设置为您的任何要求。将它们默认为静态值,使用克隆项目中的值或工作流允许的任何其他值填充它们。一个主要缺点是无法将表单呈现给用户。

于 2013-01-21T18:44:15.500 回答