I am trying to trigger CRM Plugin in customer portal on event Fetch XML query on Retrive Multiple event, i have done all code but it does not return expected output.
Can someone please help me out in this ?
*This post is locked for comments
I am trying to trigger CRM Plugin in customer portal on event Fetch XML query on Retrive Multiple event, i have done all code but it does not return expected output.
Can someone please help me out in this ?
*This post is locked for comments
I want to run CRM pliugin on Retrivel Multiple Message.
I have created one Web Template in customer portal and into that I have added fetch xml code. Below see the fetch xml code.
{% fetchxml my_query %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="new_prefix_portalwebservice">
<attribute name="new_prefix_portalwebserviceid" />
<attribute name="new_name" />
<attribute name="new_prefix_data" />
<attribute name="createdon" />
<order attribute="new_name" descending="false" />
</entity>
</fetch>
{% endfetchxml %}
{% for result in my_query.results.entities %}
{{ result.new_prefix_data }}
{% endfor %}
And I am calling this page on button click of another page and expecting result in json.
$("#servercode").click(function(){
alert("first");
jQuery.ajax({
url: "/RetrieveMultiple/",
type: "GET",
contentType: 'application/json; charset=utf-8',
success: function(resultData) {
//here is your json.
// process it
alert(JSON.stringify(resultData));
},
error : function(jqXHR, textStatus, errorThrown) {
alert(errorThrown);
},
timeout: 120000,
});
});
RetrieveMultiple is my partial URL and I have register one plugin on Entity (new_prefix_portalwebservice) which is used in fetch xml in web template.
Below is the plugin code.
public void Execute(IServiceProvider serviceProvider)
{
////Extract the tracing service for use in debugging sandboxed plug-ins.
//ITracingService tracingService =
// (ITracingService)serviceProvider.GetService(typeof(ITracingService));
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));
try
{
var entityName = context.PrimaryEntityName;
var query = (QueryBase)context.InputParameters["Query"];
if (context.OutputParameters.Contains("BusinessEntityCollection"))
{
EntityCollection outputEntities = context.OutputParameters["BusinessEntityCollection"] as EntityCollection;
outputEntities.Entities.Clear();
EntityCollection col = (EntityCollection)context.OutputParameters["BusinessEntityCollection"];
Entity entity = new Entity("new_prefix_portalwebservice");
entity.Attributes.Add("new_prefix_data", "abcde");
Guid recordid = Guid.NewGuid();
entity.Id = recordid;
entity["new_prefix_portalwebserviceid"] = recordid;
col.Entities.Add(entity);
}
}
catch (Exception ex)
{
//tracingService.Trace("FollowupPlugin: {0}", ex.ToString());
throw ex;
}
}
I am trying to modify the fetch xml entity collection result and trying to displaying that modified output in JSON Result.
Some time it works but sometime it doesn’t .
Hope you understand the issue.
Thank You.
Hi,
Could you please share what all you have done and what is not working as expected?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156