I am trying to create a component that makes a post request to a custom action in my environment. This action has an input called "leadid" and an output called "data", and when called triggers a custom plugin. However, I am having trouble trying to figure out how to call this action from my component.
I understand that you can make calls using "this._context.webAPI.retrieveMultipleRecords(entity, query)" but I am not trying to achieve this.
I have tried the following directly in the console (in the browser) and it works perfectly, but I get an error "Xrm is not defined" when using the same code in my TypeScript file:
fetch(Xrm.Page.context.getClientUrl() + "/api/data/v9.2/dev_GetData", { "method":"POST", "headers":{ "Accept": "application/json", "Content-Type": "application/json; charset=utf-8", "OData-MaxVersion": "4.0", "OData-Version": "4.0" }, "body": JSON.stringify({ "leadid": "7ba18ae0-4d0e-ea11-a813-000d3a1bbd52" }) }).then((response) => response.json()) .then((data) => { console.log(data); })
I find this odd as when I hover over the other parts (page, context, getClientUrl), it gives me the details of what It does.
What might I be doing wrong, or how may I get the client url without using Xrm.page...?
I am building the component using React Framework via --framework React


Report
All responses (
Answers (