如何在实体的操作工具栏中自定义按钮,并获取列表某项的GUID

屏幕区域名称

屏幕区域名称如下所示:
1.    标准工具栏
2.    导航窗格
3.    应用程序标题栏
4.    操作工具栏
5.    视图筛选器
6.    列表

 

本文主要针对“4. 操作工具栏”中自定义一个按钮,然后点击按钮后,获取到“6. 列表”中具体的某一项的GUID,通过GUID可以对该项进行其他操作。因为想要对列表中具体的某一项操作,目前笔者只知道用GUID去检索可以做到。

1. 通过导出ISV.Config文件,在“联系人(contact)”实体中添加一个Button。作用是调用自定义弹出对话框Temp.aspx页面,如下:

<Entity name="contact">
  <!-- The Contact Tool Bar -->
  <Grid>
    <MenuBar>
      <Buttons>
        <Button Icon="/_imgs/ico_16_112.gif" Url="
http://192.168.5.233/ISV/MyApp/Temp.aspx" PassParams="1" WinParams="" WinMode="2">
          <Titles>
            <Title LCID="1033" Text="New Talk" />
          </Titles>
          <ToolTips>
            <ToolTip LCID="1033" Text="Create new talk."/>
          </ToolTips>
        </Button>
        <ToolBarSpacer/>
      </Buttons>
    </MenuBar>
  </Grid>
</Entity>

2. 接着就是在Temp.aspx页面中捕获用户当前在列表中选中项的GUID值,SDK给出的例子如下:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Temp</title>
    <script type="text/jscript">
        function listselecteditems()
        {
            var sGUIDValues = "";
            var selectedValues;
            var placeholder = document.getElementById("test");
            if (window.dialogArguments && window.dialogArguments.length > 0)
            {
               selectedValues = new Array(window.dialogArguments.length -1);
            }
            else
            {
               placeholder.innerText = "window.dialogArguments is not available.";
               return
            }
            selectedValues = window.dialogArguments;
            if (selectedValues != null)
            {
               for (i=0; i < selectedValues.length; i++)
               {
                  sGUIDValues += selectedValues[i] +"/n";
               }
               alert(sGUIDValues);
               self.close();
              
window.open("http://192.168.5.233:83/Default.aspx?Guid=" + sGUIDValues, "BizPbxWebDemo", "resizable=yes,menubar=yes,toolbar=yes,location=yes,directories=yes,scrollbars=yes");  // 把GUID作为参数传递到自定义页面

            }
            else
            {
               placeholder.innerText = "No records were selected.";
            }
         }
   </script>
</head>
<body οnlοad="listselecteditems()">
    <form id="form1" runat="server">
    <div  id="test">   
    </div>
    </form>
</body>
</html>

3. 接着就是通过GUID检索自己需要的信息了,加入需要联系人的手机号码,可以这样实现:

string sGuid = Request.QueryString["Guid"].ToString();
Response.Write("<script type='text/javascript'>alert('GUID:" + sGuid + "');</script>");

CrmService service = CrmServiceUtility.GetCrmService("http://192.168.5.233", "crm");
ColumnSet cols = new ColumnSet();
cols.Attributes = new string[] { "mobilephone" };
TargetRetrieveContact target = new TargetRetrieveContact();
target.EntityId = new Guid(sGuid);
RetrieveRequest retrieve = new RetrieveRequest();
retrieve.Target = target;
retrieve.ColumnSet = cols;
RetrieveResponse retrieved = (RetrieveResponse)service.Execute(retrieve);
contact con = (contact)retrieved.BusinessEntity;
string sMobile = con.mobilephone;// 这里的手机号码就是最终需要的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值