Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Error Calling Custom Action

(0) ShareShare
ReportReport
Posted on by 70

I am trying to call a custom action from JavaScript in Dynamics 365 Online v9, but I am getting an error "Resource not found for the segment new_sendcrmcontactdatatoaba" where new_sendcrmcontactdatatoaba is the name of the action.  The action has four string input parameters and one string output parameter. 

Here is my JavaScript to call the action:

...

var parameters = {
        "Environment": environment,
        "StrURL": strURL,
        "RecordId": contactID,
        "RecordType": "contact"
    }

    var results = callAction('new_SendCRMContactDatatoABA', 'contacts', parameters);

...

function callAction(actionName, entityName, actionParams) {

    var result = null;
    var oDataEndPoint = encodeURI(Xrm.Page.context.getClientUrl() + "/api/data/v9.0/Microsoft.Dynamics.CRM." + actionName);

    var request = new XMLHttpRequest();
    request.open("POST", oDataEndPoint, false);
    request.setRequestHeader("OData-MaxVersion", "4.0");
    request.setRequestHeader("OData-Version", "4.0");
    request.setRequestHeader("Accept", "application/json");
    request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    

    request.onreadystatechange = function () {
        if (request.readyState === 4) {
            request.onreadystatechange = null;
            if (request.status === 200) {
                result = JSON.parse(this.response);
            } else {
                var error = JSON.parse(this.response).error;
                alert("Error calling action: " + actionName + error.message);
            }
        }
    };

    if (actionParams != null)
        request.send(JSON.stringify(actionParams));
    else
        request.send();

    return result;
}

The action is defined as a global action with the following parameters:

Environment, String, Required, Input

StrURL, String, Required, Input

RecordId, String, Required, Input

RecordType, String, Required, Input

Message, String, Required, Output

Does anyone have any idea how to get this action to work?

*This post is locked for comments

  • jimfield Profile Picture
    jimfield 70 on at
    RE: Error Calling Custom Action

    Thank you Jason.  That fixed it.

  • Verified answer
    jlattimer Profile Picture
    jlattimer 24,558 on at
    RE: Error Calling Custom Action

    Try removing "Microsoft.Dynamics.CRM." from the url. That usually appear only when the action is bound to an entity. 

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

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,836 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans