Blog, Development

PCF: PowerAppsCLI v1.7.2, Lookup attributes and how to fix an issue in ManifestTypes generated file

If you read my blog I believe you may know that I love to develop different functionality to extend Dynamics CRM, Dynamics 365 for CE, CDS, DataFlex, CDS, Dataverse. The latest and funniest playground for me is PowerAppsComponent Framework and PCF Controls. Lookup attributes were not supported for a long time so I found few tweaks in order to enable this type of attribute and create controls for it. Last week Microsoft released V1.7.2 of PowerApps CLI that included support of Lookup attributes and Diana Birkelbach wrote a wonderful review of what is available. I decided to try it as well, created the project, changed the bound attribute type to “Lookup.Simple” and built the project…

A new updated version of the PowerApps CLI 1.7.4 fixed this bug so if you experience this issue you can just install and use the latest version.

After I built the project I decided to check /generated/ManifestTypes.d.ts file to see what typing we got and I saw the following:

So something wrong was with the code that was generated. After few minutes spent in the VSCode I found the code that caused this issue. Here is what could be done in order to fix the build operation:

  • Navigate to “node_modules\pcf-scripts\manifestTypesGenerator.js and open it
  • Look for the following code:
...
else if (this.outputs[propName] === 'ComponentFramework.PropertyTypes.LookupProperty') {
	typeRef = ts.factory.createTypeReferenceNode(
	/*typeName*/ 'ComponentFramework.PropertyTypes.LookupValue', 
	/*typeArguments*/ undefined);
}
...
  • Change ‘ComponentFramework.PropertyTypes.LookupValue’ to ‘ComponentFramework.LookupValue[]’.
  • Save and close the file
  • Build the project again and if you did everything the right way VSCode won’t bark anymore on the generated code and it will look like the following:

2 Comments

    1. Thanks, Chris! I will take a look at that because I’m not familiar with it ATM.
      Andrew

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.