PCF Academy Videos
CLI Commands
Initialize PCF Project
1 2 3 |
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
1 2 3 |
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
1 |
pac solution add-reference --path PathToProjectHere |
Build the Project
1 |
msbuild /t:build /restore |
Run Project locally
1 |
npm start |
Code Scenarios
Code to get current entity Id, current entity type name, and the primary attribute value – “display value”:
1 2 3 |
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:
1 2 3 4 5 |
if ((<any>context.mode).contextInfo.entityId == null) { //Code for create } else { //Code for update } |
Code to detect that record was created:
1 2 3 4 5 |
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:
1 |
let baseUrl = (<any>context).page.getClientUrl(); |
Get “Records Per Page” setting for current user:
1 |
let recordsPerPage = (<any>context).userSettings.pagingLimit; |
Get BingMaps API Key:
1 |
const bingMapsApiKey = (<any>context).orgSettings.bingMapsApiKey; |