是否有可能在结果页面上检索高级查找查询/fetchxml?在我触发结果按钮之前,我可以按 Fetchxml 按钮,但在结果页面上不能。是否有可能通过javascript或C#检索此查询/xml,并且它必须在结果页面上。
我不是 100% 确定我们是否在谈论同一件事,但可以使用 Fetchxml 陈述查询。
看看这个页面。在这里,他们使用FetchExpression(字符串(与常规组织服务进行查询。您只需要组织服务和 fetchxml 来查询它。小例子(来自上面的链接!
// Retrieve all accounts owned by the user with read access rights to the accounts
and
// where the last name of the user is not Cannon.
string fetch2 = @"
<fetch mapping='logical'>
<entity name='account'>
<attribute name='accountid'/>
<attribute name='name'/>
<link-entity name='systemuser' to='owninguser'>
<filter type='and'>
<condition attribute='lastname' operator='ne' value='Cannon' />
</filter>
</link-entity>
</entity>
</fetch> ";
EntityCollection result = _serviceProxy.RetrieveMultiple(new
FetchExpression(fetch2));
foreach (var c in result.Entities)
{
System.Console.WriteLine(c.Attributes["name"]);
}
如您所见,这很可能是控制台作业。如何使用实体本身取决于您。
据我所知,没有钩子可以自定义高级查找页面,因此无法添加JavaScript来执行您想要的操作。
但是,您可以编写一个在RetrieveMultiple
消息上触发的插件。
在插件中,您可以从 RetrieveMultipleRequest 获取QueryExpression
var q = (QueryExpression)context.InputParameters["Query"];
然后将其转换为 FetchXML。
var conversionRequest = new QueryExpressionToFetchXmlRequest
{
Query = q
};
var conversionResponse = (QueryExpressionToFetchXmlResponse)_serviceProxy.Execute(conversionRequest);
var fetchXml = conversionResponse.FetchXml;
请注意,我还没有测试上面的代码。由于我没有做过这种确切的技术,因此您可以将查询直接强制转换为 FetchXML 并跳过转换调用。
因此,您可能想尝试一下:
var q = (FetchExpression)context.InputParameters["Query"];
检索多个插件有其警告。但是,它有多糟糕?
在相关说明中,如果用户将高级查找另存为个人视图,则可以从用户查询实体检索其 FetchXML。