Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Suggested answer

how to return a value from plugin to action

Posted on by 645

I have a button that calls an action that triggers a plugin, I want to pass a value from my plugin and show it to the user (by popup). I defined an output  parameter in my action.
How do I return the value (output parameter) I retrieved in my plugin back to my function js ?

  • Suggested answer
    Inogic Profile Picture
    Inogic 24,031 on at
    RE: how to return a value from plugin to action

    Hi Sahara,

    You can set the Output parameters in the plugin for the Action using the below code,

    context.OutputParameters["OutputParameterName"] = OutputParameterValue

    If the result of executed action is fine (i.e. success.ok == true) then you can read your response (or output parameter value) via success.json() as it will parse your response.

    Please refer below code for the same,

     //Exceute Action

                        Xrm.WebApi.online.execute(customActionReq).then(

                            //Perform on success

                            (success) => {

                                success.json().then(function(Response){

                                  // In the Response.OutputParameterName you will get your out put value

                                });

                            },

                            //Perform on error

                            (error) => {

                                console.log("Error");

                            }

                        );

     

    Hope this helps!

  • Suggested answer
    Pawar Pravin  Profile Picture
    Pawar Pravin 5,227 on at
    RE: how to return a value from plugin to action

    Hi Sahara,

    You can use "context.OutputParameters[“ReturnObject”] = ReturnValue" to return value form custom action (plugin code)

    Please refer below code for more details:

    pravinpawarweb.wordpress.com/.../

    To show alert on page :

    pravinpawarweb.wordpress.com/.../

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,556 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,625 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans