Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Call Action (process) from plugin / debug

Posted on by

I am attempting to call a new action from an existing plugin that will then trigger another plugin asynchronously.

My action accepts a number of parameters -
 
SiteSettings - Entity - Input
quoteJson - String - Input
opportunity - Entity - Input
quoteId - String - Input
priceList - Entity - Input

Existing plugin

public class examplePlugin : IPlugin {
    public void Execute(IServiceProvider serviceProvider) {
        // Get tracing service for debugging purposes
        ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
        // Get the context of the message
        IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
        IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
        IOrganizationService dynamicsService = serviceFactory.CreateOrganizationService(context.UserId);
                
        // API name of action is new_bactchProductMapping
        OrganizationRequest req = new OrganizationRequest("new_bactchProductMapping");
        // uses custom entity
        req["SiteSettings"] = siteSettings;
        // uses string
        req["quoteJSON"] = "example string";
        // uses dynamics standard Opportunity entiry
        req["opportunity"] = opportunity;
        // uses string
        req["quoteId"] = "quoteid example";
        // uses dynamics standard priceLlist entiry
        req["priceLlist"] = price_list;
        
        tracingService.Trace("ExamplePlugin - attempt to exicute request");
        
        try
        {
            OrganizationResponse response = dynamicsService.Execute(req);
        }
        catch (FaultException e)
        {
            tracingService.Trace("ExamplePlugin - error = "   e.Message   " - "   e.Reason   " - "   e.StackTrace);
        }
    }
}

when calling the action i am hitting the below error - 

ExamplePlugin - error = new_bactchProductMapping#2011/Organization.svc - new_bactchProductMapping#2011/Organization.svc - at Microsoft.CDSRuntime.SandboxWorker.SandboxCallbackService.<>c__DisplayClass14_0.<ExecuteCallBack>b__0() in C:\source\src\CDS.RunTime.Sandbox.Fabric\Microsoft.CDSRuntime.SandboxWorker\SandboxCallbackService.cs:line 109
at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult(ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)
at Microsoft.CDSRuntime.SandboxWorker.SandboxCallbackService.ExecuteCallBack(Func`2 callback, Func`2 HandleClientException) in C:\source\src\CDS.RunTime.Sandbox.Fabric\Microsoft.CDSRuntime.SandboxWorker\SandboxCallbackService.cs:line 88
at Microsoft.CDSRuntime.SandboxWorker.SandboxOrganizationService.Execute(String operation, ByteString serializedRequest, Object traceSettings) in C:\source\src\CDS.RunTime.Sandbox.Fabric\Microsoft.CDSRuntime.SandboxWorker\SandboxOrganizationService.cs:line 47
at Microsoft.CDSRuntime.SandboxWorker.SandboxOrganizationServiceWrapper.ExecuteInternal(OrganizationRequest request) in C:\source\src\CDS.RunTime.Sandbox.Fabric\Microsoft.CDSRuntime.SandboxWorker\SandboxOrganizationServiceWrapper.cs:line 226
at new_Dynamics365_Plugins.ExamplePlugin.Execute(IServiceProvider serviceProvider)



  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Call Action (process) from plugin / debug

    Hello,

    Your code doesn't show how you get SiteSettings, opportunity and pricelist. Please provide that.

    Can you please also provide a screenshot of your action that includes input/output parameters?

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Call Action (process) from plugin / debug

    Hi,

    Can you try executing custom action from console application to see if it works ?

    I hope you have activated your custom action from UI.

  • Suggested answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 8,525 Super User 2024 Season 1 on at
    RE: Call Action (process) from plugin / debug

    Can you also provide more details about the trigger point or when it will be run ?

  • haines10 Profile Picture
    haines10 5 on at
    RE: Call Action (process) from plugin / debug

    Hello Amit,

    I am not calling the Action from JS im calling it from a plugin using the IOrganizationService, i have tried to exicute using a single paramater and am sadly hitting the same issue.

  • Suggested answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 8,525 Super User 2024 Season 1 on at
    RE: Call Action (process) from plugin / debug

    Hello RyanCRM ,

    Can also share JS code which is used to call this Action ?

    Also refer below article and try to pass only one entity once and check if it is accepting or not.

    community.dynamics.com/.../814671

    Thank You,

    Amit Katariya

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans