zoukankan      html  css  js  c++  java
  • Microsoft Dynamics CRM 2011 JavaScript 总结

    Microsoft Dynamics CRM 2011 JavaScript Development Cheat Sheet              

    一、Xrm.Page.context Methods

    1.getAuthenticationHeader  获取认证表头

    已弃用。 Returns the encoded SOAP header necessary to use Microsoft Dynamics CRM 4.0 web service calls using Microsoft JScript. 已弃用。需要使用Microsoft JScript中使用的Microsoft Dynamics CRM 4.0中的Web服务调用返回编码的SOAP头。

    2.getCurrentTheme  获取当前主题。

    Returns the current user’s Outlook theme  返回当前用户outlook的主题。

    3.getOrgLcid  获取组织语言id。

    Returns the LCID value for the base language of the organization 返回的基本语言的组织的LCID的值。

    4.getOrgUniqueName  获取组织唯一的名称。

    Returns the unique organizations name 返回唯一的组织名称

    5.getQueryStringParameters   获取查询字符串参数。

    Returns an array of key-value pairs representing the query strings  返回一个数组的表示查询字符串的键值对。

    6.getServerUrl  获取服务器url地址。

    Returns the base server URL 返回基本服务器url地址。

    7.getUserId  获取当前的用户ID。

    Returns the current user’s SystemUser id  返货当前用户的系统用户的id。

    8.getUserLcid   获取用户语言id。 注意LCID 解释:http://baike.baidu.com/view/1203977.htm

    Returns the LCID value representing the user’s preferred language  返回表示用户首选语言的LCID值。

    9.getUserRoles 获取用户角色。

    Returns an array of GUID values of the security roles the user is associated with 返回与用户的安全角色关联的GUID值的一个数组。

    10.isOutlookClient 是outlook客户端。

    Returns a Boolean value indicating if the user is using Outlook  说明返回一个布尔值,如果用户使用的是Outlook。

    11.isOutlookOnline 是outlook在线

    Returns a Boolean value indicating if the user is connected to the server while using MSCRM for Outlook with Offline Access.  

    返回一个布尔值,表示如果用户连接到服务器,而使用MSCRM为Outlook中使用离线访问。

    12.prependOrgName 前置组织名称。

    Prepends the organization name to the specified pathclient 组织名称预先考虑到指定的路径客户端。

     二、Xrm.Page.data.entity attribute Methods

       Method(方法)                                       Applicable(可适用)           Description(描述)


      1.addOnChange(添加OnChange)             All(所有)                    Sets a function to be called when the value is changed 设置值被改变时被调用的函数
      2.fireOnChange(解除OnChange)              All(所有)                    Causes the OnChange even t to occur on the attribute  引起OnChange事件发生的属性                                                          

      3.getAttributeType(获取属性的类型)         All(所有)                    Returns the type of attribute (string)  返回属性(字符串)的类型

      contentIFrame.Xrm.Page.data.entity.attributes.get("name").getAttributeType()  相当于 contentIFrame.Xrm.Page.getAttribute("name").getAttributeType();

    相当于contentIFrame.Xrm.Page.getControl("name").getAttribute("name").getAttributeType(); 

      注意:在IE浏览器上调试的时候,必需加contentIFrame.

     4.getFormat(获取格式)                           All(所有)                    Returns formatting options for the attribute (string)  返回的格式选项集的属性(字符串)

      5.getInitialValue(获取初始值)   boolean(布尔), optionset(选项集) Returns the initial value for Boolean or optionset attributes返回布尔或选项集属性的初始值

      6.getIsDirty(获取是否变化)     All(所有) Returns a Boolean value indicating if there are unsaved changes to the attribute value 如果有未保存的更改的属性值,则说明返回一个布尔值。

      7.getMax(获取最大值)     money(货币), decimal(十进制), integer(整型), double(双进度型)       Returns the maximum allowed value for an attribute (number)  返回属性(数字)的最大允许值。

     8.getMaxLength(获取最大长度)   string(字符串), memo(备忘录)  Returns the maximum length of an attribute (number) 返回属性(数字)的最大允许值的长度。

     9.getMin(获取最大值)     money(货币), decimal(十进制), integer(整型), double(双进度型)       Returns the minimumallowed value for an attribute (number)  返回属性(数字)的最小允许值。

    10.getName(获取名称)                     All(所有)                              Returns the logical name of the attribute 返回属性的逻辑名称

    11.getOption(获取选项)                  optionset(选项集)                  Returns an option object by matching its name  返回他的名称相匹配的一个选项对象

    12. getOptions(获取选项集)            optionset(选项集)                   Returns an array of options for an optionset attribute 返回一个选项集属性的选项集的一个数组

    13.getParent(获取父对象)                     All(所有)                             Returns the parent object to the attribute 返回属性的父对象

    14.getPrecision(获取精度)   money(货币), decimal(十进制), integer(整型), double(双进度型) Returns the number of digits allowed after the decimal point 返回允许小数点后的数字的位数。

    15.getRequiredLevel(获取所需级别)         All(所有)             Returns a string indicating whether the attribute is required or recommended 返回一个字符串,指示属性是必需或推荐

    16.getSelectedOption(获取选择项集)       optionset(选项集) Returns the option selected in an optionset attribute.返回一个选项集属性的所选择的选项。

    17.getSubmitMode(获取提交模式)         All(所有)            Returns a string indicating if the attribute will be submitted when the record is saved 当记录保存的时候,如果这个属性将会被提交,返回一个字符串提示。

    18.getText(获取文本)   optionset(选项集)  Returns the selected option for an optionset attribute  返回所选的选项为一个选项集的属性               

    19.getUserPrivilege(获取用户权限)  All(所有) Returns an array of Boolean values indicating if the user can create/read/update an attribute's values 返回一个布尔值数组,表示如果用户可以创建/读取/更新属性的值。

    20.getValue(获取值)  All(所有)Retrieves the data value for an attribute 检索一个属性的数据的值

    21.removeOnChange(移除OnChange) All(所有) Removes a function from the OnChange event handler 移除来自onChange事件处理的一个函数。

    22.setRequiredLevel(设置必需级别)       All(所有)Sets whether the attribute is required or recommended 设置是否这个属性是必需还是推荐。

    23.setSubmitMode(设置提交模式)           All(所有) Sets whether the attribute’s data will be submitted  设置是否这个属性的数据将会被提交。
    24.setValue(设置值)                               All(所有) Sets the data value for an attribute. 为一个属性设置数据值。

    三、Form Event Handler Execution Context Reference 

    1.getContext(获取上下文)    Returns the Xrm.Page.context object 返回Xrm.Page.context的对象。
    2.getDepth(获取深度)          Returns a value indicating the order in which this handler is executed 返回一个值,指示此处理程序执行的顺序。
    3.getEventArgs(获取事件参数) Returns an object with methods to manage the Save event 返回一个对象,使用方法来管理保存事件。
    4.getEventSource(获取事件源)               Returns a reference to the object that the event occurred on 返回一个对象的引用,事件是发生在。
    5.getSharedVariable(获取共享变量)                              Retrieves a variable set using setSharedVariable 获取变量的使用,设置共享变量 。
    6.setSharedVariable Sets the value of a variable to be used by a hander after the current completes

    三、Shortcut methods

    Shortcut(快捷)                                            Equivalent (等价于)
    Xrm.Page.getAttribute                         Xrm.Page.data.entity.attributes.get
    Xrm.Page.getControl                            Xrm.Page.ui.controls.get
    GetGlobalContext (Web Resources)       Xrm.Page.context (within forms)

    比如:

    获取字段名为name的值

    contentIFrame.Xrm.Page.getAttribute("name").getValue() 相当于 

    contentIFrame.Xrm.Page.data.entity.attributes.get("name").getValue()

    contentIFrame.Xrm.Page.getControl("name").getAttribute("name").getValue();相当于

    contentIFrame.Xrm.Page.ui.controls.get("name").getAttribute("name").getValue(); 

                                                                                     

    四、Xrm.Page.data.entity Methods

    获取字段的值 

    contentIFrame.Xrm.Page.data.entity.attributes.get("name").getValue();

    1.addOnSave            Sets a function to be called when the record is saved
    2.getDataXml           Returns the xml string to be sent to the server when the record is saved
    3.getEntityName         Returns the logical name of the entity for the record
    4.getId                    Returns GUID id value for the record
    5.getIsDirty              Returns a Boolean value indicating if any fields in the form have been modified
    6.removeOnSave        Removes a function from the OnSave event hander
    7.save                      Saves the record

    五、

    前台获取lookup字段值: contentIFrame.window.Xrm.Page.getAttribute("new_costfrom").getValue()[0].id
    获取当前登录用户:Xrm.Page.context.getUserId()
    获得当前页面类型:Xrm.Page.ui.getFormType()
    获得当前实体名称:contentIFrame.Xrm.Page.data.entity.getEntityName()
    刷新Ribbon工具条:Xrm.Page.ui.refreshRibbon();
    给lookup字段赋值:var tmp=[{ id: PaymentInfo.new_distributor.Id,
    name: PaymentInfo.new_distributor.Name,
    typename: PaymentInfo.new_distributor.LogicalName}];
    Xrm.Page.getControl("new_budget").getAttribute().setValue(tmp);
    js查询方法
    function Form_CheckSoluInfo() {
    if(Xrm.Page.data.entity.getEntityName() == 'new_po_exp_detail')
    {
    return true;
    }
    var rest = new fwREST();
    var soluInfo = rest.get("New_promotion_peSet(guid'" + Xrm.Page.getAttribute("new_pe_exp_detail").getValue()[0].id +
    "')?$select=New_approvestate,New_f_type,new_current_approver");
    var value = getEnabledValueForCheckSoluInfo(soluInfo.New_approvestate.Value, soluInfo.New_f_type.Value, "{" + soluInfo.new_current_approver.Id + "}");
    return value;
    }

  • 相关阅读:
    R
    R 包的安装,使用,更新
    R 安装 简单实用
    R 介绍
    mongo:用户管理
    MySQL 书籍
    mongo: 索引
    blog
    游标处理
    如何在ASP.NET的web.config配置文件中添加MIME类型
  • 原文地址:https://www.cnblogs.com/allenhua/p/2832473.html
Copyright © 2011-2022 走看看