web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Required field is missing when calling Custom Action from Javascript

(0) ShareShare
ReportReport
Posted on by 422

I'm trying to call a custom action through Javascript. Here's the code

var host = window.opener.Xrm.Page.context.getClientUrl().toString() + "/api/data/v8.2/";
            var url = host + "new_customAction";
            var data = {
                Record: {
                    "@odata.type": "Microsoft.Dynamics.CRM.new_profile",

                    "@new_profile.id": recordId,
                },                
                Date: date
                ,
                Comment: comment                
            };
            console.log(window.JSON.stringify(data));
            var request = new XMLHttpRequest();

            request.open("POST", url);
            request.setRequestHeader("Accept", "application/json");
            request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
            request.setRequestHeader("OData-MaxVersion", "4.0");
            request.setRequestHeader("OData-Version", "4.0");
            request.send(window.JSON.stringify(data));



Here's the parameters passed printed by console.log : 
{"Record":{"@odata.type":"Microsoft.Dynamics.CRM.new_profile","@new_profile.id":"67F01BEE-98B2-E711-9403-06A5B6453DB2"},"Date":"2018-01-18T00:00:00Z","Comment":"test"}

When I execute this code, I get "message: Required field 'Record' is missing".
Anyone know what I'm doing wrong? Record is of type EntityReference in my custom action.

*This post is locked for comments

I have the same question (0)
  • anonsgate Profile Picture
    422 on at

    Oh well already fixed it...

    By changing the code to

     Record: {
                        new_profile.id: recordId
                    },       


  • Verified answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    This below line

    "@new_profile.id": recordId,

    should has either new_profileid or "new_profileid"

    Double quote (") is ok. No need of identifier (@) or dot (.)

     

    "new_profileid": recordId,

    or

    new_profileid: recordId,

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans