您的位置:首页 > 产品设计 > UI/UE

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

2010-06-30 17:44 411 查看




屏幕区域名称如下所示:
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 onload="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;// 这里的手机号码就是最终需要的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: