Closed dotfede closed 4 years ago
Really great question and well done for spotting this project early on before it's publicized! 😀
I've used this library in all my PCF and JS Webresources for a couple of years now - here are some of the differences to other libraries. In summary, it's not meant to compete - but rather tries to provide an interface that is closer to IOrganizationService as well as an implementation that can be used in NodeJS Integration tests (without running in the browser).
node-cds-auth
).cdsify-gen eject
Regarding the API style - this is how you would create an account, opportunity, then win the opportunity in TypeScript running in the Form Context:
// Create account
const account1 = {
logicalName: accountMetadata.logicalName,
name: "Account 1",
} as Account;
account1.id = await cdsServiceClient.create(account1);
// Create opportunity
const opportunity1 = {
logicalName: opportunityMetadata.logicalName,
name: "Opportunity 1",
} as Opportunity;
opportunity1.customerid = Entity.toEntityReference(account1);
opportunity1.id = await cdsServiceClient.create(opportunity1);
// WinOpportunity
const winRequest = {
logicalName: WinOpportunityMetadata.operationName,
Status: 3,
OpportunityClose: {
logicalName: opportunitycloseMetadata.logicalName,
description: "Sample Opportunity Close",
subject: "Sample",
opportunityid: Entity.toEntityReference(opportunity1),
},
} as WinOpportunityRequest;
const winResponse = await cdsServiceClient.execute(winRequest);
// Get the Opportunity
const opportunityRetreived = (await cdsServiceClient.retrieve(opportunity1.logicalName, opportunity1.id,
"customerid",
])) as Opportunity;
console.log(opportunityRetreived.customerid?.id);
You can also use activity parties for creating activities:
letter1.regardingobjectid = Entity.toEntityReference(account1);
letter1.to = [
{
logicalName: "activityparty",
partyid: Entity.toEntityReference(account1)
} as ActivityParty
];
letter1.id = await cdsServiceClient.create(letter1);
Keep checking back in for more info on how to set up and use!
Thanks! 👍
What are the primary motivations for this library and what advantages/disadvantages may I find in using it, as compared to XrmDefinitelyTyped?