Skip to content

Tutorial 4

PhuocLe edited this page Mar 7, 2018 · 12 revisions

Task

  • Account Name always uppercase and don't allow user edit it.

Coding

  1. Add PL.DynamicsCrm.DevKit > 17. C# WebResource Project to solution.
    • A popup form opened.
    • Select saved connection or create new connection.
    • Click OK
    • PL.DynamicsCrm.DevKit created webresource project name: Wooow.Kool.WebResource
  2. Add PL.DynamicsCrm.DevKit > 05. JavaScript require.js to lib folder of Wooow.Kool.WebResource project.
    • PL.DynamicsCrm.DevKit created require.js file in lib folder.
    • Open require.js file, edit ?????????????????????????????????????_/ to wo_/
  3. Add PL.DynamicsCrm.DevKit > 06. JavaScript WebApiClient.js to lib folder of Wooow.Kool.WebResource project.
    • PL.DynamicsCrm.DevKit created WebApiClient.js file in lib folder.
  4. Add PL.DynamicsCrm.DevKit > 03. JavaScript FormBase.js to lib folder of Wooow.Kool.WebResource project.
    • PL.DynamicsCrm.DevKit created FormBase.js and FormBase.debug.js files in lib folder.
    • FormBase.js should be use in the production server.
    • FormBase.debug.js should be use in dev/test server
  5. Add PL.DynamicsCrm.DevKit > 25. JavaScript WebApiBase.js to lib folder of Wooow.Kool.WebResource project.
    • PL.DynamicsCrm.DevKit created WebApiBase.js file in lib folder.
  6. Add PL.DynamicsCrm.DevKit > 01. JavaScript crm.intellisense.js to entities folder of Wooow.Kool.WebResource project.
    • PL.DynamicsCrm.DevKit created crm.intellisense.js file in entities folder.
  7. Add PL.DynamicsCrm.DevKit > 02. JavaScript webapi.intellisense.js to entities folder of Wooow.Kool.WebResource project.
    • PL.DynamicsCrm.DevKit created webapi.intellisense.js file in entities folder.
  8. Add PL.DynamicsCrm.DevKit > 07. JavaScript WebApi to entities folder of Wooow.Kool.WebResource project.
    • A popup form opened.
    • Select saved connection or create new connection.
      • PL.DynamicsCrm.DevKit load all entities and bind to dropdown Class.
    • Select Account
    • Click OK
    • PL.DynamicsCrm.DevKit created 5 JavaScript files
      • Account.js write your JavaScript code here. Deploy this file to Dynamics Crm.
      • Account.form.js DON'T changes this file, it will be lost when you re-generate. Deploy this file to Dynamics Crm.
      • Account.form.intellisense.js DON'T changes this file, it will be lost when you re-generate. DON'T deploy this file to Dynamics Crm.
      • Account.webapi.js DON'T changes this file, it will be lost when you re-generate. Deploy this file to Dynamics Crm.
      • Account.webapi.intellisense.js DON'T changes this file, it will be lost when you re-generate. DON'T deploy this file to Dynamics Crm.
  9. If you are using Visual Studio 2017 please turn off Enable the new JavaScript language service in the Tools -> Options -> Text Editor -> JavaScript/TypeScript -> Language Service and restart Visual Studio

Turn Off

  1. Go to Account.js line 5 and typing these code bellow
var account = new Kool.Form.Account(executionContext);
if (account.FormType == OptionSet.FormType.Create) {
    account.Body.Name.Disabled = false;
}
else if (account.FormType == OptionSet.FormType.Update ||
    account.FormType == OptionSet.FormType.BulkEdit) {
    account.Body.Name.Disabled = true;
}

DON'T copy/paste code. Typing to get your intellisense experience.

Intellisense

  1. Open file PL.DynamicsCrm.DevKit.Cli.json by Notepad and edit these information in section: webresources.profile = "DEBUG"
    • webresources.solution= "Kool"
    • webresources.prefix= "wo_"
    • webresources.dependencies.dependencies == "wo_/lib/require.js"
  2. Open command-line, go to Wooow.Kool.WebResource folder, then run deploy.bat and waiting PL.DynamicsCrm.DevKit.Cli deploy to Dynamics Crm.

Deploy

  1. Verify all web-resource files deployed to solution Kool
  2. If you are using Dynamics 365 (v.9). Verify wo_/entities/Account.js dependencies wo_/lib/require.js
  3. Open Main Account Form design. Click Form Properties
    • If you are using Dynamics 365 (v.9):
      • Add library: wo_/entities/Account.js to section: Form Libraries and Add function onLoad to section Event Handlers. Make sure you checked Pass execution context as first parameter
    • If you are not using Dynamics 365 (v.9):
      • Add library: wo_/lib/require.js to section: Form Libraries
      • Add library: wo_/entities/Account.js to section: Form Libraries and Add function onLoad to section Event Handlers. Make sure you checked Pass execution context as first parameter
  4. Save then Publish form
  5. Go to Crm, press Ctrl+F5 to force reload data from server to browser.
  6. Go to Account entity, create new Account record and verify field Name no locked. Then open an existing Account record, verify field Name locked
  7. Check-in all files to your source control. 20 .You finished this tutorial.

Your Solution Explorer after you finished this tutorial

Finished Tutorial 4

Clone this wiki locally