• Microsoft Dynamics CRM 4.0 中列表上的按钮如果用Javascript ,怎么给js方法传选中的值。


    请教一个问题,在CRM4.0 中列表上的按钮如果用Javascript 怎么给js方法传选中的值啊
    如图,点击打电话,想获得选中记录的ID

    答复一:可以参考CRM4.0 SDK中的例子:

    Walkthrough: Capturing the GUID Values of Records Selected in a Grid

     

    Walkthrough: Capturing the GUID Values of Records Selected in a Grid

    This walkthrough describes how to capture the GUID values of records displayed in an entity view.

    During this walkthrough you will learn how to:

    • Confirm that you will be able to export and use custom menus and toolbars.
    • Configure ISV.Config to display a modal dialog window
    • Create an HTML page which captures the window.dialogArguments and displays the GUID ID properties of the selected records.
    • Test the HTML page to confirm that the window is capturing the GUID values of the selected records.

    Note This example will only work when the HTML page is on the same domain as the CRM Server due to security features in Internet Explorer to address cross-site scripting concerns.

    Confirm You Can Export and Use Custom Menus and Toolbars.

    Before you can continue in this walkthrough you must verify the following:

    • That Custom Menus and toolbars have been enabled for your Microsoft Dynamics CRM installation.
    • That your user account is associated with a security role that has the ISV Extensions privilege and that you have the necessary privileges to export and import customizations.

    Enable Custom menus and toolbars

    Custom Menus and toolbars is a system setting. Custom Menus and toolbars are turned off by default.

    1. In the Microsoft Dynamics CRM Web application, click Settings.
    2. Click Administration and then System Settings.
    3. Click the Customization tab and select the clients that you want to display custom buttons and menu items. For the purposes of this walkthrough, only the Web application must be enabled.
    4. Click OK.

    Confirm that your user account is able to use custom menus and toolbars.

    1. In the Microsoft Dynamics CRM Web application, click Settings.
    2. Click Administration and then Users.
    3. Locate your user account and click Roles.
    4. Open the security role(s) associated with your user account.
    5. On the Customization tab verify that you have Organization level access to the following privileges located under Miscellaneous Privileges.

    ISV Extensions

    Export Customizations

    Import Customizations

    Note If you do not have the privileges necessary to view or update security roles work with your system administrator to associate your user account a security role that contains the necessary privileges.

    Configure ISV.Config

    This example will configure a button on the Account entity grid. There are three steps to this process:

    • Export ISV.Config
    • Configure the button for the Account entity grid
    • Import ISV.Config.
    1. In the Microsoft Dynamics CRM Web application, click Settings.
    2. Click Customization and then Export Customizations.
    3. Scroll down the list of Exportable items and select ISV.Config.
    4. Click Export Selected Customizations.
    5. Save the customizations.zip file.
    6. Extract the customizations.xml file from the customizations.zip file.
    7. Open the customizations.xml file using Visual Studio or any text editor, such as notepad.
    8. The default ISV.Config includes a number of sample extension control configurations. You can modify one of the existing extension controls or configure a new one.
    9. Locate the following node in the default ISV.Config:

    ImportExportXml/IsvConfig/configuration/Entities/Entity name="account"/Grid/MenuBar/Buttons

    1. Configure a button element as a child of the Buttons element using this XML:

    11.<Button

    12. Icon="/_imgs/ico_18_debug.gif"

    13. Url="/ISV/test.htm"

    14. WinMode="2"

    15.>

    16. <Titles>

    17. <Title LCID="1033" Text="Get GUIDS" />

    18. </Titles>

    19. <ToolTips>

    20. <ToolTip LCID="1033" Text="Get GUIDS for selected records" />

    21. </ToolTips>

    </Button>

    The key elements are the Url and WinMode attributes to the Button element.

    Important The URL must point to a page on the same domain as the Microsoft Dynamics CRM Server.

    This example will place the test.htm page in the ISV directory located in the Microsoft Dynamics CRM web site installation path. The WinMode attribute must be set to either 1 or 2 so that a dialog window is opened rather than a standard window. Window.dialogarguments is only available for the two dialog windows (modal and modeless).

    1. Save customization.xml file with the changes you have made.
    2. In the Microsoft Dynamics CRM Web application, click Settings.
    3. Click Customization and then Import Customizations.
    4. Browse to the customization.xml file you have saved and click Upload.
    5. After the file has loaded, click Import Selected Customizations.

    Create the HTML Page to Capture the GUIDs

    This page will use a JScript function in the onload event of the page to detect whether the window.dialogarguments is available and simply display the GUID values in the page. In a solution that takes actions using the GUID values, these values would be passed to another application.

    1. Create a file named test.htm in the ISV folder of your Microsoft Dynamics CRM Web application.
    2. Use the following code in the page:

    3. <html>

    4. <head>

    5. <title>GUIDs for records seleced in Grid</title>

    6. <script type="text/jscript">

    7. function listselecteditems()

    8. {

    9. var placeholder = document.getElementById("test");

    10. var sGUIDValues = "";

    11. var selectedValues;

    12. //Make sure window.dialogArguments is available.

    13. if (window.dialogArguments)

    14. {

    15. selectedValues = new Array(window.dialogArguments.length -1);

    16. }

    17. else

    18. {

    19. placeholder.innerText = "window.dialogArguments is not available.";

    20. return

    21. }

    22. selectedValues = window.dialogArguments;

    23. if (selectedValues != null)

    24. {

    25. for (i=0; i < selectedValues.length; i++)

    26. {

    27. sGUIDValues += selectedValues[i] +"\n";

    28. }

    29. placeholder.innerText = sGUIDValues;

    30. }

    31. else

    32. {

    33. placeholder.innerText = "No records were selected.";

    34. }

    35. }

    36. </script>

    37. </head>

    38. <body onload="listselecteditems()">

    39. <div id="test"></div>

    40. </body>

    </html>

    The listselecteditems function is called when the page loads. If window.dialogArguments doesn't exist, the innerText property of a placeholder div element in the pages is updated with a message. If window.dialogArguments does exist, a new array is created based on the length of window.dialogArguments. Then a for loop iterates through the items in the array and the GUID values are appended to a string. The innerText value of the placeholder div element is updated with the string value.

    Save the test.htm page to the ISV folder.

    Test the Button

    1. In the Microsoft Dynamics CRM Web application, click Workplace.
    2. Click Accounts.

    You should see the button you configured in the toolbar.

     

    1. Select a number of accounts in the view and then click the Get Guids button. The test.htm page should open and display the GUIDs for the selected accounts.  

      

    答复二:关于视图的一些常用函数和方法:

    刷新:

    crmGrid.Refresh()

    打印:

    crmGrid.Print();

    获取已选择的项的GUID集合:

    getSelected("crmGrid");

    获取未选择的项的GUID集合:

    getNotSelected("crmGrid")

    可以跟踪一些表单上的按钮事件,或看一下CRM里载入的JS,会有不少发现。

  • 相关阅读:
    Java为何大行其道
    Centos安装成功mysql-5.5.37
    ADO.NET与Oracle(一):获取多行记录集
    【spring data jpa】【mybatis】通过反射实现 更新/保存 实体的任意字段的操作
    【spring data jpa】spring data jpa的in查询
    【mybatis】mybatis中的<if test=“”>test中多条件
    【mybatis】in查询+判断list查询条件是否进行in查询
    【spring boot】【log4jdbc】使用log4jdbc打印mybatis的sql和Jpa的sql语句运行情况
    【mybatis】mybatis中 的# 和 $的区别
    【mybatis】时间范围 处理时间格式问题 + 查询当天 本月 本年 + 按当天 当月 范围 查询 分组
  • 原文地址:https://www.cnblogs.com/allenhua/p/2737994.html
Copyright © 2020-2023  润新知