Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Error while passing parameters to Xrm.Page.context.getClientUrl()

Posted on by 40

Hello everyone.

I have this requirement where I have to pass entity name, GUI and action as a parameter to close the case. But I am not able to execute the code. Could you tell me where I am making a mistake and how should I rectify it.

It is a web API query. 

var entityId = "(FBD5D7F4-27CD-E811-9123-00155DDC4BD8)";
var entityName = "incident";
var requestName = "/Microsoft.Dynamics.CRM.rucs_closecase";
var req = new XMLHttpRequest();

req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/" + entityName + entityId  + requestName +, true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204) {
//Success - No Return Data - Do Something
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();

*This post is locked for comments

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Error while passing parameters to Xrm.Page.context.getClientUrl()

    Hi,

    It appears that you are trying to execute custom action. If yes then check the below links for the correct syntax.

    www.c-sharpcorner.com/.../calling-custom-actions-using-web-api

    If you still need assistance, share the screenshot of your accustom action as the code depends on your paramters as well.

    Hope this helps.

  • Saqib Profile Picture
    Saqib 40 on at
    RE: Error while passing parameters to Xrm.Page.context.getClientUrl()

    oops! how can I miss that. Thanks for the correction mate!

  • Verified answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Error while passing parameters to Xrm.Page.context.getClientUrl()

    Hi Muhammad,

    You should write entity name "incidents" instead of "incident".

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