Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Dynamics 365 customer portal

Posted on by Microsoft Employee

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dynamics 365 customer portal

    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.

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Dynamics 365 customer portal

    Hi,

    Could you please share what all you have done and what is not working as expected?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans