PCF FAQ

PCF Academy Videos

CLI Commands

Initialize PCF Project

pac pcf init --namespace YourNamespace --name ComponentName --template field|dataset
//v0.3.4+
pac pcf init -ns YourNamespace -n ComponentName -t field|dataset

Initialize Packaging Project

pac solution init --publisher-name PublisherName --publisher-prefix PublisherPrefix
//v0.3.4+
pac solution init -pn PublisherName -pp PublisherPrefix

Add a reference to PCF Project into Packaging Project

pac solution add-reference --path PathToProjectHere

Build the Project

msbuild /t:build /restore

Run Project locally

npm start

Code Scenarios

Code to get current entity Id, current entity type name, and the primary attribute value – “display value”:

let entityId = (<any>context.mode).contextInfo.entityId;
let entityTypeName = (<any>context.mode).contextInfo.entityTypeName;
let entityDisplayName = (<any>context.mode).contextInfo.entityRecordName;

Code to check if record exists:

if ((<any>context.mode).contextInfo.entityId == null) {
	//Code for create
} else {
	//Code for update
}

Code to detect that record was created:

public updateView(context: ComponentFramework.Context<IInputs>): void {
	if (context.updatedProperties.includes("entityId")) {
		//Record was created - do whatever you need with it
	}
}

Get base URL of instance:

let baseUrl = (<any>context).page.getClientUrl();

Get “Records Per Page” setting for current user:

let recordsPerPage = (<any>context).userSettings.pagingLimit;

Get BingMaps API Key:

const bingMapsApiKey = (<any>context).orgSettings.bingMapsApiKey;