Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Answered

InputParameters java to plugin

Posted on by 35
Hey,

Could someone help me, I'm trying to pass a parameter from javascript to a plugin, but I'm not having success.

Here are codes:

var req = {};
                req.getMetadata = function () {
                    return {
                        boundParameter: null,
                        parameterTypes: {"CNPJ": CNPJ_data_texto},
                        operationType: 0,
                        operationName: "new_TestedeProcesso"
                    };
                };



                var CNPJ = (string)context.InputParameters["CNPJ"];
                ((IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext))).InputParameters["CNPJ"] = CNPJ;
  • Verified answer
    PabloCRP Profile Picture
    PabloCRP 1,086 on at
    RE: InputParameters java to plugin

    Hi, seems like you are not passing any value when calling your action... try this.

    var req = {};
    req.CNPJ = CNPJ_data_texto;
    req.getMetadata = function () {
        return {
            boundParameter: null,
            parameterTypes: {   
            "CNPJ": {
                        typeName: "Edm.String",//I suppose it's string
                        structuralProperty: 1
                        }
            },
            operationType: 0,
            operationName: "new_TestedeProcesso"
        };
    };

    now for store the value just use this line in C#

    var CNPJ = (string)context.InputParameters["CNPJ";

    in the backend you are right

    regards.

  • Suggested answer
    Torrado Profile Picture
    Torrado 1,270 on at
    RE: InputParameters java to plugin

    Hello Felipe,

    That's exactly why you should use Action or Custom API.

    The Custom APIs where created by Microsoft for that purpose, please read the official documentation. It's a component that makes use of a Plugin class to run the logic, so your C# code can be reused there.

    Please check this example about how to create Custom API: https://markcarrington.dev/2020/10/22/cds-custom-apis/ 

    Hope this helps you.

    Please mark the answer as verified if helpful. That will help others in future.

  • Felipe Kavai Profile Picture
    Felipe Kavai 35 on at
    RE: InputParameters java to plugin

    Hey,

    Thanks for the answer.

    I'm building an integration, I made the whole structure using C #, that's why I use the plugin.

    As I am creating a custom screen within the dynamics, I would like the javascript to call the plugin based on the data that users put on that screen, but the variable arrives blank and I cannot perform the query correctly.

  • Suggested answer
    Torrado Profile Picture
    Torrado 1,270 on at
    RE: InputParameters java to plugin

    Hello,

    Why trying to pass the parameters from JavaScript to Plugin? I would not recommend that approach.

    If the request is coming from Client-Side or as External Web Request, please evaluate the option of calling an Action or Custom API.

    Hope this helps you.

    Please mark the answer as verified if helpful. That will help others in future.

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