Is there any way to create that query?
I need data from Adress and Contact Adress, normally i can just combine them by Combine OR
but not in this case.
I guess that i must write new plugin with PreExecute()
method, get my query, parse data and then manualy get equal address OR there are other way?
I am unaware of any way to do the above.
Rather than write a plugin however I would do a report.
Simplest way I can think of is to do your fetchXML without filters like so.
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="account">
<attribute name="name" />
<attribute name="primarycontactid" />
<attribute name="telephone1" />
<attribute name="accountid" />
<attribute name="address1_city" />
<order attribute="name" descending="false" />
<link-entity name="contact" from="parentcustomerid" to="accountid" alias="ac">
<attribute name="address1_city" />
</link-entity>
</entity>
</fetch>
Then toggle visibilty of rows in your report using
=Fields!address1_city.Value="Sydney" Or Fields!ac_address1_city.Value="Sydney"
Obviously you could replace Sydney with a Parameter
I solved the problem.
Execute()
method and some
method for data parsing. GUID
.PS I'll add sources in day or two after refactoring and approval from customer.
Edit:
First of all - y need create new GUID
and add string field to view with that guid to view(It is better to hide it from the user).
Create plugin with RetrieveMultiple
action and Post
validation(in Pre
action you may lose your changes)
In plugin: main method
RetrieveMultiple
which will get context and service from wich you will take query, then you need get fetchXml and check if there are your GUID
.
string fetchXml = string.Empty;
var query = context.InputParameters["Query"] as QueryExpression;
var fetchQuery = context.InputParameters["Query"] as FetchExpression;
if (query == null)
{
if (fetchQuery == null)
{
return;
}
fetchXml = fetchQuery.Query;
}
// Convert query to a fetch expression for processing and apply filter
else
{
fetchXml =
((QueryExpressionToFetchXmlResponse)
service.Execute(new QueryExpressionToFetchXmlRequest {Query = query})).FetchXml;
}
if (fetchXml.Contains(OpportunityFilterGuid))
{
ApplyFilter(context, service, query);
}
}
In your ApllyFilter
method you need:
Get query from user(he can add some new fileds).
Delete your field with GUID
.
Execute query.
Delete fileds, that can conflict with your OR
statement.
Add link-entity
to query.
Execute query.
Add received entities from second query to first.
Using LINQ select entities wich are not repeated.
collectionOne.Entities.GroupBy(oppId => oppId.Id).Select(opp => opp.First())
Send that data to client.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With