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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
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

I have the same question (0)
  • Verified answer
    jlattimer Profile Picture
    24,564 on at

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

  • jimfield Profile Picture
    70 on at

    Thank you Jason.  That fixed it.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
RichardM Profile Picture

RichardM 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans