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 :
Power Platform Community / Forums / Power Apps / Calling a custom actio...
Power Apps
Unanswered

Calling a custom action from power apps component

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

I have the same question (0)
  • skoofy5 Profile Picture
    482 on at

    The Xrm namespace/object isn't available in a PCF and you're trying to call it in your first line. I don't think you actually need the base url - you should be able to omit that and the fetch call might work.

     

    This thread will help you - https://powerusers.microsoft.com/t5/Power-Apps-Pro-Dev-ISV/How-to-call-custom-actions-using-PCF/td-p/360030

     

    Also take a look at the Dataverse REST builder - https://www.xrmtoolbox.com/plugins/GuidoPreite.DRB/

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard