cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

PCF-React Control Using webAPI

Hi Folks,

Im a frontend developer and new to PCF and Powerapps component framework. I'm trying to retrieve data from an entity using retriveRecord but was not working even after deployed. 

This is the code which i have used in the pcf control.I'm aware about the webAPI not supported in the test harness but In the test harness at least I'm getting the error response. After deploying the control we are not getting any success or error console logs.

 

We are also getting a authentication error from skype-sdk file.

 

(the id and entity logical name is dummy here)

 

const retriveData=async () => {
console.log("log from retriveData");
let id="1";
let filter=`$select=firstname,lastname`;
let options="";
props.pcfContext.webAPI
      .retrieveRecord("leads", id, filter)
      .then(successCallback, errorCallback);
  };
const successCallback= (response: any) => {
console.log(response, "WebApi succss Response");
alert("sucess");
  };
const errorCallback= (errorResponse: any) => {
console.log(errorResponse, "WebApi error Response");
alert("error");
  };

 

 

 

Any help work appreciate!

Krishna

11 REPLIES 11

Hi @Anonymous , 

 

Did this or something else solve your issue? 

 

Kind regards,

Diana

 

Anonymous
Not applicable

@DianaBirkelbach, yes I used the context instance from init method. Previously I used to pass the context instance directly from updateview method to the react component. Now its working fine.

 

private webAPI: ComponentFramework.webapi;
public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container:HTMLDivElement)
	{
		this.webAPI=context.webAPI;
	}

Then passed this.webAPI as props of react component in the updateview.

I appreciate your kind help and time to revisit this thread 😀 .

 

Thnaks & Regards

Krishna

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Users online (56,405)