-
Notifications
You must be signed in to change notification settings - Fork 15
Tutorial 3
PhuocLe edited this page Aug 26, 2018
·
8 revisions
- When creating lead, topic field always uppercase. But when editing, it cannot edit
- When creating/editing lead, if user enter Business Phone they should be enter Mobile Phone too and vice versa. Otherwise, 2 fields can be blank
- Finish Tutorial 1
- Finish Tutorial 2
- Add
New Project
05. C# WebResource Project
to your solution- A popup form
Add new WebResource Project
opened - Click button
><
to create/select a Dynamics 365 connection - After connected, click
OK
-
PL.DynamicsCrm.DevKit
created project name:Paz.LuckeyMonkey.WebResource
- A popup form
- Rebuild solution to restore
NuGet
packages - Open file
PL.DynamicsCrm.DevKit.Cli.json
by Notepad and edit these information in section:webresources.profile = "DEBUG"
webresources.solution = "LuckeyMonkey"
webresources.prefix = "paz_"
- Open file
PL.DynamicsCrm.DevKit.json
by Notepad and editSolutionPrefix = "paz_"
- Add
New Item
07. JavaScript Form
toentities
folder ofPaz.LuckeyMonkey.WebResource
project- A popup form
Add new Js Form Class
opened - Click button
><
to create/select a Dynamics 365 connection - After connected
PL.DynamicsCrm.DevKit
loaded all entities and bind to dropdownEntity
- Select
Lead
in theEntity
then clickLoad Forms
button - Select
Lead
in the list checkbox (This list load all formsLead
) - Click
OK
- A popup form
-
PL.DynamicsCrm.DevKit
created3
JavaScript files-
Lead.js
write your JavaScript code here,deploy
this file to Dynamics 365 -
Lead.form.js
DON'T
changes this file, it will be lost when you re-generate,deploy
this file to Dynamics 365 -
Lead.intellisense.js
DON'T
changes this file, it will be lost when you re-generate.DON'T
deploy
this file to Dynamics 365
-
- If you are using
Visual Studio 2017
pleaseturn off
Enable the new JavaScript language service
in theTools
->Options
->Text Editor
->JavaScript/TypeScript
->Language Service
and restartVisual Studio
- Open
Lead.js
and begin coding. PleaseDON'T
copy/paste code. Trytyping
to getintellisense
thatPL.DynamicsCrm.DevKit
support
///<reference path='Lead.intellisense.js' />
var formLead = (function () {
function onLoad(executionContext) {
var form = new LuckeyMonkey.FormLead(executionContext);
if (form.FormType !== OptionSet.FormType.Create) {
form.Body.Subject.Disabled = true;
}
else {
form.Body.Subject.AddOnChange(SubjectAddOnChange);
}
form.Body.Telephone1.AddOnChange(PhoneAddOnChange);
form.Body.MobilePhone.AddOnChange(PhoneAddOnChange);
}
function onSave(executionContext) {
}
function SubjectAddOnChange(executionContext) {
var form = new LuckeyMonkey.FormLead(executionContext);
if (form.Body.Subject.Value !== null) {
form.Body.Subject.Value = form.Body.Subject.Value.toUpperCase();
}
}
function PhoneAddOnChange(executionContext) {
var form = new LuckeyMonkey.FormLead(executionContext);
if (form.Body.Telephone1.Value !== null ||
form.Body.MobilePhone.Value !== null) {
form.Body.Telephone1.RequiredLevel = OptionSet.FieldRequiredLevel.Required;
form.Body.MobilePhone.RequiredLevel = OptionSet.FieldRequiredLevel.Required;
}
else {
form.Body.Telephone1.RequiredLevel = OptionSet.FieldRequiredLevel.None;
form.Body.MobilePhone.RequiredLevel = OptionSet.FieldRequiredLevel.None;
}
}
return {
OnLoad: onLoad,
OnSave: onSave
};
})();
- Open
Lead Form
design. ClickForm Properties
- Add library:
paz_/entities/Lead.form.js
to section:Form Libraries
- Add library:
paz_/entities/Lead.js
to section:Form Libraries
- Add function
formLead.OnLoad
of librarypaz_/entities/Lead.js
to sectionEvent Handlers
. Make sure you checkedPass execution context as first parameter
- Add library:
-
Save
thenPublish
form - Go to Dynamics 365, create/edit
Lead
and check your task - Check-in all files to your source control
- You finished this tutorial
This tutorial, you know howto
- Add
05. C# WebResource Project
- Add
07. JavaScript Form
- Config
PL.DynamicsCrm.DevKit.Cli.json
forWebResource
- Config
PL.DynamicsCrm.DevKit.json
fordeploy
javascript
fromVisual Studio