Hi. I'm fairly new to PCFs but have worked through some tutorials and successfully created controls both with and without React. I don't find the framework particularly complicated, but do have a technical hurdle, the solution of which is certainly trivial, but which I have not been able to solve so far.
My problem is: whenever I work with promises, I get the following error from the TS compiler (more precisely: pcf-scripts build):
[10:56:39] [build] Initializing...
[10:56:39] [build] Validating manifest...
[10:56:39] [build] Validating control...
[10:56:39] [build] Generating manifest types...
[10:56:39] [build] Generating design types...
[10:56:39] [build] Running ESLint...
[pcf-scripts] [Error] encountered unexpected error:
Error
For example, the following test call in the init method:
public init(
context: ComponentFramework.Context<IInputs>,
notifyOutputChanged: () => void,
state: ComponentFramework.Dictionary
): void {
const eventName = context.parameters.EventName.raw;
if (eventName) {
const paOneGridCustomizer: PAOneGridCustomizer = { cellRendererOverrides, cellEditorOverrides };
context.webAPI.retrieveRecord("account", "some uuid here").then(() => {
// This is just a placeholder for the test function
console.log("Record retrieved successfully");
});
}
}
As soon as I comment out the call to retrieveRecord, the build process goes through:
public init(
context: ComponentFramework.Context<IInputs>,
notifyOutputChanged: () => void,
state: ComponentFramework.Dictionary
): void {
const eventName = context.parameters.EventName.raw;
if (eventName) {
const paOneGridCustomizer: PAOneGridCustomizer = { cellRendererOverrides, cellEditorOverrides };
// context.webAPI.retrieveRecord("account", "some uuid here").then(() => {
// // This is just a placeholder for the test function
// console.log("Record retrieved successfully");
// });
}
}
I do not have problems with promises in other scripts, mainly OnLoad and OnChange event handlers in D365 forms.
Any ideas what I'm doing wrong here?
Thanks in advance!
Michael