Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

WebAPI custom action calling issue

Posted on by 385

Hi All,

I facing issue when i try to invoke custom action from js for the custom activity entity.

Error: parameter  in the request payload is not a valid parameter for the operation

This is working for any OOB or custom entity but not for custom activity entity.

 

Code:

 function CallCustomAction() {
        var id = Xrm.Page.data.entity.getId().substring(1, 37);
        var query = "new_VIJJI(" + id.replace("}", "").replace("{", "") + ")/Microsoft.Dynamics.CRM.new_testingaction";
        query = Xrm.Page.context.getClientUrl() + "/api/data/v8.0/" + query;
        var data = {
            "subject": "Test description vijji"
        };
        var req = new XMLHttpRequest();
        req.open("POST", query, true);
        req.setRequestHeader("Accept", "application/json");
        req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        req.setRequestHeader("OData-MaxVersion", "4.0");
        req.setRequestHeader("OData-Version", "4.0");
        req.onreadystatechange = function () {
            if (this.readyState == 4 /* complete */) {
                req.onreadystatechange = null;
                if (this.status == 200) {
                    var data = JSON.parse(this.response);
                    if (data['voutput'] != null) {
                        alert(data['voutput']);
                    }
                } else {
                    var error = JSON.parse(this.response).error;
                    alert(error.message);
                }
            }
        };        
        req.send(window.JSON.stringify(data));
    }


In Custom action i have an output and assigning a value

Is it a limitation or i am i missing some thing in the code?

screenshot_5F00_customaction.png

*This post is locked for comments

  • Rizwan Aarif Profile Picture
    Rizwan Aarif 480 on at
    RE: WebAPI custom action calling issue

    I too am facing this issue on some CRM instances. For now on D365 v 8.2 (online).


    Any work arounds? 

  • VIJENDER REDDY Profile Picture
    VIJENDER REDDY 385 on at
    RE: WebAPI custom action calling issue

    Sorry for the late response.

    The plugin is registered with the custom action message and it is of post operation.

    if i go with the old fashioned Soap based call i am getting input value.

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: WebAPI custom action calling issue

    If it is "Pre-Validation" or "Pre-Operation" plugin you will not see any value because body of operation (with assigning)  is executed after Pre plugins. Try to use Post plugin.

  • VIJENDER REDDY Profile Picture
    VIJENDER REDDY 385 on at
    RE: WebAPI custom action calling issue

    async services restarted, the error now resolved.

    Now the value for the input is blank when i check from plugin (From the js code the value for the subject is given)

    For testing i made the input as mandatory and i can see response for the call is getting blank "" value.

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: WebAPI custom action calling issue

    Hello,

    Can you please provide a screenshot of your action?

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