MicrosoftDynamicsCRM2013ExtendingTrainingMaterialVersion2.
0www.
firebrandtraining.
comExtendingMicrosoftDynamicsCRM2013Page2of14011/09/2014CoursecontentModule0–CourseContentandPlan.
5Objectives5CoursePlan5CourseModules.
6Resources.
7CaseStudy.
7SDK.
7Exam.
7Feedback.
10Module1–ExtensibilityModelandFramework.
11Objectives11Lesson1-1CRMFunctionality.
11Lesson1-2XRMApplicationFramework12Lesson1-3DeploymentOptions.
16Lesson1-4What'sNewinCRM2013.
18Lesson1-5Resources.
22Module2–PlatformOperations.
23Objectives23Lesson2-1WindowsCommunicationsFoundation.
23Lesson2-2MicrosoftDynamicsCRMWebServices.
26Lesson2-3EarlyBoundandLateBoundClasses29Lesson2-4Create,Retrieve,UpdateandDeleteMethods32Lesson2-5ExecuteMethod.
34Lesson2-6Exceptions.
35Lesson2-7Metadata.
36Module3–QueryingData.
38ExtendingMicrosoftDynamicsCRM201311/09/2014Page3of140Objectives38Lesson3-1QueriesinDynamicsCRM.
38Lesson3-2QueryExpression38Lesson3-3QuerybyAttribute.
39Lesson3-4LINQ40Lesson3-5FetchXML41Lesson3-6FilteredViews42Lesson3-7ReportingOptions.
43Module4–Processes46Objectives46Lesson4-1DynamicsCRMProcesses46Lesson4-2DynamicsCRMProcessSteps49Lesson4-3Workflows.
53Lesson4-4Dialogs.
57Lesson4-5BusinessProcessFlows.
61Lesson4-6Actions64Module5–ServerSideCode.
69Objectives69Lesson5-1Plugins.
69Lesson5-2EventFramework.
70Lesson5-3PluginIsolation,TrustsandStatistics.
72Lesson5-4DevelopingPlugins.
73Lesson5-5DeployingPluginsandImpersonation76Lesson5-6DebuggingPlugins.
79Lesson5-7CustomWorkflowActivities.
82Lesson5-8DeclarativeWorkflows.
86Lesson5-9OutlookandPlugins.
87ExtendingMicrosoftDynamicsCRM2013Page4of14011/09/2014Lesson5-10Azure.
89Lesson5-11PluginsvsCustomWorkflowActivities.
93Lesson5-12DeveloperToolkit.
95Module6–ClientSideScript.
96Objectives96Lesson6-1UseofJavaScript.
96Lesson6-2Xrm.
PageModel.
97Lesson6-3WebResources105Lesson6-4FormsandClient-SideEvents111Lesson6-5URLAddressableForms114Lesson6-6BestPractice117Lesson6-7DebuggingJavaScript.
120Module7–ClientSideCode.
123Objectives123Lesson7-1DataaccessusingJavaScript.
123Lesson7-2ModernappSOAPendpoint.
125Lesson7-3ODATA.
126Lesson7-4JSON.
129Lesson7-5JQUERY.
130Module8–UserInterface.
132Objectives132Lesson8-1UserInterface132Lesson8-2SiteMap.
132Lesson8-3CommandBar135ExtendingMicrosoftDynamicsCRM201311/09/2014Page5of140Module0–CourseContentandPlanObjectivesThekeyobjectiveofthiscourseistoenableyoutounderstanddifferentwaysofdevelopingagainstDynamicsCRMwithC#andJavaScript.
WhatthiscoursecoversExtensibilityModelandFrameworkPlatformOperationsQueryingDataProcessesServerSideCodeClientSideScriptsClientSideCodeUserInterfaceWhatthiscoursedoesnotcoverC#ProgrammingSQLReportingServicesreportsServicefunctionalityCoursePlanThiscoursetakes2.
5daystocompleteandhelpspreparefortheMicrosoftDynamicsCRM2013Extendingcertificationexam.
ExtendingMicrosoftDynamicsCRM2013Page6of14011/09/2014CourseModules1.
ExtensibilityModelandFramework2.
PlatformOperations3.
QueryingData4.
Processes5.
ServerSideCode6.
ClientSideScripts7.
ClientSideCode8.
UserInterfaceExtendingMicrosoftDynamicsCRM201311/09/2014Page7of140ResourcesVirtualMachinesThecourseemploysaVirtualMachinesrunningonHyper-V:Firebrand-Extending.
ThisisaWindowsServer2013computerwithDynamicsCRM2013andVisualStudioalreadyinstalledYoustartvirtualmachinesbystartingHyper-VManagerandright-clickingonthevirtualmachineandselectingStart.
CaseStudyThereareseparatePDFsfortheCaseStudies.
Thesecasestudiesbuildonthelabsfromthecustomisationcourse.
Thereisonecasestudyfordemonstrations(EventManagement)andantherforthelabs(NewProductDevelopment:Prototypes,Ideas,Feedback).
SDKTheMicrosoftDynamicsCRMSoftwareDeveloperkitisavailablefrommicrosoft.
com/downloadsandfromtheMSDNCRMDeveloperCentre.
ExamTheExtendingMicrosoftDynamicsCRM2013examisaMicrosoftcertificationexamandistakenonlineinoneofthetestingroomsofftheFirebrandreceptionandrefreshmentsareaIdYouwillneedtwoformsofid;onewithaphotoide.
g.
,apassportordrivinglicenseandtheotherwithyoursignaturee.
g.
,adebit/creditcard.
ExamFormatTheexamhas48multiplechoicequestionsandyouareallowed140minutes.
Thereisthreehoursintotaltoallowforyoutocompletei)atestexamontheplanetsofthesolarsystemtogetyouusedtotheexaminationformatandii)twosurveysattheendoftheexam.
ExamPreparationTherearecurrentlynopracticetestsavailabletopreparefortheexam.
SkillsMeasuredThiscertificationexammeasuresyourabilitytoextendMicrosoftDynamicsCRM2013includingplanningthedeploymentofMicrosoftDynamicsCRM,performingcommonandadvancedplatformoperations,implementingbusinessprocesses,creatingplug-ins,implementingapplicationevents,andimplementingwebresources.
ExtendingMicrosoftDynamicsCRM2013Page8of14011/09/2014PlanningtheDeploymentofMicrosoftDynamicsCRM(15-20percent)DescribetheCRMapplicationframeworkoThistopicmayinclude:describetheDynamicsCRMextensibilityplatform;describePortableBusinessLogicfunctionality;explaintheApplication,Platform,andDatabaselayers;describethedifferencesbetweentheCRMapplicationframeworkon-premisesandonlineIdentifytheconsiderationsfordeployingDynamicsCRM.
oThistopicmayinclude:describethedeploymentmodel;identifysupportforMicrosoftOutlookclients;identifytheextensibilitypoints;identifytypesofreporting;identifythewebresourcesPlanforuserinterfacecustomization.
oThistopicmayinclude:describetheWebApplicationNavigationandNavbars;customizetheSiteMapandcommandbar;describetheentitycommandbartemplates;describehowcustomizationsimpactMicrosoftOutlook;editthecustomactionsandcommanddefinitions;describeNavbarenableanddisplayrules;describehowtouselocalizedlabelswithcommandbars;describeURL-addressableformsandviewsPerformingCommonPlatformOperations(15-20percent)ExplaintheDiscoveryService.
oThistopicmayinclude:describeDiscoveryServiceauthenticationandauthorization;explainthedifferencesbetweentheDiscoveryServiceWebServiceon-premisesandonlineExplaintheOrganizationService.
oThistopicmayinclude:describeOrganizationServiceauthenticationandauthorization;describeentityinformation;explaintheRetrieveAttributeRequestandRetrieveAttributeResponsemethodsDescribehowtousedatatypes,methods,andclasses.
oThistopicmayinclude:explainthedifferentdatatypes;describehowtousetheCreate,Retrieve,Update,Delete,andRetrieveMultiplemethods;describehowtouseearly-andlate-boundclassesDescribeWindowsCommunicationFoundation(WCF)webservices.
oThistopicmayinclude:describeintegrationofDynamicsCRMandWCF;describehowtohandleWCFfaults;useandspecifyOpenDataProtocol(OData)elementswhenqueryingDynamicsCRMdataPerformingAdvancedPlatformOperations(10-15percent)Identifydifferentwaystoquerydata.
oThistopicmayinclude:explainQueryExpression,QueryByAttribute,LINQqueries,andfilteredviews;explainhowtosavequeries;explainFetchXMLandcustomSQLServerReportingServices(SSRS)reportinginrelationtoDynamicsCRM;describetheintegrationofWindowsAzurewithDynamicsCRMIdentifyhowtouserequestsandresponses.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page9of140oThistopicmayinclude:identifyhowtousetheExecute()method;useentity-specificandnon-entityspecificrequests;usesimplegenericrequestmessages;passoptionalparametersinmessagesExplaintheMetadatawebservice.
oThistopicmayinclude:describethemetadatalayer;explaintheReadandWriteactionspossiblewithmetadata;usemetadatafromcustomapplicationsImplementingBusinessProcesses(10-15percent)Describeworkflows.
oThistopicmayinclude:describeworkflowprocessarchitecture;describecustomworkflowactivitiesandcustomXAMLworkflows(declarativeworkflows);describeworkflowrulesandbindingrulestoeventsDescribedialogs.
oThistopicmayinclude:explaininputargumentsindialogs;describedialogrules,events,pages,prompts,responses,actions,andconditionsCreateandmanagecustomworkflows.
oThistopicmayinclude:setupcustomworkflowactivityassemblies;create,configure,anddebugcustomworkflowactivities;createandmodifyworkflowsinWindowsWorkflowFoundation(WF);describebusinessprocessflowsCreatingPlug-ins(15-20percent)Describeplug-ins.
oThistopicmayinclude:explainplug-insandwhentousethem;describecascadingevents;explaintheinformationavailableinplug-ins;describeplug-inisolation,trusts,andstatistics;describeimpersonationinplug-ins;describehowtoregisteranddeployplug-ins;describehowtodebugplug-insDescribetheeventframework.
oThistopicmayinclude:describethekeyfeaturesoftheeventframework;describetheeventexecutionpipeline;describehowtouseEntityclassesinplug-insImplementingApplicationEvents(15-20percent)Describeapplicationevents.
oThistopicmayinclude:describetheuseofJavaScriptlibrariestocustomizeDynamicsCRM;describeformandfieldeventsincludingOnChange,OnLoad,OnSave,TabStateChange,andOnReadyStateComplete;implementIFRAMESinentityformsImplementclient-sidecode.
oThistopicmayinclude:describeusingJavaScriptforclient-sideevents;debugclient-sidecode;requestexternaldata;passparameters;accessDynamicsCRM2013webservicesImplementformtypes.
ExtendingMicrosoftDynamicsCRM2013Page10of14011/09/2014oThistopicmayinclude:describethedifferentformtypes;implementtheXrm.
Pageobject;implementXrm.
Utility;explainhowtotestformtypes;describetheformeventhandlerexecutioncontextDescribeglobalvariablesandfunctions.
oThistopicmayinclude:explainhowtosetdependenciesandpassparameters;definetheallowedquerystringparameters;addandhandleformparameters;explainthegetQueryStringParametersmethodImplementingWebResources(10-15percent)Explainhowtousethedifferenttypesofwebresources.
oThistopicmayinclude:definewebpage(HTML),stylesheet(CSS),script(JavaScript),data(XML),images(PNG,JPG,GIF,ICO),Silverlight(XAP),andstylesheet(XSL)webresources;createwebresources;identifythelimitationsofeachwebresource;implementthepassingofparametersbetweenwebresources;referencewebresources;implementJavaScriptlibrariesforcodereuseacrossmultipleapplicationsExplainhowtouseREST,OData,andJSONinDynamicsCRM.
oThistopicmayinclude:explainRepresentationalStateTransfer(REST);useRESTinAJAXandJavaScript;explainJavaScriptObjectNotation(JSON);explainhowtousetheXMLHttpRequestobject;useODataandJavaScripttocreateandupdateanaccountrecordExplainhowtouseJQueryinDynamicsCRM.
oThistopicmayinclude:explainJQueryandhowtousetheJQueryobject;useJQuerywithawebresource;useJQuerytointeractwiththeCRMformFeedbackYouwillneedtocompletetwosetsoffeedbackattheendofthecourse.
OneisforFirebrandandisavailableonyourPC;http://www.
firebrandtraining.
co.
uk/feedback.
TheotherisforMicrosoftandyourinstructorwillgiveyouthelinktotheKnowledgeAdvisorsMetricsThatMatterwebsitethatMicrosoftusesforfeedback.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page11of140Module1–ExtensibilityModelandFrameworkObjectivesThekeyobjectiveofthismoduleistodescribetheDynamicsCRMapplicationframeworkandthedifferentwaysCRMcanbeextended.
Inthismodulewewillcover:CRMFunctionalityXRMApplicationFrameworkDeploymentOptionsforDynamicsCRMWhat'sNewinDynamicsCRM2013ResourcesavailableLesson1-1CRMFunctionalityMicrosoftDynamicsCRMFunctionalityMicrosoftDynamicsCRMisdesignedtosupportthesales,marketingandservicefunctionsofanorganisation.
Outofthebox,DynamicsCRMprovidessignificantfunctionalityformanyorganisationsandalsoprovidescapabilitytocustomiseandextendthefunctionalitytomeetspecificbusinessrequirements.
Thirdpartiesalsoprovidepre-builtcustomisationsviatheDynamicsCRMMarketplace.
SalesThesalesfunctionalitywithinDynamicsCRMcoversthegenerationofleadsforprospectingandqualifying,managingopportunitiesandkeepingtrackofstagesofdealclosure,managingandtrackingcommunicationsbetweensalespeopleandthecustomers,andmaintainingadatabaseofproductinformationLeadsOpportunitiesCommunicationtrackingProductsandPricingSalesprocessesSalesProcessThesalesprocessstartswiththegenerationofalead;thatthenfollowsaqualificationprocesstoconvertittoanopportunity.
Aquotecanbegeneratedforthecustomer,whichthencanbecomeanExtendingMicrosoftDynamicsCRM2013Page12of14011/09/2014orderand,fromthisorder,invoicescanbegenerated.
ThisentiresalesprocessismodelledwithinDynamicsCRM.
MarketingThemarketingfunctionalitywithinDynamicsCRMallowsyoutodocampaignplanning,campaignbudgetingandcreatingtargetmarketinglistsofcontacts,accountsandleadsthatyouwanttomarketyourservicesto.
Youcangeneratecampaignsinordertoprovideyoutheabilitytosendoutemailblastsormailtoaparticularmarketinglists,andthentrackingandreportingtheefficacyofthosecampaignsthroughreportsandcharts.
MarketlistsCampaignsTrackingresponsesReportingServiceTheservicefunctionalitywithinDynamicsCRMallowsyoutorecordcasesforissuesortickettrackingforcustomers,managingservicesthatyouprovideorcontractsthatyouhavewithacustomer.
Youcanmanagetheservicesandresourcesthatyouhaveathandthroughappointmentschedulingallowingyoutotakeyouravailableresources,schedulethemoutoptimally,andfindwhentheyareavailabletobedeployedtorendertheservicesthatyouprovideyourcustomers.
Aknowledgebaseofexistinginformationandintelligencethatyoucanusetohelpyoumoreeffectivelysolvecasesandissuesthatmayarisewithacustomer.
CaserecordingandresolutionContractManagementServiceandResourceManagementServiceSchedulingKnowledgeBaseLesson1-2XRMApplicationFrameworkMicrosoftDynamicsCRM2013includesadeclarativedevelopmentofrelationalbusinessapplicationsthathaveflexibledatamodelsanddynamicservices.
ISVsbuildingExtendedCRMapplicationsonMicrosoftDynamicsCRM2013usethe.
NETFrameworkandothercommonMicrosoftplatformtechnologiessuchasWebServer(IIS)WindowsWorkflowFoundation(WF)WindowsCommunicationFoundation(WCF)SQLServerExtendingMicrosoftDynamicsCRM201311/09/2014Page13of140XRMApplicationFrameworkTheXRMapplicationframeworkisthecommonfoundationusedbyboththecoreCRMapplicationsbuiltbyMicrosoftandtheExtendedCRMapplicationsbuiltbyISVsandpartners.
Forexample,aninsuranceagencyorfinancefirmcoulduseMicrosoftDynamicsCRM2013inatraditionalsensebutcouldalsobenefitgreatlywithanextendedCRMapplicationtomanagepolicies,documentsandinteroperatewithotherindustrystandardapplications.
TheseapplicationsalltakeadvantageofthefollowinghighlevelfeaturesofthexRMapplicationframework:Modelsthatconsistofmultipledomainsthatautomaticallyincludedata,presentation,workflowandsecuritytonameafew.
Businessapplicationservicesthatincludeextensibleclientexperiences,multi-tenancy,robustwebservicesthatalladapttothecurrentapplication'spublishedmodel.
EnterprisescalabilityandaplatformthatprovidesaprovencommitmenttobackwardcompatibilityandearlyadoptionofkeyMicrosofttechnologies(forexample.
NET).
RunninginthecloudwithCRMOnlineandinteroperabilitywithotherMicrosoftCloudproductssuchasWindowsAzure.
ExtendedCRMapplicationscanbefasttobuildwithpoint-and-clickcustomizationsanddrag-and-dropuserinterface(UI)designs.
Sometimesmorethanpointandclickcustomizationsareneededtoresolveissues.
Inthisinstancedevelopersmustextendthesolutiontoincludecustomcodewhichisthefocusofthiscourse.
DevelopersworkmostlywithtoolssuchasMicrosoftVisualStudiotointeractwithandextendservices.
End-usersinteractwiththeapplicationbytheuseofafamiliarbrowserbasedinterfaceorthroughtheCRMclientforMicrosoftOutlook.
Generally,applicationsbuiltthatuseMicrosoftDynamicsCRM2013workthewaythattheyareexpectedtowork.
ExtendedCRMapplicationsthatusedynamicservicecapabilitiescanadapttochangingbusinessneeds.
Forexample,whenanewattributeisaddedtothemodelitisimmediatelyavailableintheUI,fromthewebservicesandalsoavailableforreportingandworkflows.
Typically,inatraditionalapplicationthiswouldhaverequiredsomeefforttoaccomplish.
Customizationsandfullextendedapplicationsarepackagedasa(Managed)Solution.
ISVscanbuildacommonsolutiontoaproblemwhichcanbecustomizedtofittheindividualneedsoftheirendcustomersinamorecost-effectiveway.
ISVscanthenpublishandselltheirsolutionintheMicrosoftDynamicsMarketplace(http://www.
microsoft.
com/dynamics/marketplace).
DeclarativeDesignModelMicrosoftDynamicsCRM2013containsadeclarativemodel.
Thismeansthatwhentheapplicationisdesignedtomeetspecificbusinessprocesses,thecustomizeranddeveloperdonothavetospendtimecreatingeventswhichperformbasiccreate,read,update,anddelete(CRUD)actions.
Theseactionsincludedesigningasecuritymodelfortheform,designingaformstructure,ordevelopingcodetoperformnavigationalandinteractionevents.
ExtendingMicrosoftDynamicsCRM2013Page14of14011/09/2014AlltheseactionsareabstractedfromtheeventsandthecomplexityofthisisperformedinthebackgroundbytheXRMframework.
Thisprovidesdevelopersandcustomizersmoretimefocusingonthespecificbusinessprocessesandscenarios.
Themodelcontainsthebuildingblocksforanapplication;andbyitselfitisonlyacollectionofrelatedobjects.
However,theinteractionbetweenthoseobjectsisusedtoimplementmoreextensiblelogicsuchasthequote-to-order-to-invoiceprocessingandpricinglogic.
Four-layerarchitectureMicrosoftDynamicsCRMhasaconceptual4-layerarchitecture.
PresentationThePresentationlayerisyourbrowser,orOutlook,ormobileclient.
ApplicationTheApplicationlayerisquitelightanddisplaystheASPXpagesyouseethroughthebrowser.
TheApplicationlayeriswhereanyJavaScript,youhaveaddedtotheform,isexecuted.
TheApplicationlayeralsoenforcesfieldsettingssuchas:Min/MaxvaluesMandatoryfieldsFieldlengthDataTypesvalidationPlatformThePlatformlayerisprobablythemostimportantfromtheperspectiveofthiscourse.
Theplatformperformsanumberofkeyfunctionsincluding:CRMBusinessLogicCustomBusinessLogicSecurityWorkflowsDataImportsDuplicateDetectionThePlatformusestheMetadataextensivelye.
g.
toconvertuserqueriesintoSQLstatements.
ThePlatformisalsowherethewebservicesreside.
DataThedatalayeristheSQLServerdatabaseforyourorganisation.
InDynamicsCRMOnlineandPartnerHosteddeploymentsyouwillnothavedirectaccesstoSQLServer.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page15of140Inanon-premisedeployment,accesstoSQLdatabaseisrestrictedtoFilteredViewsthatisa)readonlyandb)enforcesdatasecuritymodel.
YoushouldneveraccesstheSQLdatabasedirectlytocreateoramenddataortableswithinthedatabase.
Youareallowedtocreateindexesbutnothingelse,nostoredproceduresortriggers.
ExtensibilityPlatformandFeaturesTheextensibilityplatformisthecoreofbothMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnline.
WhenusingMicrosoftDynamicsCRMSDK,developersarebuildingontopofthissystem.
WhendevelopinganapplicationthatusesMicrosoftDynamicsCRM,developersusewebservicestocommunicatewiththeunderlyingXRMframeworklayer.
MicrosoftDynamicsCRMusesametadatadrivenarchitecturetoprovidetheflexibilitytocreatecustomentitiesandadditionalsystementityattributes.
Thisarchitectureisalsousedtomakeupgradesandmakethetransportationofsolutionseasier.
BydoingthisyoucanmakechangesinthedatastructurewithouthavingtochangecodeinMicrosoftDynamicsCRM.
TheXRMframeworkalsocontrolsaccesstodatathroughsecurity,controlsaccesstothedatabase,andraiseseventsforworkflowprocessesandcustombusinesslogicimplementations(plug-ins).
TheplatformlayerprovidesforbothincomingandoutgoingemailprocessingthroughtheMicrosoftExchangeServer.
Figure1–ExtensibilitypointsExtendingMicrosoftDynamicsCRM2013Page16of14011/09/2014TheabovefigureshowsseveralcomponentsinthestructureofaMicrosoftDynamicsCRM2013environment.
Withinthesecomponents,thereareseveralextensibilitypoints:FormandClient-SideEventsCommandBarandSiteMapJScriptLibrariesPlug-insWebserviceprogrammingWebResourcessuchasthefollowing:oWebPage(HTML)oData(XML)oStyleSheet(XSLandCSS)oJScriptoSilverlightMicrosoftSQLServerReportingServicesProcessesLesson1-3DeploymentOptionsDeploymentOptionsTherearevariouswaysinwhichyoucandeployDynamicsCRM2013;on-premise,online,orapartner-hostedmodel.
Thefunctionalityisalmostidenticalbetweenthedeploymentoptions.
ClientsMicrosoftDynamicsCRMisessentiallyaweb-basedapplication.
Therearevariousdifferentsupportedbrowsers;InternetExplorer,Firefox,ChromeandSafari.
YoucanjustopenyourbrowserandtypeintheURLoftheCRMserver.
AnotherwaytoaccessitisthroughOutlook.
TheCRMClientforOutlookusesthestandardOutlookinterface,andenablesyoutoaccessallofyourrecordsandCRMdatathroughOutlook.
Italsoprovidesyouadditionalabilitytotrackandsyncyouremails,appointmentsandtasksbetweenOutlookandCRM.
Newin2013istheNativeMobileClient;thisisavailablefortabletsandvariousphonesthroughappstores.
YouareabletoaccessyourCRMdatathroughanativeapplicationonyourphoneortablet.
SecurityUserAccessAllusersmustbeauthorisedandauthenticatedbeforetheycanaccessDynamicsCRM.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page17of140Figure2-AuthenticationIfauserwithanon-premisedeploymentofDynamicsCRMuserlogsintotheircomputerandaccessCRM,theyareloggedinwiththeirActiveDirectoryusernameandtheuserisautomaticallyloggedintoCRM2013.
ForCRMOnlineandpartner-hosteddeployments,userswillneedtologintoCRMseparatelyusingClaimsBasedAuthentication.
SecurityRolesSecurityrolesallowdifferentaccesstodifferentpartsofCRMbothfunctionalityandrecords.
UsersmustbegivenatleastonesecurityroletoaccessCRM.
OtherSecurityFeaturesRecordscanbesharedwithotherusersandteams.
CRM2013hasnewfunctionality,accessteams,toallowrecordstobesharedwithmultipleusersviaaccesstemplates.
Userscanalsobeprovidedwithdifferentformsbasedontheirsecurityroles.
ItisalsopossibletorestrictaccesstospecificfieldsviaFieldLevelSecurity.
Thesecuritymodelisveryflexibleandrobustandcannotbebypassed.
ExtendingMicrosoftDynamicsCRM2013Page18of14011/09/2014Lesson1-4What'sNewinCRM2013MicrosoftCRM2013newfeaturesinclude:NewUIandNavigationTheCRMuserinterfacehasbeenredesigned.
ThenewmenubarreplacesCRM2013Navigationpaneanddesignedtoeaseusernavigation,freeupscreenspaceandcreateaconsistentlookandfeelacrossdesktopandtouchenabledmobiledevices.
TheCRM2013ribbonhasbeenreplacedbyasimplersinglelineactionbarwitha"moreactions"dropdownlistfreeingupscreenspaceformoredata,chartsandinformationonforms.
Commandsarerelatedtowhatyouareworkingonandchangebasedondataandrecordopened.
QuickCreateformThisverybasicformallowsyoutoquicklyenterarecord.
Forexample,ifyou'reonthephonewithaLeadandwanttoquicklycapturetheirnameandphonenumberinCRMwithouthavingtonavigatetotheleadentity.
Youcancustomisetheseformstoincludethetypeofinformationyouwant.
QuickViewformsThisfeatureallowsyoutobringindatafromrelatedentities.
Forexample,ifyouareworkingonaCaserecordandwanttoviewbasicAccountinformationontheCaseform,youcanuseaQuickViewformtodothat.
BusinessRulesThisprovidesanintuitivewaytowritesimplecodethatwasotherwisereservedforsomeonewithdevelopment/codingexperience.
Youcandothingslikesetfieldvalues,show/hidefields,setrequired/recommendedfieldsandvalidatefielddata.
BusinessProcessFlowsAnewvisualprocessdisplaycanbemadeavailablethatguidestheuserthroughpre-definedprocesses.
Multipleprocessescanbeaddedtoeachrecordtype-thinksalesprocessforinsidesalesvs.
outsidesales.
Asalesorganizationcanmakesureeachrequiredstepineachpipelinephaseiscompletedbeforemovingtothenextpipelinephase.
Realtime/SynchronousWorkflowsProcessesinCRM2013alwaysraninthebackgroundrequiringausertoreloadtheformtoseetheendresultoftheworkflow.
CRM2013nowintroducesprocessesthatrunimmediatelyandupdatetheforminrealtime.
ActionsAnewprocessthatallowsnon-programmerstodefine"functions"thatdeveloperscancalltoperformasetofactionse.
g.
EscalateacaseExtendingMicrosoftDynamicsCRM201311/09/2014Page19of140AutoSaveOnceyou'vecreatedarecord,thisnewfeatureautomaticallysavesinformationonyourformtriggeringevery30secondsaswellaswhenyouleavetheform.
ThisbatchupdatesanychangesmadetotheformwithouthavingtoremembertohittheSavebutton.
Thisisasystemwidesetting,soyoueitheruseAutoSaveonallformsoryoudon't.
FetchXMLFetchXMLhasbeenexpandedsoallowforLeftOuterJoins.
Role-BasedSecurityTeams(ownerTeams)andAccessTeamsWitharecord-basedaccessteam,CRMuserscanbeaddedtoaspecificrecordandgivethemaccess.
Theaccessteamisanewtypeofteamthatdoesn'townrecords,but,hasaccesstorecords.
Unlikewithownerteams,youcancreateoneormoreaccessteamstoworkonthesamerecordsandhaveteammemberswithdifferentlevelsofaccessrightstotherecord.
NativeMobileAppsMoCAotherwiseknownas"MobileClientApplication".
MoCAreferstothe(free)mobileappthatcanbedownloadedtoyourphone,tablet,orevendesktop.
ThisnewmobileapprendersyourexistingCRMformsasmobileforms.
Thesemobileformsarelimitedandarerestrictedto5tabsor75fieldsand10lists,whicheveronecomesfirst.
IFramesarenotsupported.
Globalsearchissupportedinthemobileclientsoyoucannowsearchacrossmultipleentities,whereas,inthefullwebclientthe'QuickFind'onlysearcheswithinaspecificentity.
Figure3-MobileClientExtendingMicrosoftDynamicsCRM2013Page20of14011/09/2014ExtendingMicrosoftDynamicsCRM201311/09/2014Page21of140Figure4-TabletDashboardOthernewfeaturesDatabaseencryption:databaseencryptionisenabledforasetofdefaultentityattributesthatcontainsensitiveinformation,suchasusernamesandemailpasswords.
Getstartedpane:removedinCRM2013toprovidefurtherscreenspaceforinformationPopups:therearenomorepopupsinCRM2013.
InlineEditing:youcannowclickortapafieldtoupdateinfoforarecordrightinline.
YammerIntegration:userscanparticipateinsocialconversationsdirectlywithinMicrosoftDynamics,throughtheYammerwebanddesktopapplicationsaswellasappsrunningonMicrosoft(WindowsPhone),Apple(iOS)andGoogle(Android)mobiledevicesSkype&LyncIntegration:enablingdirectdiallingfromanyphonenumberfieldinDynamicsCRMBingMaps:integratedMapsIntegrateddynamicallyshowthemapfortheprimaryrecordaddressDuplicateDetection:detectionduringrecordCreateandUpdatehasbeenremovedfromCRM2013ServerSideSynch:Server-SideSyncisusedtointegrateemails,activitiesandtaskswithCRM2013.
Server-SideSyncdoesthesameworkastheEmailRouterandmore.
Currently,Server-SideSyncwillonlyworkinthefollowingscenarios:oMicrosoftDynamicsCRMOnline→MicrosoftOffice365oMicrosoftDynamicsCRMOn-Premise→MicrosoftExchangeOn-PremiseExtendingMicrosoftDynamicsCRM2013Page22of14011/09/2014Baseandextensiontablemerge:InCRM2013theentitynameBaseandentitynameExtensionBasetablesaremergedintoasingleentitynameBasetable.
ThiscanimproveoverallperformanceofCRMOneimagefieldperentityNewFunctionalityMicrosoftisreleasingadditionalfunctionalityasadd-onlicenseoptions.
MarketingPilot(DynamicsMarketing)Parature(CustomerService)SocialListeningUnifiedServiceDesktop(CCA)EnterpriseLicenseFindmoreintheSpring2014PreviewGuideLesson1-5ResourcesMicrosofthasalwaysbeensupportiveofdevelopersandthefollowingresourcesareavailable:CRMDeveloperCentermsdn.
microsoft.
com/dynamics/crmMicrosoftDynamicsCRM2013CustomizationGuideCRMHelpCenterwww.
microsoft.
com/en-us/dynamics/crm-help-centerSDKwww.
microsoft.
com/en-us/download/details.
aspxid=40321Codeplexwww.
codeplex.
comForumssocial.
microsoft.
com/ForumMarketplacedynamics.
pinpoint.
microsoft.
com/en-GB/homeTrainingandAdoptionKitExtendingMicrosoftDynamicsCRM201311/09/2014Page23of140Module2–PlatformOperationsThekeyobjectivesofthismodulearetounderstandhowtoconnecttotheWCFwebservicesusing.
NETandtoexecutemethodstoaccessdata.
ThismodulecoversconnectingtotheCRMserveranddoesnotincludeclientsideaccess.
ObjectivesThekeyobjectivesofthismoduleareto:DiscusstheuseandbenefitsoftheWindowsCommunicationFoundationwebservicesDescribethepurposeofDiscoveryServicewebserviceandhowitisusedHowtousetheOrganizationwebserviceUnderstandthedifferencesbetweenearlyandlate-boundclassesUsetheCreate,Retrieve,UpdateandDeleteMethodsUseRequest/ResponsemethodHowtohandleexceptionsUsingMetaDataLesson2-1WindowsCommunicationsFoundationWindowsCommunicationFoundationMicrosoftusestheWindowsCommunicationFoundation(WCF)programmingmodeltobuildservice-orientedapplications.
Developersuseittobuildsecureandreliablesolutionsthatintegrateacrossplatformsandinteroperatewithexistinginvestments.
TheMicrosoftDynamicsCRMSDKsimplifiestheuseofWCFtechnologyandclaims-basedauthentication.
ItprovideshelperproxyclassesmakingiteasytowriteapplicationsthatconnecttoandauthenticatewiththeMicrosoftDynamicsCRMwebservices.
ThesehelperclassescanbeusedinapplicationssothatdeveloperswillhavetoaccessanyMicrosoftDynamicsCRMdeploymentusingthesamecodeandwithouthavingtobecomeanexpertinclaims-basedsecurityorWCFprogramming.
MicrosoftDynamicsCRM2013expandsuponthestreamlinedWCFendpointintroducedinCRM2011whichreplacedpriorWebservices.
TheWCFendpointisaconsolidatedAPIthatincludesbothCRMserviceandmetadataserviceAPIinearlierversions.
BenefitsThereareanumberofkeybenefitstoWCF:WebServicesExtendingMicrosoftDynamicsCRM2013Page24of14011/09/2014StreamlinedAPIImprovedperformance.
NETdatatypesClaimsbasedauthenticationWebServicesWCFincludeabstractstheunderlyingtransporttechnology,supportsstandardcommunicationswhichimprovesinteroperability,andthatitiscompletelyextendabletosupportanynewstandardorprotocol.
ThemainWCFwebserviceisonlyavailableforusewith.
NETclients.
WCFalsoprovidesaSOAPwebserviceforusewhennotconnectingwith.
NET.
TheWSDL,servicecontractdefinition,isstaticandthesameoranyorganization.
StreamlinedAPIwithaFocusedSetofMethodsEachorganizationhasthesameservicecontractwithtypedclasses.
TheservicecontractensurestheentityrelatedAPIwilluseagenericEntityclass.
Standard.
NETTypesTheAPIusesstandard.
NETnullabletypesformostofthedatatypes.
ClaimsBasedAuthenticationAuthenticationMethodsMicrosoftDynamicsCRM2013supportstwoauthenticationmethods:BasicClaimsAuthenticationActiveDirectoryAuthenticationBasicClaimsAuthenticationTheconceptofa"onesizefitsall"securityforapplicationsaccessingfromdifferentlocationswithmultipledevicesdoesnotworkwellandsoMicrosoftcreatedtheWindowsIdentifyFoundation(WIF)toaddressthischallenge.
WIFisaframeworkforimplementingclaims-basedauthenticationusedbyMicrosoftDynamicsCRM2013andotherMicrosoftapplicationssuchasSharePoint.
ClaimsbasedauthenticationusesanindustrystandardprotocolsointheorywecanuseanyIdentifyProvidertoauthenticateuses.
Inessencetheauthenticationofusersishandledbyathirdparty.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page25of140ClaimsBasedAuthenticationworkstogetherwithWCFtoprovidesecureuserauthenticationandacommunicationchannelwithaMicrosoftDynamicsCRMserver.
AllMicrosoftDynamicsCRMeditionssupportclaims-basedauthentication.
Thefollowingaresomescenariosactivatedbymovingtoclaims-basedauthentication:SupportforanySecurityAssertionMarkupLanguage(SAML)compliantproviderActiveDirectoryFederationServicestoaccessMicrosoftDynamicsCRMremotelyusingtheirexistingidentitieswiththeneedforaVPN.
SecureTokenServiceClaims-basedauthenticationrequirestheavailabilityofaSecureTokenService(STS)runningonaserver.
AnSTSservercanbebasedonActiveDirectoryFederationServices(ADFS)v2,oranyplatformthatprovidestheofficialSTSprotocol.
Claims-basedauthenticationismadeupofasetofWS-*standardsthatdescribetheuseofaSecurityAssertionMarkupLanguage(SAML)token.
TheSAMLtokeniseither:Passivemode(whenWS-FederationisusedwithbothMicrosoftDynamicsCRM2013andtheMicrosoftDynamicsCRMOnlinewebapplication).
Activemode(whereWS-TrustisusedwithWindowsCommunicationFoundation(WCF)clients).
TrustsMicrosoftDynamicsCRM2013needstotrustthethirdpartyidentifyprovideandacceptuserspassedfromtheidentityprovider'sSTSandhasnoneedtoperformfurtherauthentication.
TouseClaims-basedauthenticationyoumustfirstcreateatrustbetweenDynamicsCRMandtheSTS.
Note:HowtosetupclaimsbasedauthenticationiscoveredintheMCRMcourseorrefertothefollowingtopicsintheMicrosoftDynamicsCRM2013ImplementationGuide.
ConfigureMicrosoftDynamicsCRMforanInternet-facingdeploymentClaims-basedauthenticationandInternet-FacingDeployment(IFD)requirementsConfigurerelyingpartiesforclaims-basedauthenticationHowClaims-basedAuthenticationWorksToaccessaclaimsconfiguredMicrosoftDynamicsCRM2013serverbyusingtheMicrosoftDynamicsCRMSDK,youmustfirstinstallWindowsIdentityFoundation(WIF)onthedevelopmentcomputer.
TheWindowsIdentityFoundationinstallstheMicrosoft.
IdentityModelassembly.
ThisisreferencedbytheMicrosoftDynamicsCRMSDKassembliesatrun-time.
ExtendingMicrosoftDynamicsCRM2013Page26of14011/09/2014ArequesttoauthenticateauserissentfromMicrosoftDynamicsCRM2013orMicrosoftDynamicsCRMOnlineoracustomapplicationtotheSTSserver.
TheSTSserverdetermineswhethertheusershouldbeauthenticated,andifthisisthecase,issuesasignedandencryptedSAMLtokenthatcontainsuserauthenticationinformation.
HowActiveDirectoryAuthenticationWorksArequesttoauthenticateauserissentfromMicrosoftDynamicsCRM2013oracustomapplicationtoActiveDirectory.
TheWCFstackmanagestheauthenticationprocessforMicrosoftDynamicsCRMSDKAPIcallsfromanapplication,whereasInternetInformationServices(IIS)managesauthenticationforawebapplication.
Kerberosticketscreatedandpassedbetweenthecomputersandcontaintheuserauthenticationinformation.
Lesson2-2MicrosoftDynamicsCRMWebServicesWebServicesprovidedbyDynamicsCRMTherearefourwebservicesprovidedbyDynamicsCRM:DiscoverywebserviceOrganizationwebserviceDeploymentwebserviceOData(REST)webserviceInCRM2013,theODataendpointisnowavailableoutsidetheapplicationtoprovideauthentication.
Thisprovidesfunctionalityforexternalappstousethemodernappendpointforauthentication.
TheODatawebserviceisusedwithclientsidecodingandiscoveredinModule7.
DiscoveryWebServiceTheDiscoveryServicewebserviceisusedtodeterminetheorganizationswithaCRMdeploymentthatauserisamemberof,andtoidentifytheendpointaddressURLneededtoaccesstheOrganizationServicewebserviceforeachofthoseorganizations.
BecauseMicrosoftDynamicsCRM2013worksinamulti-tenantenvironmentthediscoveryserviceisnecessarysothatanapplicationcandeterminetheendpointaddressURLtoaccessthetargetorganization'sbusinessdata.
ForMicrosoftDynamicsCRM2013installations,serverandorganizationallocationmaychangeaspartofdatacentermanagementandloadbalancing.
TheDiscoveryServicewebserviceletsyoudiscoverwhichMicrosoftDynamicsCRMserverisservinganorganizationatagiventime.
TheDiscoveryServicereturnsalistofOrganisationsthattheuserisentitledtouseandcontainsthenamesoftheorganisationsandURLendpoints.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page27of140AssembliesrequiredTheDiscoveryservicerequiresthefollowingassemblies:Microsoft.
Xrm.
Sdk.
dll-Microsoft.
Xrm.
Sdk.
ClientnamespaceSystem.
ServiceModel-forWCFSystem.
Runtime.
SerializationSystem.
SecurityDiscoveryServiceURLTheURLforthediscoveryserviceon-premiseis:http[s]:///XRMServices/2011/Discovery.
svcTheURLforthediscoveryserviceusingIFDis:https://dev.
/XRMServices/2011/Discovery.
svcTheURLforthediscoveryserviceforCRMOnlineinEMEAis:https://disco.
crm4.
dynamics.
com/XRMServices/2011/Discovery.
svcEndpointAccessTypeEnumerationWheninstantiatingtheDiscoveryServicewebservice,youmustidentifythetypeofauthenticationapproach.
TheMicrosoft.
Xrm.
SdkassemblyhasanenumerationcalledtheEndpointAccessType.
Thiscontainsthreeitems:Default-Defaultaccess.
Usedforon-premisedeploymentsbuttheactualaccessisdeterminedbytheendpointURL(Value=0)Internet-Internetaccess.
UsedforMicrosoftDynamicsCRMOnline(Value=1)Intranet-Intranetaccess.
UsedforInternet-Facing(IFD)deployments(Value=2)OrganizationWebServiceInMicrosoftDynamicsCRM2013,theprimarywebserviceaccessingdataandmetadataforyourorganizationistheOrganizationServicewebservice.
ThiscontainsthemethodsthatarerequiredtowritecodethatuseallthedataandmetadatainMicrosoftDynamicsCRM.
AssembliesrequiredTheOrganisationservicerequiresthefollowingassemblies:Microsoft.
Xrm.
Sdk.
dll-Microsoft.
Xrm.
Sdk.
ClientnamespaceExtendingMicrosoftDynamicsCRM2013Page28of14011/09/2014System.
ServiceModel-forWCFSystem.
Runtime.
SerializationSystem.
SecurityOrganizationServiceURLTheURLfortheorganizationserviceon-premiseis:http[s]:////XRMServices/2011/Organization.
svcTheURLfortheorganizationserviceusingIFDis:https://.
/]>/XRMServices/2011/Organization.
svcTheURLfortheorganizationserviceforCRMOnlineinEMEAis:https://crm4.
dynamics.
com/XRMServices/2011/Organization.
svcDeploymentWebServiceTheDeploymentwebserviceisusedtomanagetheMicrosoftDynamicsCRMdeploymenti.
e.
organisationsandservers.
WiththeDeploymentwebserviceyoucancreateorganisations,disableorganisations,disableserversetc.
TheMicrosoftDynamicsCRMDeploymentManagerMMCandMicrosoft.
CrmPowershellcmdletsutilisethiswebservice.
AuthenticationbyUsingtheClientProxyClassesTheeasiestwaytoauthenticatewithMicrosoftDynamicsCRMwebservicesisbyusingtheOrganizationServiceProxyandDiscoveryServiceProxyclassesintheapplicationsyouarewriting.
Thefour-parameterconstructoroftheseclassessupportsMicrosoftDynamicsCRM2013deployments.
ThisisthepreferredmethodofauthenticatingwiththeserverandisusedbymostoftheMicrosoftDynamicsCRMSDKsamples.
TheseproxyclassesautomaticallyhandleclaimsorActiveDirectoryauthenticationandalsomanageresourcelimitsontheWCFchannelendpoint.
ClassesDescriptionandusageHelpercodeTheclassesinthesamplecodedemonstratehowtoconnecttothewebservicesandauthenticatetheuser.
Youcanusethehelpercodeasabasisofyourowncustomauthenticationcode.
ThiscodeiseasytouseandsupportsallMicrosoftDynamicsCRMdeploymenttypes.
Italsosupportsstoringusers'passwordsintheWindowsCredentialManagerforlaterreuse.
Fullsourcecodeisprovidedsoyoucancopyandcustomizeitforyourneeds.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page29of140DeveloperExtensionsTheseassembliesareprovidedtosimplifyandacceleratethedevelopmentofapplicationsthatinteractwithMicrosoftDynamicsCRM.
TheextensionsextendthefunctionalityofthecoreMicrosoftDynamicsCRMSDKspecificallyaroundtheuseoftheOrganizationServiceContextclass.
Foraneasymethodthatdoesthehardworkforyouinafewlinesofcode,usetheCrmConnectionclass.
ThiscodeiseasytouseandsupportsallMicrosoftDynamicsCRMdeploymenttypes.
XrmclientForadvanceddeveloperswhoneedtocustomizetheWindowsCommunicationFoundation(WCF)servicechannelmanagementandtheauthenticationprocess,usetheIServiceManagmentandOrganizationServiceProxyclassesintheMicrosoft.
Xrm.
Sdk.
Clientnamespace.
Usingtheseclassesdirectlycanprovidebetterconnectionandauthenticationperformance,andmoreflexibility.
However,theyrequiremoreadvancedknowledgeoftheWCFservicechannelandserverauthentication.
Inaddition,youmustwritemorecodetohandleallMicrosoftDynamicsCRMdeploymenttypes.
Lesson2-3EarlyBoundandLateBoundClassesEntityclassDeveloperscaninteractwiththeAPIusingtheEntityclassinalate-boundfashion(workingdirectlywiththeattributecollection).
Thiskindofaccessisbestforsituationswhereyoudonothavepriorknowledgeoftheentitiesyourapplicationwillbeworkingwith.
MicrosoftDynamicsCRM2013providesautilitywhichusestheplatformmetadatatogeneratetypedclassesforeachentity.
Thegeneratedclassisusedinearly-bounddevelopment.
TheseclassesinheritfromthegenericEntityclassanddeveloperscanworkwiththeknownproperties.
Thisisknownasearly-bound.
Asadeveloperyoucanuseeitherearlyorlatebindinginyour.
NETcode.
IfyouareusingSOAPandanon.
NETlanguageyouarerestrictedtolatebinding.
Early-BoundEntityClassInMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnline,thecodegenerationtool(CrmSvcUtil)createsearly-boundentityclassesthatyoucanusetoaccessbusinessdatainMicrosoftDynamicsCRM.
Theseclassesincludeoneclassforeachentityinyourorganisation,includingcustomentities.
Everytimethatacustomizermakescustomisationstoasystemandthosefieldsorentitieshavetobeusedprogrammatically,theseclassesmustberegenerated.
Theclassescanbeusedinanyprojecttypeorbuiltintoaclasslibrary.
Developerscanuseearly-boundentityclasseswhentheycreateapplicationsthatuseMicrosoftDynamicsCRM,plug-insandcustomworkflowactivities.
ExtendingMicrosoftDynamicsCRM2013Page30of14011/09/2014AdvantagesofanEarly-BoundEntityClassTheadvantagestousingearly-boundentityclassesisthatalltypereferencesarecheckedatcompiletime.
Thecompiledexecutablecontainsthecodethatisneededtoinvokethetypes,properties,methods,andevents.
Theclasscreatedbythecodegenerationtoolincludesalltheentity'sattributesandrelationships.
Byusingtheclassintheircode,developerscanaccesstheseattributesandbetypesafe.
Aclasswithattributesandrelationshipsiscreatedforallentitiesinanorganization.
Thereisnodifferencebetweenthegeneratedtypesforsystemandcustomentities.
Thefollowingsampleshowshowtosettheemailaddressofacontactentity.
Forthisexample,assumethataqueryhasfoundtherecordtobechangedandthelogicalnameisContact:Contactcontact=NewContact();contact.
EMailAddress1=marykay@contoso.
com;Thefollowingsampleshowshowtousecustomentitiesandattributes:new_bankaccountbankaccount=Newnew_bankaccount();bankaccount.
new_accountnumber="12345";CreateEarly-BoundEntityClasseswiththeCodeGenerationTool(CrmSvcUtil.
exe)Touseearly-boundclasses,customcodemustknowwhattheobjectmodelisforthedeploymentitisintendedtoworkwith.
ToobtainthisinformationaclassfilewillhavetobecreatedthroughtheuseoftheCrmSvcUtil.
CrmSvcUtil.
exeisacommand-linecodegenerationtoolinMicrosoftDynamicsCRM2013andisincludedintheSDK.
Itgeneratesearly-bound.
NETFrameworkclassesthatrepresenttheentitydatamodelentitiesinsideMicrosoftDynamicsCRM.
RunningthetoolisthefirststepinusinganentitydatamodeltodevelopapplicationsforMicrosoftDynamicsCRM.
TheCrmSvcUtil.
exetoolcreatesaMicrosoftVisualC#orMicrosoftVisualBasic.
NETfilethatcontainsstronglytypedclassesfortheentitiesinyourorganization,includingcustomentitiesandattributes.
Thisoutputfilecontainsoneclassforeachentity.
Itprovidesearly-bindingandIntelliSensetoaidyouasyouwritecustomcode.
Thegeneratedclassesarepartialclassesthatcanbeextendedwithcustombusinesslogicinseparatefiles.
UsingEarlyBoundWhenemployingearlyboundproxyclassyoumustspecifythefollowinglineafterconnectingtotheOrganisationservice.
serviceProxy.
ServiceConfiguration.
CurrentServiceEndpoint.
Behaviors.
Add(newProxyTypesBehavior());or,.
moresimply_serviceProxy.
EnableProxyTypes();ExtendingMicrosoftDynamicsCRM201311/09/2014Page31of140Late-BoundEntityClassInMicrosoftDynamicsCRM2013,adevelopercanusetheEntityclasstoworkwithentities.
Thisletsadeveloperuselatebindingsothatheorshecanworkwithtypessuchascustomentitiesandcustomattributesnotavailablewhencompilingtheapplication.
Wheninitialized,theEntityclasscontainsthelogicalnameofanentityandaproperty-bagarrayoftheentity'sattributes.
Thekeydifferencebetweenearlyandlatebindinginvolvestypeconversion.
Whereasearlybindingprovidescompile-timecheckingofalltypessothatnoimplicitcastsoccur,latebindingcheckstypesonlywhentheobjectiscreatedoranactionisperformedonthetype.
TheEntityclassrequirestypestobeexplicitlyspecifiedtopreventimplicitcasts.
WhenadeveloperworkswiththeEntityclassanduseslatebinding,heorshecanworkwiththeentityandlogicalattributename.
Thiscontrastswithearlybindingwhereapersonworkswiththeentityandattributeschemaname.
Tocreateanewentity,firstcreateanewinstanceoftheEntityclassandpassitanentityname.
Thefollowingcodeexampleshowshowtocreateanewaccountrecord.
Entityaccount=newEntity("account");account["name"]="FourthCoffee";_accountId=_orgService.
Create(account);Intheprecedingexample,anewentityobjectofthetype"account"iscreated,attributesareset,andthentheIOrganizationService.
Createmethodiscalledtocreatethenewrecord.
DataTypesTheprogrammingmodelnowusesnative.
NETtypeswheneverpossible.
AttributeTypeCodeCRM2013typeBigIntlongBooleanboolCalendarRulesEntityCollectionorCalendarRules[]CustomerEntityReferenceDateTimeSystem.
DateTimeDecimaldecimalDoubledoubleEntityNamestringIntegerintLookupEntityReferenceExtendingMicrosoftDynamicsCRM2013Page32of14011/09/2014ManagedPropertyBooleanManagedPropertyMemostringMoneyMoneyOwnerEntityReferencePartyListEntityCollectionorActivityParty[]PicklistOptionSetValueUniqueidentifier(FormerlyPrimaryKey)System.
GuidStringstringStateOptionSetValueorenumerationgeneratedfortheentitystateStatusOptionSetValueUniqueidentifierSystem.
GuidVirtualNotusedinrecords.
NullValuesTosetafieldtonullinmosttypes,justsetthevaluetonull.
ForstringssetthefieldtoString.
Empty.
ForEntityReferencessetthevaluetoGuid.
Empty.
Lesson2-4Create,Retrieve,UpdateandDeleteMethodsCreatemethodTheCreatemethodisusedtocreateanewentityinstance(object)inMicrosoftDynamicsCRM.
TheparametersspecifytheentitythatwillbecreatedandtheyreturnaGUIDthatcontainstheIDofthenewlycreatedentity.
AGUIDcanbespecifiedbeforecallingtheCreatemethod,andMicrosoftDynamicsCRMwillusethatGUIDforthenewobject.
RetrievemethodTheRetrievemethodisusedtoobtainanobjectfromMicrosoftDynamicsCRManditacceptsthefollowingparameters:entityName:ThelogicalnameoftheentityspecifiedintheentityIdExtendingMicrosoftDynamicsCRM201311/09/2014Page33of140id:TheID(GUID)oftherecordthatyouwanttoretrieve.
columnSet:Aquerythatspecifiesthesetofcolumns,orattributes,toretrieve.
AnentityisreturnedcontainingthefieldsspecifiedinthecolumnSet.
ColumnSetTospecifyalistoffieldstoretrieve,youmustdeclareaColumnSetvariableandthensetitsAttributespropertyorcreateanAllColumnsvariable.
UsetheColumnSetvariableexceptwhenallattributesoftheentitymustbereturned.
UsingAllColumns,orColumnSet(true),returnsallthedatafieldsassociatedwiththeentitythereforeitshouldbeusedsparingly,especiallybecauseitsendslargequantitiesofunnecessarydataoverthenetwork.
Manyfieldsonanentityarereferencestootherentities.
TheMicrosoftDynamicsCRMplatformperformsthejoin,andthenreturnsanobjectthathastheType,ID,andNamepropertiespopulated.
Thatmeansforeachreferencefield,MicrosoftDynamicsCRMisbeingaskedtoperformajoin,createaninstanceofaclass,andpopulatethreepropertiesoftheclass.
OnaContactobject,thisoccursatleastfivetimes.
WhenusingColumnSet,theAttributespropertytakesanarrayofstringsthatrepresentthenamesofthedesiredfields.
Note:TheIDcolumnisalwaysreturned.
UpdatemethodTheUpdatemethodisusedtoupdateinformationforaspecificobject.
WhenyouuseUpdate,youmustspecifytheGUIDfortheobjectthatwillbeupdated.
Anentityistheinputparameter.
Nothingisreturned.
BewaryofupdatingarecordofanentityretrievedasCRMwilltreatallfieldsintheentityasbeingupdatedevenifthevaluehasnotchanged.
Thiscantriggerpluginsandworkflowsunnecessarilyandcauseauditlogstobewritten.
ThisisparticularlyrelevantwhereAllColumnshasbeenusedtoretrievetherecord.
Bestpracticeistoinstantiateanewinstanceoftheentityandonlyspecifythefieldsyouneedtochange.
DeletemethodTheDeletemethodisusedtodeleteanobject.
Whenanobjectisdeletedallappendedobjectsarealsodeleted.
Appendedobjectsincludeanychildobjectsfortheentitybeingdeleted,forexample,addressesonanAccount.
Ifanyobjectswithintheparenthierarchycannotbedeleted,thedeleteoperationrollsbackandnochangesaremade.
Objectswithoutparentalrelationshipsarenotdeleted.
TheDeletemethodacceptsaGUIDfortheobjectthatwillbedeleted.
TheDeletemethodacceptsthefollowingparameters:entityName:ThelogicalnameoftheentityspecifiedintheentityIdid:TheIDoftherecordthatyouwanttoretrieve.
ExtendingMicrosoftDynamicsCRM2013Page34of14011/09/2014Nothingisreturned.
IsCRM,itisbestpracticetodeactivaterecordsusingSetStateratherthandeletethem.
Lesson2-5ExecuteMethodExecuteMethodToperformanyoperationotherthanthecommonCreate,Retrieve,Update,DeleteandRetrieveMultiple(seenextmodule)methods,usetheExecutemethod.
TheCreate,Retrieve,Update,DeleteandRetrieveMultiplemethodsprovidewrappersthatinternallyusetheExecutemethod.
TheExecutemethodisdesignedaroundamessage-basedapproachtodevelopmentinsteadofamethod-basedapproach.
Insteadofhavingamethodforeveryoperation,thereisasinglemethod,Execute.
Thisispassedamessage(embodiedasaOrganizationRequestclass)thatdescribestheoperationtoperform.
TheExecutemethodsupportsamessageclasshierarchytogroupsimilaroperations.
Executetakesamessagerequestclassasaparameterandreturnsamessageresponseclass.
Everyrequestmessagehasacorrespondingresponsemessage.
Therequestdescribeswhatisneededfromtheplatformandtheresponseishowtheplatformprovidesit.
Thedifferencebetweenusingamessage-basedapproachandamethod-basedapproachisbestillustratedbythedifferencebetweentheExecutemethodthatreliesonmessagesasparameters,andtheCreate,Update,Delete,RetrieveandRetrieveMultiplemethods.
TheSDKprovidesthefivecommonmethodsbecausetheyareusedfrequently.
However,eachofthoseoperationscanalsobeperformedbyusingExecute.
Therearealmost200operationsthatcanbeperformedbyusingExecutepairedwiththeappropriateRequestandResponseobjects.
Inamethod-basedSDK,thiswouldrequirealmost200differentmethodswiththeirownuniquesyntax.
RequestsandResponsesTheExecutemethodisamessage-basedmethod.
Thismethodtakes,asitssoleparameter,aRequestclass.
TheRequestclassisamessagesenttotheserverforprocessing.
ItreturnsaResponseclasswhichcontainstheresultsoftherequest.
Non-EntitySpecificRequestsManyrequestmessagesarenotboundtoparticularentities.
Theydonotrequireanentityortheycanbeappliedtoanynumberofdifferententitytypes.
Whentheycanbeappliedtodifferententitytypes,theycontainaTargetpropertythatisnotboundtoaspecificentitytype.
Otherwise,theydonothaveaTargetproperty.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page35of140NOTE:FordetailsaboutSimpleGenericRequests,referto"XRMMessagesintheOrganizationService"intheSDK.
EntitySpecificRequestsEntityspecificrequestsaremessagesthatalwaysapplytoonlyonetypeofentity.
Thesemessageshavetheentitynameintheclassname,suchas"GenerateQuoteFromOpportunityRequest.
"TheydonothaveaTargetproperty,insteadtheytakeentity-identifyinginformationsuchasanID.
NOTE:Theterms"Non-EntitySpecificRequest"isnotusedintheMicrosoftDynamicsCRMSDK.
ItisintroducedheretoclarifythedifferencebetweenRequeststhatdonotapplytoaspecifickindofentityandRequestmessagesthatdo.
GenericRequestsThereareseveralExecutemessagesthataresimplegenericrequests.
ThesedonothavetheirTargetproperty.
ThetwomostcommonareWhoAmIandQueryExpressionToFetchXml.
Lesson2-6ExceptionsMicrosoft.
Xrm.
Sdk.
OrganizationServiceFaultManyexceptionscanbereturnedfromaMicrosoftDynamicsCRMwebservicemethodcall.
Yourapplicationdesignmustcatchandappropriatelyhandletheseexceptions.
IntheMicrosoftDynamicsCRMSDK,allwebservicemethodcallsuseacommunicationchanneltotheserverbasedontheWindowsCommunicationFoundation(WCF)technology.
InWCFterms,exceptionsreturnedfromthechannelarecalledfaults.
ToaccesstheMicrosoftDynamicsCRMfaultsbeingproducedbyWCF,addSystem.
ServiceModeltotheheaderofthecode.
Thiswillcapturecontractually-specifiedSOAPfaults.
TotrackthosefaultsrelatedspecificallytoMicrosoftDynamicsCRM,includethefollowingcodeintothecatchstatement:catch(FaultExceptionex)IfyouareaccessingthediscoveryWebservice,yourcodeshouldcatchDiscoveryServiceFaultinsteadoftheOrganizationServiceFault.
OtherExceptionsInadditiontotheseexceptionsandfaults,codeshouldalsohandlethefollowingexceptions:SecurityTokenValidationExceptionExpiredSecurityTokenExceptionSecurityAccessDeniedExceptionMessageSecurityExceptionSecurityNegotiationExceptionWhenconnectingtoMicrosoftDynamicsCRMOnline,aSecurityAccessDeniedExceptionexceptioncanbethrownifyouuseavalidMicrosoftAccountIDandyourMicrosoftAccountisnotassociatedExtendingMicrosoftDynamicsCRM2013Page36of14011/09/2014withanyMicrosoftDynamicsCRMOnlineorganization.
AMessageSecurityExceptioncanbethrownifyourMicrosoftAccountIDisnotvalidorMicrosoftAccountdidnotauthenticate.
Lesson2-7MetadataMetadataThemetadatalayerabstractstheunderlyingdatastoragedetails,suchasschemaanddataaccessfromthehigher-levelconstructsofdomainlogicimplementationanduserinterfaceandprovidesadditionalinformationaboutthedata.
TheorganizationservicewebserviceprovidesaccesstometadataoftheMicrosoftDynamicsCRMorganization.
Asadeveloper,youhavetochoosewhethertotakeadditionalstepsthatarerequiredtoincorporatetheMicrosoftDynamicsCRMmetadataintoyourapplicationsothatthesechangesarereflectedintheapplication.
Thealternativeistousehard-codedvaluesandtoleratepotentialinconsistenciesorrebuildtheapplicationswhentheymustreflectchangesinthemetadata.
ItisrecommendedtousethemetadatasotheapplicationsreflectchangesinMicrosoftDynamicsCRM.
ThemetadataforanorganizationisstoredintablesintheMicrosoftSQLServerintheirorganization'sdatabase.
Thesetablescontaintheentity,attribute,andrelationshipdefinitionsforeachorganization.
Thisincludesthemetadataforcustomisations.
TheorganizationservicewebservicecontainsthemessagesusedtoreadorwritethedefinitionsforalltheentitiesinaMicrosoftDynamicsCRMinstallationwiththeMicrosoft.
Xrm.
Sdk.
Metadatanamespace.
ReadandWriteActionsTheorganizationservicecanbeusedtoperformreadandwriteactions.
Thereadactionscanincludethefollowing:retrieveallthemetadatatocreateametadatacacheinaclientapplication;determinewhetherthemetadatahaschangedsincethepreviousretrieve;retrievealltheentitiesanddeterminewhichonesarecustomentities;retrievethemetadataforaspecificentity,system,orcustom;retrievetheattributesforanentity;retrievethemetadataforaspecificattributesuchaspossiblestate,namesoroppositevaluesonanattribute.
Writeactionsincludethefollowing:Createacustomentity;addorupdateandattributeforanentity,systemorcustom;createordeletearelationshipbetweentwoentities;ExtendingMicrosoftDynamicsCRM201311/09/2014Page37of140addorremoveanoptionfromtheoptionsetattribute;writeaninstallationandinstall-uninstallprogramforthecustomsolution.
Whenaccessingthemetadataontheorganizationservice,theuserhastohavesufficientprivilegestoperformtherequiredaction.
Manybuilt-insecurityrolesdonotincludetherequiredprivilegesontheentity,attributeandrelationshipsecurable,andthismighthavetobemodified.
Creatingfieldsprogrammaticallyisconceptuallysimilartocreatingthemthroughtheinterface.
Eachdatatypehaspotentiallydifferentpropertiesthatcanorhavetobesetduringthecreationprocess.
Additionally,whencreatingseveralnewfields,itishelpfultoaddthemtoalist.
Thiscanbedonebycreatinganinstanceoftheattributemetadatalist.
Whenyouprogrammaticallycreatecustomizationstoanenvironmentsuchasmodifyingtheform,thecustomizationswillhavetobepublished.
Conceptually,thisisthesameprocessasifyouweredoingitthroughtheinterface.
Youcanpublishanentity,multipleentities,orallentitiesandcomponents.
Finally,forefficiencyandperformance,makesuretousetheretrievemetadatachangesmessage.
Thismessageallowsyoutodetectchangesandonlyretrievewhathasbeenaddedordeleted,allowingformuchmoreeffectivecachemanagement.
LookupmoreontheSDKhelpunderRetrieveanddetectchangestometadata.
MetadataBrowserThesolutionexplorerprovidesaccesstoalltheentitiesthatyoucancustomize,butthisisjustafractionofalltheentitiesthatdefinethemetadatausedforMicrosoftDynamicsCRM.
Formostbasiccustomizationtaskstheinformationpresentedwithinthesolutionexplorerisgoingtobeallyouneed.
Developersfrequentlyneedinformationaboutmetadataandaneasywaytoseethemetadata.
Ifyouneedtohavein-depthdiscussionswithdevelopersaboutmetadataorifyoujustwanttohaveadeeperunderstandingofthemetadata,usetheMetadataBrowsersolutionthatisincludedintheMicrosoftDynamicsCRMSDK.
TheMetadatabrowserisamanagedsolutioncontainingonlyHTMLwebresourcesthatyoucaninstallthatwillletyouviewallthemetadataandfilterentitiesandfieldstogainabetterunderstandingofwhatthemetadatacontainsExtendingMicrosoftDynamicsCRM2013Page38of14011/09/2014Module3–QueryingDataThekeyobjectivesofthismodulearetoprovideanunderstandingofdifferentmethodsofqueryingCRMdata.
ObjectivesThekeyobjectivesofthismoduleareto:UnderstandthedifferentquerymethodsLesson3-1QueriesinDynamicsCRMQueryOptionsThereareseveralwaystocreatequeriesinMicrosoftDynamicsCRM2013.
Developerscanuse.
NETLanguage-IntegratedQuery(LINQ)inearlyandlatebindingscenarios,writequeriesbyusingFetchXML,theproprietaryMicrosoftDynamicsCRMquerylanguage,orbuildaquerybyusingQueryExpressionandtheQueryExpressionclass.
DeveloperscanalsouseODatainclientsidecode.
ODataiscoveredinModule7.
Lesson3-2QueryExpressionOverviewTheQueryExpressionclasscanbeusedtobuildcomplexqueriesforusewiththeIOrganizationService.
RetrieveMultiplemethodortheRetrieveMultipleRequestmessage.
QueryparameterscanbepassedtotheQueryExpressionbyusingtheConditionExpression,ColumnSet,andFilterExpressionclasses.
Ifvaluesfrommultipleentitiesareneeded,QueryExpressioncanbeusediftherearerelatedentities.
Forexample,ifadeveloperloopsthroughalistofcontactsandreturnsthenamesofallthoseaccountsforwhomthatcontactisaprimarycontact,aQueryExpressioncanhandlethisthroughtheuseofLinkedEntities.
However,ifadeveloperwantstoretrievealistofOpportunities,Quotes,OrdersandInvoicesthatarecreatedonorbeforeaparticulardate,QueryExpressionwouldnothandlethis.
Alternatively,thedevelopercoulduseFilteredViewsorpotentiallyFetchXML.
Dependingonthespecificsoftheorganisationandtherequirements,theuseofFilteredViewscouldbeeasier.
RestrictionsQueryExpressionislimitedto.
NETcodeonly.
QueryExpressioncanonlyretrieverecords.
QueryExpressioncannotperformaggregations.
QueryExpressionisproprietarytoMicrosoftDynamicsCRMandisnotusedelsewhere.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page39of140BenefitsQueryExpressioncanretrievevaluesfrommultiplerelatedentities.
QueryExpressioncanbeusedwithbothearlyandlateboundclasses.
IfQueryExpressionisusedwithearlyboundproxyclassthenyouwillhavecompiletimevalidation.
EntityCollectionTheentitycollectionclassisacollectionofbusinessentitiesandisusuallyviewedasaresultofaretrievedmultiplemethodsuchasQueryExpression.
TheEntityCollectionclassexposesthefollowingmembersNameDescriptionEntitiesGetsthecollectionofentities.
EntityNameGetsorsetsthelogicalnameoftheentity.
ExtensionDataGetsorsetsthestructurethatcontainsextradata.
ItemGetsorsetsaniteminthecollection.
MinActiveRowVersionGetsorsetsthelowestactiverowversionvalue.
MoreRecordsGetsorsetswhethertherearemorerecordsavailable.
PagingCookieGetsorsetsthecurrentpaginginformation.
TotalRecordCountGetsthetotalnumberofrecordsinthecollection.
ReturnTotalRecordCountwastruewhenthequerywasexecuted.
TotalRecordCountLimitExceededGetsorsetswhethertheresultsofthequeryexceedsthetotalrecordcount.
Lesson3-3QuerybyAttributeOverviewTheQueryByAttributeclasscanbeusedtobuildqueriesthattestasetofattributesagainstasetofvalues.
WhereastheQueryExpressionenablesmorecomplexqueries,theQueryByAttributeclassisasimpleoptionwhenitsearchesforrecordswhoseattributeshaveparticularvalues.
UsethisclasswiththeRetrieveMultiplemethodortheIOrganizationService.
RetrieveMultipleRequestmethod.
QueryByAttributehasthesameBenefitsandRestrictionsasQueryExpression.
ExtendingMicrosoftDynamicsCRM2013Page40of14011/09/2014Lesson3-4LINQOverviewInMicrosoftDynamicsCRM2013,developerscanuse.
NETLanguage-IntegratedQuery(LINQ)towritequeries.
DeveloperscanusetheOrganizationServiceContextclassoraderivedclasscreatedbytheCrmSvcUtiltooltowriteLINQqueriesthataccesstheOrganisationendpoint(Organization.
svc).
TheOrganizationServiceContextclasscontainsanunderlyingLINQqueryproviderthattranslatesLINQqueriesfromMicrosoftVisualC#orMicrosoftVisualBasic.
NETsyntaxintothequeryAPIusedbyMicrosoftDynamicsCRM.
RestrictionsLINQqueriesarebuiltusingstandardlanguagebutinternallyusesQueryExpressionsoislimitedtothefeaturesofQueryExpression.
TheLINQqueryprovidersupportsasubsetoftheLINQoperators.
NotallconditionsthatcanbeexpressedinLINQaresupportedLINQislimitedto.
NETcodeonly.
LINQcannotperformaggregations.
BenefitsLINQcancreate,retrieve,updateanddeleterecords.
LINQcanretrievevaluesfrommultiplerelatedentities.
LINQcanbeusedwithbothearlyandlateboundclasses.
IfLINQisusedwithearlyboundproxyclassthenyouwillhavecompiletimevalidation.
EarlyBindingandLINQTheCRMSvcUtilcangeneratetheLINQServiceContextbyprovidingtheoptionaltag/serviceContextName:eg/serviceContextName:MyDataContextTheLINQServiceContextthatisproducedbytakingthisapproachisagatewaytotheworkwiththeLINQprovider.
WhentheMyDataContextclassisinstantiated,aninstanceoftheOrganizationServicewillbepassed:var=newMyDataContext(_orgService)ThisproducesaLINQcontextthatcodecanworkwith.
Thiscontexthaspublic,queryablepropertiesforeachentityset.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page41of140Lesson3-5FetchXMLOverviewFetchXMLisaproprietaryquerylanguagethatisusedinMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnlinebasedonaschemathatdescribesthecapabilitiesofthelanguage.
TheFetchXMLlanguagesupportssimilarquerycapabilitiesasqueryexpressions.
ToexecuteaFetchXMLqueryinMicrosoftDynamicsCRM2013,anXMLquerystringmustfirstbebuilt.
Aftercreatingthequerystring,usetheIOrganizationService.
RetrieveMultiplemethodtoexecutethequerystring.
Theprivilegesoftheloggedonuseraffectsthesetofrecordsreturned.
Onlyrecordsforwhichtheloggedonuserhasreadaccesswillbereturned.
FetchXMLisusedasaserializedformofqueryinternallywithinCRM,tosaveaqueryasauser-ownedsavedviewintheuserqueryentityandasanorganization-ownedsavedviewinthesavedqueryentity.
AFetchXMLquerycanbeconvertedtoaqueryexpressionwiththeFetchXmlToQueryExpressionRequestmessageandbackagainwiththeQueryExpressionToFetchXmlRequestNotonlycanFetchXMLbeusedtoreturndatafromthedatatier,butitsuseisextendedinMicrosoftDynamicsCRM2013.
DeveloperscanuseFetchXMLaggregationssuchassum,max,min,count,andotherexamplestoperformcalculationsintheirFetchXMLqueries.
Additionally,althoughitisnotcoveredinthiscourse,MicrosoftDynamicsCRMcustomerscancreatecustomreportsusingFetchXMLqueries.
IfareportdesignerordeveloperisnewtoFetchXML,theycanusethestandardAdvancedFindfunctionalitytohelpconstructtheirFetchXMLqueryandusetheDownloadFetchXMLbutton.
RestrictionsFetchXMLislimitedto.
NETcode,andSQLReportingServicesaslongasa)theDynamicsCRMReportingExtensionsareinstalledontheSQLReportingServicesserverandtheDynamicsCRMReportingAuthoringExtension(BIDS)isinstalledonthedevelopersmachine.
FetchXMLcanonlyretrieverecords.
FetchXMLdoesnothavecompiletimevalidation.
FetchXMLisproprietarytoMicrosoftDynamicsCRMandisnotusedelsewhere.
BenefitsFetchXMLcanperformaggregations.
FetchXMLcanperformouterjoins–newinCRM2013.
ExtendingMicrosoftDynamicsCRM2013Page42of14011/09/2014FetchXmlandAggregationsInMicrosoftDynamicsCRM2013,FetchXMLincludesgroupingandaggregationfeaturesthatallowcodetocalculatesum,averagemin,maxandcount.
Thefollowingaggregatefunctionsaresupported:sumavgminmaxcount(*)count(attributename)Onlyoneaggregateattributecanbespecifiedinaquery.
Thedistinctkeywordcannotbeused.
Tocreateanaggregateattribute,setthekeywordaggregatetotrue,thenspecifyavalidentityname,attributename,andalias(variablename).
Inaddition,dataresultscanbegroupedusingFetchXML.
ThefollowingGroupByoptionsareavailable:GroupByWithLinkedEntityGroupByYearGroupByQuarterGroupByMonthGroupByWeekGroupByDayMultipleGroupByLesson3-6FilteredViewsOverviewMicrosoftDynamicsCRMprovidesdatabaseviewsthatarenamedfilteredviews,forallentities.
Thisincludescustomentities.
FilteredViewsarespecialSQLViewsthatmakeiteasiertoqueryagainsttheMicrosoftDynamicsCRMdatabase.
Theseviewsdenormalisethedatainthesystemintoasingletable.
Theviewsalsoalreadyhavesecurityappliedtothem.
Therefore,theyonlyreturnrecordsthattheusercanaccessthroughtheMicrosoftDynamicsCRMapplication.
WhencustomizingMicrosoftDynamicsCRM'sschemaoraddingcustomentities,MicrosoftDynamicsCRMupdatesorcreatesthecorrespondingfilteredviews.
UsefilteredviewstoquerytheMicrosoftDynamicsCRMdatastoredirectlyusingstandardSQLcommands.
Thesecommandsareexecutedusingthemethodsthatareprovidedbythetechnologyaccessingthedatabase.
Forexample,whenwriting.
NETcodeuseaSQLClientObject,andwhenusingSQLServerReportingServicessettheMicrosoftDynamicsCRMdatabaseasaDataSource.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page43of140WhentoUseFilteredViewsFilteredviewsarebestused:ToretrieveaDataSet(containingonetable,aDataTable)insteadofacollectionofobjects.
Forexample,tobindtoagridoruseaconsumersuchasSQLServerReportingServices,ExcelorMicrosoftWordthatexpectsDataSets.
TodosomethingthatcannotbedoneinQueryExpression,LINQorFetchXML.
AnythingdonewithSQLmustbedonewithFilteredViews.
ForcustomreportsforOn-Premiseorganizations.
SecurityandFilteredViewsWhenauserobtainsdatafromfilteredviews,theuser'sMicrosoftDynamicsCRMsecurityprivilegesandaccessrightsdeterminethedatathatisreturned.
Additionally,fieldlevelsecurityprofilesassociatedwithauserorateamauserispartofalsoaffectthedatareturnedwhenqueryingafilteredview.
Whencallingfilteredviews,theymustbecalledinthecontextofaMicrosoftDynamicsCRMuserusingintegratedWindowsauthentication.
AnyattempttouseSQLauthenticationfails.
UsingfilteredviewsfromcustomworkflowactivitiesandpluginsAdditionalstepsmustbetakentousefilteredviewswithincustomworkflowactivitiesandplugins.
Theseuseanetworkserviceaccountbydefault.
Ifusingfilteredviewstoretrievedataforcustomworkflowactivitiesorfromaplugin,includecredentialsofavalidMicrosoftDynamicsCRMuser.
RestrictionsFilteredViewsarelimitedtoon-premisedeploymentsonly.
FilteredViewscanonlyretrieverecords.
FilteredViewscannotbeusedwithinSandboxedpluginsandcustomworkflowassembliesBenefitsFilteredViewscanperformaggregations.
FilteredViewscanbeusedwithinSQLReportingServicesreports.
Lesson3-7ReportingOptionsOverviewAbusinessmustbeabletoanalysedataandvisualizeitinmeaningfulways.
Throughtheuseofcharts,dashboards,andreports,combinedorindividually,usersanddeveloperscanbuildacompletebusinessstorythroughvisualizations.
Datacanbedisplayedatasummarylevelanduserscanthendrilldownandtakeactiononindividualrows.
Userscanusethebuilt-intoolstocreatethevisualizationsstartingfromscratchorfromthetemplatesthatareprovidedbytheISVorapartner.
Developerscancontinuefromwheretheusersstarted,ortheycancreatenewvisualizationsfromExtendingMicrosoftDynamicsCRM2013Page44of14011/09/2014scratch.
DeveloperscanalsousetheadditionaltoolsthatareprovidedbyMicrosoftBusinessInformationDevelopmentStudio(BIDS)toexperienceafamiliarMicrosoftVisualStudioeditingexperience.
Thereportingcapabilitiesincludethefollowing:DashboardsVisualizations(Charts)MicrosoftOfficeExcelSQLReportingServicesReportsDashboardsDashboardsareawaytoviewalotofdatafromanapplicationinasinglelocation.
Theyhelptheusersavetimefromhavingtovisitseveraldifferentlocationstoviewkeymetrics.
Dashboardscancontaindatafromseveralentities,andtheyshowsavedcharts,views,IFrames,andwebresourcesallinonescreen.
Therearetwotypesofdashboards:Systemdashboards-viewedbyallusers.
User-specificdashboards-tailoredbyausertohisorherspecifications.
DashboardsarebasedontheFormStorageModel(FormXml)andareincludedaspartofaSolutionpackage.
ThismeansthatISVscanincludeoneormoredashboardsaspartoftheirproducts.
CustomdashboardscancontainanddisplaydatathatusesthestandardxRMFrameworkvisualizationcharts,gridviewsofdatarecords,IFrames,andwebresourcessuchasSilverlightandHTML.
Eachdashboardcancontaindisplaysfromseveralsourcesandstillbeshowntogetherinasingleuserview.
Additionally,thedashboarditemscanbringtheirnativefunctionalitywiththem;chartsstillhavedrill-downabilityandgridscanstillbesortedorsearched.
Visualizations(Charts)Chartsanddashboardsprovideusersahigherlevelperspectiveoftheirbusinessdata.
Oneormorechartscanbedefinedandassociatedwithanentity.
Theyappearalongsideagridofentitydata,andthentheusersreceiveanin-contextvisualrepresentationofthegriddata.
MicrosoftDynamicsCRM2013providesabuilt-inChartdesignerusedtobuildcommonchartsinthegridarea.
Chartssupportmultiplelevelsofdrilldownintothedifferentsegmentsofdata.
Whentheuserdrillsdowntheviewshowninthegridisupdatedandheorshecanselectdifferentcharttypesthatareappropriateforthelowerlevelofdata.
UserscancreatenewchartvisualizationsfromtheViewRibbonandthenstarttheChartWizardtocustomizeandselectthetypeofcharttodisplay.
Chartscanbeimported,exportedandtheycanalsobesharedwithotherusersasawholewhenmadeaspartofasolution.
Developerscanfurthercustomizetheexportedcharttoperformformattingandotherchangesmoreadvancedthanthosesupportedinthewizard.
ThisincludesusingthefullsetofchartstylessupportedbytheASP.
Netchartingcontrolslibrary.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page45of140MicrosoftOfficeExcelAnotherreportingoptioninMicrosoftDynamicsCRMisMicrosoftOfficeExcel.
Userscanexporttostaticordynamicworksheetsandpivottables.
SQLReportingServicesReportsMicrosoftDynamicsCRMprovidesmanyout-of-boxreportsforviewingbusinessdata.
CustomreportscanbecreatedbyusingoneofthesereportsasatemplateandmodifyingitwithinBusinessIntelligenceDevelopmentStudioortheycanbecreatedfromscratchusingthebuilt-inReportWizardortheBusinessIntelligenceDevelopmentStudio.
TherearetwotypesofreportsinMicrosoftDynamicsCRM:SQL-basedThesereportsuseSQLqueriestosecurelyretrievedataforreportsfromfilteredviewsdefinedbythesystem.
Fetch-basedFetch-basedreportsuseFetchXMLqueriestoretrievedataforreports.
Customfetch-basedreportscanbedeployedtoMicrosoftDynamicsCRMOnlineandtoMicrosoftDynamicsCRM2013on-premiseorhosted.
AllreportsthatarecreatedusingtheReportWizardinMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnlineareFetch-basedreports.
ExtendingMicrosoftDynamicsCRM2013Page46of14011/09/2014Module4–ProcessesThekeyobjectivesofthismodulearetoprovideanunderstandingofthedifferentprocessinDynamicsCRM.
ObjectivesThekeyobjectivesofthismoduleareto:UnderstandprocesstypesWorkflowsDialogsBusinessProcessFlowsActionsLesson4-1DynamicsCRMProcessesBusinessProcessesDefiningandenforcingconsistentbusinessprocessesisoneofthemainreasonspeopleuseMicrosoftDynamicsCRM.
Processesareagroupoffeaturesthatyoucanusetodefineandenforceconsistentprocessesforyourorganisation.
Theseconsistentprocesseshelpmakesurepeopleusingthesystemcanfocusontheirworkandnotonrememberingtoperformasetofmanualsteps.
Processescanbesimpleorcomplexandcanchangeovertime.
Processesaredesignedtobeusedbypeoplewhoaren'tdevelopers.
Therulesthataredefinedinprocessescontainsimilarlogicthatadevelopermayapplyusingcode,butyoudon'tneedtocallinadevelopereachtimeyouwanttochangetherules.
However,youdoneedtohaveaclearunderstandingofthelogicintherulesandunderstandthecapabilitiesofeachtypeofprocess.
YoustillneedtoapplyprocessescarefullyandtesttheresultstomakesureyougetwhatyouwantBusinessprocessesarethereforeanimportantpartofanyenterprisesoftwareapplication.
Therearethreetypesofbusinessprocesses:Automated:Reliesonlyoncommunicationamongapplicationsbasedonasetofrules.
Interactive:Reliesonindividualstoinitiateandruntheprocessandmaketheappropriatedecisionsduringtherunningoftheprocess.
Combination:Acombinationofboththeautomatedandinteractiveprocesses.
WithMicrosoftDynamicsCRM2013,youcancreateandmanageyourautomatedandinteractiveprocesses.
Theentityusedtoimplementaprocessstillincludesworkflowsanddialogsandnowitincludesbusinessprocessflowsandactions.
MicrosoftDynamicsCRMoffersdevelopersawaytoextendandcustomizethestandardbehaviourofprocessesbydevelopingcustomcomponents.
TheMicrosoftDynamicsCRMprocessisbasedonExtendingMicrosoftDynamicsCRM201311/09/2014Page47of140theWindowsWorkflowFoundation(WWF)programmingmodel.
TheWWFprovidesaruntimeengine,framework,baselibraryofactivities,anddefaultimplementationsoftheruntimeservices.
TheWWFruntimeenginemanagesprocessexecution,andsupportsprocessesthatcanremainactiveforextendedperiodsoftime.
Italsopreservesthestateofprocessexecutionduringcomputershutdownandrestart.
ProcessesinDynamicsCRMTherearefourprocesstypesinDynamicsCRMWorkflowsDialogsBusinessProcessesFlows(GuidedBusinessProcesses)–newinCRM2013Actions–newinCRM2013Thefollowingtableprovidesanoverviewofwhentouseeachcategoryofprocess.
ProcesscategoryDescriptionWorkflowUseworkflowstoautomatebusinessprocessesbehindthescenes.
Workflowsaretypicallyinitiatedbysystemeventssotheuserdoesn'tneedtobeawarethattheyarerunning,buttheycanalsobeconfiguredforpeopletomanuallyinitiatethem.
Workflowscanoperateinthebackground(asynchronously)orinreal-time(synchronously).
Thesearereferredtoseparatelyasbackgroundworkflowsorreal-timeworkflows.
DialogsUsedialogstocreateauserinterfacethatwillguidepeoplethroughascriptforcustomerinteractionorawizardtoperformcomplexactionsconsistently.
BusinessProcessFlowsUsebusinessprocessflowstodefinethestepsinwhichpeopleshouldenterdatatoachieveanoutcome.
Businessprocessflowsaddacontroltothetopofaformthatshowpeoplewhatdatatheyneedtoentertomoveforwardtothenextstageandultimatelytocompletionofabusinessprocess.
Abusinessprocessflowcanspanmultipleentities.
ActionsUseactionstoexpandthevocabularyavailablefordeveloperstoexpressbusinessprocesses.
WithcoreverbslikeCreate,Update,Delete,andAssignprovidedbythesystem,anActionusesthosecoreverbstocreatemoreexpressiveverbslikeApprove,Escalate,Route,orSchedule.
Ifthedefinitionofabusinessprocesschanges,someonewhoisn'tadevelopercanedittheActionsothecodedoesn'tneedtobechanged.
ExtendingMicrosoftDynamicsCRM2013Page48of14011/09/2014Note:Businessprocessflowsaredifferentfromothertypesofprocesses.
AllprocessesusethesameunderlyingtechnologyandinformationaboutthemisstoredintheProcessentity.
BusinessprocessflowshaveadifferentconfigurationexperienceandbehaviourcomparedtoothertypesofprocessesProcessesandEntitiesandEventsProcessesareboundtoaspecificentitysetwhentheprocessiscreated.
Figure5-NewprocessformWhencreatinganewprocessyouspecifythename,processtype(category)andentity.
Oncesavedyoucannotchangetheentity,Processareinitiatedeitherautomaticallyormanually.
Thefollowingtabledescribestheeventsthatcantriggeraprocess.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page49of140EventProcesstypeDescriptionCreateWorkflow,BusinessProcessFlowCreationofarecordUpdateWorkflowUpdateofoneaselectionoffieldsforarecordDeleteWorkflowDeletionofarecordChangeStatusWorkflowChangeofstatecodeofarecordAssignWorkflowChangeofownershipofarecordOnDemandWorkflow,DialogUserinitiatestheprocessthroughtheRunWorkfloworRunDialogoptioninthecommendbarChildWorkflow,DialogProcessiscalledfromanotherprocessCustomActionExecutionoftheactionfromcodeLesson4-2DynamicsCRMProcessStepsProcessStepsProcessescancheckconditions,applybranchinglogic,andperformactions.
Theyperformtheseactionsinaseriesofsteps.
Businessprocessflowscontainstagesandcontroladvancementtostages,buttheydon'tprovideanyoftheothercapabilities.
Thefollowingtabledescribestheavailablestepsinworkflow,dialog,andactionprocesses.
StepProcesstypeDescriptionStageWorkflow,Dialog,ActionStagesmaketheworkflowlogiceasiertoread,andexplaintheworkflowlogic.
However,stagesdon'taffectthelogicorbehaviourofworkflows.
Ifaprocesshasstages,allthestepsExtendingMicrosoftDynamicsCRM2013Page50of14011/09/2014StepProcesstypeDescriptionintheprocessmustbecontainedwithastage.
CheckConditionWorkflow,Dialog,ActionAlogical"if-then"statement.
Youcancheckvaluesfortherecordthattheworkflowisrunningon,anyoftherecordslinkedtothatrecordinanN:1relationship,oranyrecordscreatedbyearliersteps.
Basedonthesevaluesyoucandefineadditionalstepswhentheconditionistrue.
ConditionalBranchWorkflow,Dialog,ActionAlogical"else-if-then"statement,theeditorusesthetext"Otherwise,ifthen:"Selectacheckconditionyouhavepreviouslydefinedandyoucanaddaconditionalbranchtodefineadditionalstepswhenthecheckconditionreturnsfalse.
DefaultActionWorkflow,Dialog,ActionAlogical"else"statement.
theeditorusesthetext"Otherwise:"Selectacheckcondition,conditionalbranch,waitcondition,orparallelwaitbranchthatyouhavepreviouslydefinedandyoucanuseadefaultactiontodefinestepsforallcasesthatdon'tmatchthecriteriadefinedinconditionorbranchelements.
WaitConditionBackgroundWorkflowOnlyEnablesabackgroundworkflowExtendingMicrosoftDynamicsCRM201311/09/2014Page51of140StepProcesstypeDescriptiontopauseitselfuntilthecriteriadefinedbytheconditionhavebeenmet.
Theworkflowstartsagainautomaticallywhenthecriteriainthewaitconditionhavebeenmet.
ParallelWaitBranchBackgroundWorkflowOnlyDefinesanalternativewaitconditionforabackgroundworkflowwithacorrespondingsetofadditionalstepsthatareperformedonlywhentheinitialcriterionismet.
Youcanuseparallelwaitbranchestocreatetimelimitsinyourworkflowlogic.
Theyhelppreventtheworkflowfromwaitingindefinitelyuntilthecriteriadefinedinawaitconditionhavebeenmet.
AssignValueDialog,ActionSetsavaluetoavariableoroutputparameterintheprocess.
CreateRecordWorkflow,Dialog,ActionCreatesanewrecordforanentityandassignsvaluestoattributes.
UpdateRecordWorkflow,Dialog,ActionYoucanupdatetherecordthattheworkflowisrunningon,anyoftherecordslinkedtothatrecordinanN:1relationship,oranyrecordscreatedbyearliersteps.
AssignRecordWorkflow,Dialog,ActionYoucanassigntherecordthattheworkflowisrunningon,anyoftherecordslinkedtothatrecordwithanN:1relationship,oranyrecordscreatedbyearliersteps.
ExtendingMicrosoftDynamicsCRM2013Page52of14011/09/2014StepProcesstypeDescriptionSendEmailWorkflow,Dialog,ActionSendsanemail.
YoucanchoosetocreateanewemailmessageoruseanemailtemplateconfiguredfortheentityoftherecordthattheworkflowisrunningonoranyentitiesthathaveanN:1relationshipwiththeentity,ortheentityforanyrecordscreatedbyearliersteps.
StartChildWorkflowWorkflow,Dialog,ActionStartsaworkflowprocessthathasbeenconfiguredasachildworkflow.
ChangeStatusWorkflow,Dialog,ActionChangesthestatusoftherecordthattheprocessisrunningon,anyoftherecordslinkedtothatrecordwithanN:1relationship,oranyrecordscreatedbyearliersteps.
StopWorkflow/StopDialogWorkflow,Dialog,ActionStopsthecurrentworkflow,dialog,oraction.
YoucansetastatusofeitherSucceededorCanceledandspecifyastatusmessage.
PageDialogAcontainerforpromptandresponsestepsinadialog.
PromptandResponseDialogDisplaysapromptinadialogpageandmayprovideafieldtocapturedatafromaresponse.
QueryCRMDataDialogDefinesaquerythatreturnsdatatoprovideoptionsforaresponseinapromptandresponsestepofadialog.
LinkChildDialogDialogStartsadialogprocessthathasbeenconfiguredasachilddialog.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page53of140StepProcesstypeDescriptionCustomStepWorkflow,Dialog,ActionProvidesextensionstothelogicalelementsavailablebydefaultinCRM.
Stepscanincludeconditions,actions,othersteps,oracombinationoftheseelements.
Developerscancreatecustomworkflowsteps.
Bydefault,therearenocustomstepsavailableinCRM.
Customworkflowactivitiesarecoveredinthenextmodule.
Lesson4-3WorkflowsWorkflowsWorkflowsautomatebusinessprocesseswithoutauserinterface.
Peopleusuallyuseworkflowprocessestoinitiateautomationthatdoesn'trequireanyuserinteraction.
Eachworkflowprocessisassociatedwithasingleentity.
Whenconfiguringworkflowsyouhavefourmajorareastoconsider:WhentostartthemShouldtheyrunasareal-timeworkfloworabackgroundworkflowWhatactionsshouldtheyperformUnderwhatconditionsactionsshouldbeperformedUsethisprocesstomodelandautomaterealworldbusinessprocesses.
Theseprocessescanbeconfiguredtoruninthebackgroundorinrealtime.
Workflowprocessescanstartautomaticallybasedonspecifiedconditionsorcanbestartedmanuallybyauser.
Workflowsconsistofconditions(IfthenElseandWait)andactions(Createrecord,updaterecord,sendemail,assignrecord).
Workflowsaretriggeredby(some)changes(creationofarecord,assigningofarecordtoauser,changeofstatus,updatingofafield)todata.
Workscanberunmanually(on-demand).
WorkflowsWorkflowsrunontheCRMserverExtendingMicrosoftDynamicsCRM2013Page54of14011/09/2014WorkflowPropertiesFigure6-WorkflowDesignerPropertyDescriptionActivateAsYoucanchooseProcesstemplatetocreateanadvancedstartingpointforotherworkflow.
Ifyouchoosethisoption,afteryouactivatetheworkflowitwillnotbeappliedbutinsteaditwillbeavailabletoselectintheCreateProcessdialogifyouselectType:Newprocessfromanexistingtemplate(selectfromlist)ProcesstemplatesareconvenientwhenyouhaveanumberofsimilarworkflowprocessesandwanttodefinethemwithoutduplicatingthesamelogicRunthisWorkflowinthebackground(recommended)Thischeckboxreflectstheoptionyouselectedwhenyoucreatedtheworkflow.
Thisoptionisdisabled,butyoucanchangeitfromtheActionsmenubychoosingeitherConverttoareal-timeworkfloworConverttoabackgroundworkflow.
Asanon-demandChoosethisoptionifyouwanttoallowuserstorunthisworkflowfromtheExtendingMicrosoftDynamicsCRM201311/09/2014Page55of140PropertyDescriptionprocessRunWorkflowcommandAsachildprocessChoosethisoptionifyouwanttoallowtheworkflowtobeavailabletobestartedfromanotherworkflowordialog.
ScopeForuser-ownedentities,optionsareOrganization,Parent:ChildBusinessUnits,BusinessUnit,orUser.
ForOrganization-ownedentitiestheonlyoptionisOrganization.
IfscopeisOrganization,thentheworkflowlogiccanbeappliedtoanyrecordintheorganization.
Otherwise,theworkflowcanonlybeappliedtoasubsetofrecordsthatfallwithinthescope.
Note:ThedefaultscopevalueisUser.
Makesureyouverifythatthescopevalueisappropriatebeforeyouactivatetheworkflow.
StartWhenUsetheoptionsinthissectiontospecifywhenaworkflowshouldstartautomatically.
Youcanconfigureareal-timeworkflowtoberunbeforecertainevents.
Thisisaverypowerfulcapabilitybecausetheworkflowcanstoptheactionbeforeitoccurs.
Theoptionsare:RecordiscreatedRecordstatuschangesRecordisassignedRecordfieldschangeRecordisdeletedExecuteAsThisoptionisonlyavailableifyouunselectedtheRunthisworkflowinthebackground(recommended)optionwhenyoucreatedtheworkfloworifyoulaterconvertedabackgroundworkflowtobeareal-timeworkflowRealTimeWorkflowsInCRM2011workflowprocessesalwaysraninthebackgroundrequiringausertoreloadtheformtoseetheendresultoftheworkflow.
CRM2013hasintroducedtheoptionforprocessestorunimmediatelyandupdatetheforminrealtime.
Youcanconfigurereal-timeworkflowsbutyoushouldusethemwithcare.
Backgroundworkflowsaregenerallyrecommendedbecausetheyallowthesystemtoapplythemasresourcesontheserverareavailable.
Thishelpssmoothouttheworktheserverhastodoandhelpmaintainthebestperformanceforeveryoneusingthesystem.
Thedrawbackisthatactionsdefinedbybackgroundworkflowsarenotimmediate.
Youcan'tpredictwhentheywillbeapplied,butgenerallyitwilltakeaExtendingMicrosoftDynamicsCRM2013Page56of14011/09/2014fewminutes.
Formostautomationofbusinessprocessesthisisfinebecausepeopleusingthesystemdon'tneedtobeconsciouslyawarethattheprocessisrunning.
Usereal-timeworkflowswhenabusinessprocessrequiressomeonetoimmediatelyseetheresultsoftheprocessorifyouwanttheabilitytocancelanoperation.
Forexample,youmaywanttosetcertaindefaultvaluesforarecordthefirsttimeitissaved,oryouwanttomakesurethatsomerecordsarenotdeleted.
Youcanchangeareal-timeworkflowintoabackgroundworkflowbychoosingConverttoabackgroundworkflowonthetoolbar.
Youcanchangeabackgroundworkflowintoareal-timeworkflowbychoosingConverttoareal-timeworkflowonthetoolbar.
Ifthebackgroundworkflowusesawaitconditionsitwillbecomeinvalidandyouwon'tbeabletoactivateituntilyouremovethewaitcondition.
WhenyouconfigureOptionsforAutomaticProcessesforreal-timeworkflows,theStartWhenoptionsforthestatuschangeseventletyouselectAfterorBeforeforwhenstatuschanges.
ThedefaultoptionisAfter.
WhenyouselectBeforeyouaresayingthatyouwantthelogicintheworkflowtobeappliedbeforedatachangingthestatusissaved.
Thisprovidesyouwiththeabilitytocheckthevaluesbeforeotherlogichasbeenappliedaftertheoperationandpreventfurtherlogicfrombeingperformed.
Forexample,youmayhaveadditionallogicinapluginorcustomworkflowactionwhichcouldinitiateactionsonanothersystem.
Bystoppingfurtherprocessingyoucanavoidcaseswhereexternalsystemsareaffected.
Applyingreal-timeworkflowsbeforethiseventalsomeansthatotherworkfloworplug-inactionsinMicrosoftDynamicsCRMthatmayhavesaveddatadon'tneedtobe"rolledback"whentheoperationiscancelled.
WhenyouapplyaStopWorkflowactioninaworkflowyouhavetheoptiontospecifyastatusconditionthatcanbeeitherSucceededorCanceled.
Whenyousetthestatustocanceled,youpreventtheoperation.
AnerrormessagecontainingthetextfromthestopactionstatusmessagewillbedisplayedtotheuserwiththeheadingBusinessProcessError.
SecurityContextWhenabackgroundworkflowisconfiguredasanon-demandprocessandisstartedbyauserusingtheRunWorkflowcommand,theactionsthattheworkflowcanperformarelimitedtothosetheusercouldperformbasedontheprivilegesandaccesslevelsdefinedbythesecurityrole(s)setfortheiruseraccount.
Whenabackgroundworkflowstartsbasedonaneventtheworkflowoperatesinthecontextofthepersonwhoownsit,usuallythepersonwhocreatedtheworkflow.
Forreal-timeworkflowsyouhavetheExecuteAsoptionandyoucanchoosewhethertheworkflowshouldapplythesecuritycontextoftheowneroftheworkflowortheuserwhomadechangestotherecord.
Ifyourworkflowincludesactionswhichalluserswouldnotbeabletoperformbasedonsecurityconstraints,youshouldchoosetohavetheworkflowrunastheowneroftheworkflow.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page57of140Lesson4-4DialogsDialogsUsethisprocesstocreateaninteractivestep-by-stepdataentryformthatrequiresuserinputtostartandruntocompletion.
Whenyoustartthedialogprocess,awizard-likeinterfaceispresentedsoyoucanmakeappropriateselectionsorenterdataasyouprogressthrougheachpageofthewizard.
Dialogsarewizardsthatallowyoutocollectinputfromauserandthencreateorupdaterecords.
Theyareparticularlyusefulininitialdatacapture.
DialogsconsistofPageswithoneormorePrompt/Responsestocaptureuserinput.
Figure7-DialogpageDialogsprovide:Consistentcustomerinteractionsandinteractiveusertasks.
Consistentinformationentryintoyourorganization'sdatabase.
Awayforpeopleinyourorganizationtofocusongrowingyourbusiness,insteadofperformingrepetitivetasks.
Dialogssharemanyoftheconditionsandactionswithworkflows.
Unlikeworkflowprocesses,dialogsdonothavescope.
Theyareavailabletotheentireorganization.
Ifauserrunsadialogthatcreatesorupdatesrecord,theusermusthaveprivilegestoperformthoseactionsoutsidethedialog.
EachdialogwillcreateaDialogsessionrecordandtheusermusthaveprivilegestocreateandupdatethoserecordsExtendingMicrosoftDynamicsCRM2013Page58of14011/09/2014Unlikeworkflowprocesses,adialogcanonlybeappliedtoonerecordatatime.
DialogPropertiesFigure8-DialogDesignerPropertyDescriptionActivateAsYoucanchooseProcesstemplatetocreateanadvancedstartingpointforotherDialogs.
Ifyouchoosethisoption,afteryouactivatetheDialogitwillnotbeappliedbutinsteaditwillbeavailabletoselectintheCreateProcessdialogifyouselectType:Newprocessfromanexistingtemplate(selectfromlist)ProcesstemplatesareconvenientwhenyouhaveanumberofsimilardialogprocessesandwanttodefinethemwithoutduplicatingthesamelogicAsanon-demandprocessChoosethisoptionifyouwanttoallowuserstorunthisworkflowfromtheRunWorkflowcommandAsachildChoosethisoptionifyouwanttoallowtheworkflowtobeavailabletobestartedExtendingMicrosoftDynamicsCRM201311/09/2014Page59of140PropertyDescriptionprocessfromanotherworkflowordialog.
InputArgumentsUnlikeworkflows,dialogscanhaveinputargumentsthatallowonedialogprocesstopassvaluestoachilddialogprocess.
IfyouattempttoenterInputargumentsforaprocessconfiguredasanon-demandprocess,youwillbepromptedtochangetheAvailabletoRunvaluetoAsaChildprocess.
AfteryouenterInputarguments,youwillnotbeabletosettheprocesstobeanon-demandprocessuntilalltheinputargumentshavebeenremoved.
Inputargumentscanbeofthefollowingtypes:SingleLineofTextWholeNumberFloatingPointNumberDateandTimeDateOnlyLookupWitheachtype,youcansetadefaultvaluetobeusedifthecallingdialogdoesn'tprovidedatatotheinputargument.
VariablesUnlikeworkflows,dialogscanhavevariablesthatcanbesetusingtheAssignValuestep.
Variablesareusefulwhenaprocessgathersdatathroughthecourseofseveralpagesandthisdatamaybeusedtoperformcalculations.
Forexample,adialogmightbeusedtocalculateastandardratingvaluebasedontheanswerstoseveralquestions.
PromptandResponseAPromptandResponsestephasthefollowingproperties:PropertyDescriptionStatementLabelThestatementlabelshouldprovideanappropriateheadingforthePromptText.
TheStatementLabelisvisibleinthedialogsessionwhenviewingthesummaryduringorafterthedialogiscompleted.
PromptTextPromptTextmayrepresentsomethingthepersonusingthedialogshouldsaytothecustomeroritcouldincludeinstructionsabouthowtocompleteastepofacomplexprocedure.
ExtendingMicrosoftDynamicsCRM2013Page60of14011/09/2014PropertyDescriptionTipTextTiptextprovidesadditionalinformationtosupportthePromptText.
ResponseTypeChooseoneofthefollowingResponseTypes:None-apromptwithoutaresponse.
SingleLine-Asinglelinecanrepresentatext,integerorfloatdatabysettingtheDataType.
OptionSet(RadioButtons)TheresultsarepresentedasasetofRadiobuttons.
Usethisoptionwhentherearejustasmallnumberofoptionstochoosefrom.
Thedataselectedcanbesettotext,integerorfloatdatabysettingtheDataType.
YoucanchoosetodefinestaticvaluesorqueryCRMDatatoprovidealistofoptions.
OptionsSet(Picklist)-ThisisexactlylikeOptionSet(RadioButtons),exceptthattheoptionsaredisplayedasalist.
MultipleLines(TextOnly)-Providesanareatotypetextwithmultiplelines.
DateandTime-providesacontroltosetadateandatime.
DateOnly-Providesacontroltosetadate.
Lookup-Thisoptionwillpresentoneofthelookupfieldsusedintheapplication.
DataTypeWhenyouselectaResponseTypeofSingleLine,OptionSet(radiobuttons),orOptionSet(picklist),youcanchoosetohavethedatasetinthecontrolbeexpressedusingoneofthefollowingdatatypes:TextIntegerFloatWhenyouselectaResponseTypeofLookup,theDataTypefieldisreplacedbytheReferenceEntityfield.
LogResponseWhenyouchoosetonotlogresponsesyouwillstillbeabletoaccesstheresponsesasvariableswithinyourdialog,butthedataintheresponsewillnotbesavedwiththedialogsession.
Thisisasecurityfeature.
Considerifyouhaveadialogthatrequiressomepersonalinformationtobeenteredandprocessed.
IftheresponseisnotloggeditwillnotbesavedwiththedialogsessionrecordthatcontainsthedatainthedialogsummaryExtendingMicrosoftDynamicsCRM201311/09/2014Page61of140PropertyDescriptionDefaultValueUsedefaultvaluetosetavaluetoindicatethatthedataintheresponsewasnotprovidedorrepresentsaverycommonresponsewhichwouldonlyneedtobeeditedifitwasdifferent.
Lesson4-5BusinessProcessFlowsBusinessProcessFlowsUsethisprocesstocreateavisualisationofthebusinessprocessflow.
Usersareguidedthroughvariousstagesofthesalesorcustomerserviceprocesses.
Ateachstage,youcompletespecificstepsandthenmovetothenextstage.
Youcancustomizetheprocessflowbyaddingorremovingsteps,changingtheorderstages,oraddingnewentitiestotheprocessflow.
Multipleprocessescanbeaddedtoeachrecordtype-thinksalesprocessforinsidesalesvs.
outsidesales.
Asalesorganizationcanmakesureeachrequiredstepineachpipelinephaseiscompletedbeforemovingtothenextpipelinephase.
WhatcanbusinessprocessflowsdoWithbusinessprocessflows,youdefineasetofstagesandstepsthatarethendisplayedinacontrolatthetopoftheform.
Asauseryouwillseeaprocessbaratthetopofthescreenformanyoftherecordtypes.
Withbusinessprocesses,eachstageforworkingwithacustomerisclearlyoutlined.
Stepstocompleteyourworkareeasytofollow.
Figure9-ProcessFlowEachstagecontainsagroupofsteps.
Eachsteprepresentsafieldwheredatacanbeentered.
PeopleadvancetothenextstagebyusingtheNextStagebutton.
Youcanmakeasteprequiredsothatpeoplemustenterdataforthecorrespondingfieldbeforetheycanproceedtothenextstage.
Thisiscommonlycalled"stage-gating".
Businessprocessflowsappearrelativelysimplecomparedtoothertypesofprocessesbecausetheydonotprovideanyconditionalbusinesslogicorautomationbeyondprovidingthestreamlinedexperiencefordataentryandcontrollingentryintostages.
However,whenyoucombinethemwithotherprocessesandcustomizations,theycanplayanimportantroleinsavingpeopletime,reducingtrainingcosts,andincreasinguseradoption.
ExtendingMicrosoftDynamicsCRM2013Page62of14011/09/2014SystembusinessprocessflowsMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnlineincludethreebusinessprocessflows:LeadtoOpportunitySalesProcessOpportunitySalesProcessPhonetoCaseProcessMultipleentitiesinbusinessprocessflowsYoucanuseabusinessprocessflowforasingleentityorspanmultipleentities.
Forexample,youmayhaveaprocessthatbeginswithanopportunity,thencontinuestoaquote,anorder,andthenaninvoice,beforefinallyreturningtoclosetheopportunity.
YoucandesignbusinessprocessflowsthattietogethertherecordsforuptofivedifferententitiesintoasingleprocesssothatpeopleusingMicrosoftCRMcanfocusontheflowoftheirprocessratherthanonwhichentitytheyareworkingin.
Theycanmoreeasilynavigatebetweenrelatedentityrecords.
Figure10-ProcessflowovermultipleentitiesMultiplebusinessprocessflowsareavailableperentityNoteveryuserinanorganizationmayfollowthesameprocessanddifferentconditionsmayrequirethatadifferentprocessbeapplied.
Youcanhaveupto10activebusinessprocessflowsperentitytoprovideappropriateprocessesfordifferentsituations.
ControlwhichbusinessprocessflowwillbeappliedYoucanassociatebusinessprocessflowswithsecurityrolessothatonlypeoplewiththosesecurityrolescanseeorusethem.
Youcanalsosettheorderofthebusinessprocessflowssothatyoucancontrolwhichbusinessprocessflowwillbesetbydefault.
Thisworksinthesamewaythatmultipleformsforanentityaredefined.
Whensomeonecreatesanewentityrecord,thelistofavailableactivatedbusinessprocessflowsiscomparedtothebusinessprocessesflowsthattheperson'ssecurityrolewillshowthem.
Thefirstactivatedbusinessprocessflowinthatlististheonethatwillbeappliedbydefault.
Ifmorethanoneactivebusinessprocessflowisavailable,peoplecanchoseSwitchProcessfromthecommandbartoapplyadifferentprocess.
Wheneversomeoneswitchesprocesses,thecurrentprocessstagewillbesettothefirststageofthenewlyappliedbusinessprocessflow.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page63of140Eachrecordcanhaveonlyonebusinessprocessflowatatime.
Whenanyuserappliesadifferentprocess,thatprocessistheonethatthenextusertoviewtherecordwillsee.
Ifsomeone'ssecurityrolesdonotallowthemtouseaspecificbusinessprocessflow,thecurrentbusinessprocessflowwillbevisible,butdisabled.
BusinessprocessflowlimitationsYoucandefinebusinessprocessflowsonlyforthoseentitiesthatsupportthem.
Toensureacceptableperformanceandtheusabilityoftheuserinterface,therearesomelimitationsyouneedtobeawareofwhenyouplantousebusinessprocessflows:Therecanbenomorethan10activatedbusinessprocessflowprocessesperentity.
Eachprocesscancontainnomorethan30stages.
Multi-entityprocessescancontainnomorethanfiveentitiesBusinessProcessFlowPropertiesFigure11-BusinessProcessFlowDesignerExtendingMicrosoftDynamicsCRM2013Page64of14011/09/2014BusinessprocessflowsintegratedwithothercustomizationsWhenyouoryouruserentersdatausingbusinessprocessflows,thedatachangesarealsoappliedtoformfieldssothatanyautomationprovidedbybusinessrulesorformscriptscanbeappliedimmediately.
StepscanbeaddedthatsetvaluesforfieldsthatarenotpresentintheformandthesefieldswillbeaddedtotheXrm.
Pageobjectmodelusedforformscripts.
Anyworkflowsthatareinitiatedbychangestofieldsincludedinabusinessprocessflowwillbeappliedwhenthedataintheformissaved.
Iftheautomationisappliedbyareal-timeworkflow,thechangeswillbeimmediatelyvisibletotheuserwhenthedataintheformisrefreshedaftertherecordissaved.
Althoughthebusinessprocessflowcontrolintheformdoesnotprovideanydirectclient-sideprogrammability,changesappliedbybusinessrulesorformscriptsareautomaticallyappliedtobusinessprocessflowcontrols.
Ifyouhideafieldinaform,thatfieldwillalsobehiddeninthebusinessprocessflowcontrol.
Ifyousetavaluebyusingbusinessrulesorformscripts,thatvaluewillbesetwithinthebusinessprocessflow.
Lesson4-6ActionsActionsUsethisprocesstocreateanewoperationthatisnotavailableinastockMicrosoftDynamicsCRMinstallationortocombinemultipledisparateoperationsintoasingleoperation.
Forexample,inthecaseofasupportcallcentre,youcouldcombinecreate,assign,andsetstateoperationsintoasinglenew"escalate"operation.
Thisprovidesanintuitivewaytowritesimplecodethatwasotherwisereservedforsomeonewithdevelopment/codingexperience.
WhyuseactionsActionsopenarangeofpossibilitiesfordevelopersandpeoplewhocomposebusinesslogic.
BeforeActions,theprimarywaythatdeveloperscouldimplementbusinessprocesseswaslimitedtoplug-insorcustomworkflows.
Withthese,developerscanperformoperationscomposedofverbslikeCreate,Update,Delete,Assign,andSetStatus.
Eachofthesemessagesisbasedonactionstakenonanentityinstance.
Soifthegoalofaprocessistocreatearecord,thenupdateit,thenassignit,therearethreeseparatesteps.
Eachstepisdefinedbythecapabilitiesoftheentity–notnecessarilyyourbusinessprocess.
Actionsprovidetheabilitytodefineasingleverb(ormessage)thatmatchesanoperationyouneedtoperformforyourbusiness.
Thesenewmessagesaredrivenbyaprocessorbehaviourratherthanwhatcanbedonewithanentity.
ThesemessagescancorrespondtoverbslikeEscalate,Convert,Schedule,Route,orApprove–whateveryouneed.
Theadditionoftheseverbshelpsprovidearichervocabularyforyoutofluentlydefineyourbusinessprocesses.
Youcanapplythisrichervocabularyfromclientsorintegrationsratherthanhavingtowritetheactionwithinclients.
Thisalsomakesiteasierbecauseyoucanmanageandlogthesuccessorfailureoftheentireactionasasingleunit.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page65of140Effectlively,Developerscanaddnew"messages"totheCRMEventPipeline.
ConfigurablemessagesOnceanactionisdefinedandactivated,adevelopercanusethatmessagelikeanyoftheothermessagesprovidedbytheMicrosoftDynamicsCRMplatform.
However,asignificantdifferenceisthatnowsomeonewhoisnotadevelopercanapplychangestowhatshouldbedonewhenthatmessageisused.
Youcanconfiguretheactiontomodifystepsasyourbusinessprocesseschange.
Anycustomcodethatusesthatmessagedoesnotneedtobechangedaslongastheprocessargumentsdonotchange.
Workflowprocessesandpluginscontinuetoprovidesimilarcapabilitiesfordefiningautomation.
Workflowprocessesstillprovidethecapabilityforanon-developertoapplychanges.
Butthedifferenceisinhowthebusinessprocessesarecomposedandhowadevelopercanwritetheircode.
AnactionisamessagethatoperatesonthesamelevelasanyofthemessagesprovidedbytheMicrosoftDynamicsCRMPlatform.
DeveloperscanevencreatepluginsforActions.
GlobalmessagesUnlikeworkflowprocessesorplugins,anactiondoesn'thavetobeassociatedwithaspecificentity.
Youcandefine"global"Actionsthatcanbecalledontheirown.
ActionslimitationsForMicrosoftDynamicsCRM2013,Actionscanbecalledonlyfromcode.
Youcan'tcallanactionfromaworkfloworotherprocess.
SofornowthemostcommonwaystoinvokeActionswillbe:Fromcodethatexecuteswithinapluginorcustomworkflow.
FromacommandthatisplacedintheapplicationandexecutestheoperationusingJavaScriptcode.
FromanintegrationwithanothersystemthatusestheMicrosoftDynamicsCRMwebservices.
FromacustomclientapplicationthatusestheMicrosoftDynamicsCRMwebservices.
ConfigureactionsYoumayneedtocreateanactionsothatadeveloperwilluseitincodeoryoumayneedtoeditanactionthatwaspreviouslydefined.
Likeworkflowprocesses,considerthefollowing:WhatactionsshouldtheyperformUnderwhatconditionsactionsshouldbeperformedUnlikeworkflowprocesses,youdon'tneedtosetthefollowingoptions:StartWhen:Actionsstartwhencodecallsthemessagegeneratedforthem.
ExtendingMicrosoftDynamicsCRM2013Page66of14011/09/2014Scope:Actionsalwaysruninthecontextofthecallinguser.
Runinthebackground:Actionsarealwaysreal-timeworkflows.
Anactionalsohassomethingthatworkflowprocessesdon'thave–inputandoutputarguments.
ActionPropertiesFigure12-ActionDesignerPropertyDescriptionActivateAsYoucanchooseProcesstemplatetocreateanadvancedstartingpointforotherActions.
Ifyouchoosethisoption,afteryouactivatetheActionitwillnotbeappliedbutinsteaditwillbeavailabletoselectintheCreateProcessdialogifyouselectType:Newprocessfromanexistingtemplate(selectfromlist)ProcesstemplatesareconvenientwhenyouhaveanumberofsimilaractionprocessesExtendingMicrosoftDynamicsCRM201311/09/2014Page67of140PropertyDescriptionandwanttodefinethemwithoutduplicatingthesamelogicIntransactionGenerally,processesthatsupporttransactionswill"undo"(orrollback)theentireoperationifanypartofthemfails.
Therearesomeexceptionstothis.
Someactionsdevelopersmightdoincodeinitiatedbytheactionmightnotsupporttransactions.
Forexample,ifthecodeperformactionsinothersystemsthatarebeyondthescopeofthetransaction.
Thosecan'tberolledbackbytheactionrunninginMicrosoftDynamicsCRM.
SomemessagesintheCRMplatformdon'tsupporttransactions.
Buteverythingyoucandojustwiththeuserinterfaceoftheactionwillsupporttransactions.
Alltheactionsthatarepartofareal-timeworkflowareconsideredintransaction,butwithactionsyouhavetheoptiontooptoutofthis.
Youshouldconsultwiththedeveloperwhowillusethismessagetodeterminewhetheritmustbeintransactionornot.
Generally,anactionshouldbeintransactioniftheactionsperformedbythebusinessprocessdon'tmakesenseunlessallofthemarecompletedsuccessfully.
Theclassicexampleistransferringfundsbetweentwobankaccounts.
Ifyouwithdrawfundsfromoneaccountyoumustdepositthemintheother.
Ifeitherfails,bothmustfail.
ProcessArgumentsWhenadeveloperusesamessagetheymaybeginwithsomedatathattheycanpassintothemessageanduse.
Forexample,ifyouwanttocreateanewcaserecord,youmayhavethecasetitlevaluethatwillbepassedinasanargument.
Thiswouldbeaninputargument.
Whenthemessageisfinishedthedevelopermayneedtopasssomedatathatwaschangedorgeneratedbythemessagetoanotheroperationintheircode.
Thesemustbedefinedasanoutputargument.
Bothinputandoutputargumentsmusthaveaname,atype,andsomeinformationaboutwhethertheargumentisalwaysrequired.
Youcanalsoprovideadescription.
Thenameofthemessageandtheinformationaboutalltheprocessargumentsrepresentthe"signature"forthemessage.
Afteranactionisactivatedanditisbeingusedincode,thesignaturemustnotchange.
Changingthissignaturewillcauseanycodethatusesthemessagetofail.
Theonlyexceptiontothismaybechangingoneoftheparameterssothatitisnotalwaysrequired.
Changingtheorderoftheargumentsbysortingthemormovingthemupordowndoesn'tmakeadifferencebecausetheargumentsareidentifiedbyname,notbytheorder.
Changingthedescriptionwillnotbreakcodeusingthemessage.
Thefollowingtabledescribestheactionprocessargumenttypes.
ExtendingMicrosoftDynamicsCRM2013Page68of14011/09/2014TypeDescriptionBooleanAtrueorfalsevalue.
DateTimeAvaluethatstoresdateandtimeinformation.
DecimalAnumbervaluewithdecimalprecision.
Usedwhenprecisionisextremelyimportant.
EntityACRMrecordforthespecifiedentity.
WhenyouselectEntity,thedrop-downisenabledandallowsyoutoselecttheentitytype.
EntityCollectionAcollectionofentityrecords.
EntityReferenceAnobjectthatcontainsthename,id,andtypeofanentityrecordthatuniquelyidentifiesit.
WhenyouselectEntityReference,thedrop-downisenabledandallowsyoutoselecttheentitytype.
FloatAnumbervaluewithdecimalprecision.
Usedwhendatacomesfromameasurementthatisn'tabsolutelyprecise.
IntegerAwholenumber.
MoneyAvaluethatstoresdataaboutanamountofmoney.
PicklistAvaluethatrepresentsanoptionforanOptionSetattribute.
StringAtextvalue.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page69of140Module5–ServerSideCodeThekeyobjectivesofthismodulearetoprovideanunderstandingofthedifferenttypesofserversidecodethatcanbeusedinDynamicsCRM.
ObjectivesThekeyobjectivesofthismoduleareto:UnderstandPluginsUnderstandCustomWorkflowActivitiesWhentouseDebuggingLesson5-1PluginsOverviewThefunctionalityofmostMicrosoftDynamicsCRMeventscanbeextendedbywritingcustomplug-ins.
Aplug-inisacustombusinesslogicthatcanintegratewithMicrosoftDynamicsCRM2013tomodifyoraugmentstandardbehaviouroftheplatform.
Plug-inssubscribetoasetofeventsandrunwhentheseeventsoccur.
Pluginscanruncodebothbeforeaneventperformsitsoperationsandafteraneventcompletesitsoperations.
Pluginsareimplementedincodeheldinacustomassembly.
Theseeventsoccurregardlessofthemethodthatisusedtoperformtheactivitysotheyareindependentoftheuserinterface.
RegistrationofpluginsisperformedthroughcustomcodethatusesclassesavailableintheSDK.
TheSDKprovidesatooltoassistwithplug-inregistration.
BasicsPluginshavemanyuses.
Thisincludesthefollowing:PerformingcomplexplatformleveldatavalidationPerformingauto-numbergenerationProvidingintegrationwithotherapplicationsExecutingcomplexbusinesslogicAnynumberofplug-inscanbeassociatedwithagivenentityandevent.
Whenmultiplepluginsareregisteredforthesameeventonthesameentity,theyarecalledinasequencebasedontheorderspecifiedonthestepregistration.
ThisvalueisspecifiedastheRankanditissuppliedwhentheplug-inisregistered.
Thisallowsdevelopercontroloverthesequence.
ExtendingMicrosoftDynamicsCRM2013Page70of14011/09/2014Plug-inscanbewritteninanyMicrosoft.
NET4.
0CLR-compliantlanguagei.
e.
,MicrosoftVisualC#andMicrosoftVisualBasic.
NET.
AuthenticationPlug-insnotexecutedbythesandboxorasynchronousserviceexecuteunderthesecuritycontextoftheMicrosoftDynamicsCRMapplicationpool,CrmAppPool,asdefinedinInternetInformationServices.
Bydefault,CrmAppPoolusestheNetworkSecurityaccountidentity.
Therefore,itisimportanttosetcredentialscorrectly.
Manytimes,itmightbenecessarytoimpersonatetheuserwhoseactionscausedtheplug-intorun.
Lesson5-2EventFrameworkEventFrameworkTheeventframeworkisthetermthatisusedtodescribethetechnologyandmechanismsavailableinMicrosoftDynamicsCRMtoextendorcustomizefunctionalitywithcustombusinesslogic.
TheeventframeworkenablesyoutocreaterichverticalandhorizontalsolutionsontopofMicrosoftDynamicsCRMbysupportingthedevelopmentandintegrationofcustombusinesslogicwithMicrosoftDynamicsCRMinareliableandportableway.
AfteryourcustombusinesslogichasbeenintegratedintoMicrosoftDynamicsCRM,itcanbeexecutedsynchronouslyaspartofthemainMicrosoftDynamicsCRMexecutionpath,orasynchronouslyfromamanagedqueue.
Businessdatacanbepassedtoyourcustomcode,whichcanthenperformactionsbasedonthenatureoftheinformation,ormodifytheinformationitself.
TheEventFrameworkprovidesthefollowingkeyfeatures:Animprovedeventprocessingsubsystem.
Thissubsystemprovidesaunifiedmethodofexecutingbothplug-insandworkflowactivities,whichresultsinimprovedreliability,anenhancedfeatureset,andplug-inportability.
AneventframeworkAPIforextendingtheMicrosoftDynamicsCRMplatformthroughthedevelopmentofcustombusinesslogicintheformofplug-insandworkflowactivities.
AnAPIforthedeploymentofplug-insandcustomworkflowactivitiestotheMicrosoftDynamicsCRMdatabase.
Deploymentofplug-insandworkflowactivitiestothedatabaseenablesautomaticdistributionofyourplug-insandcustomworkflowactivitiestoserversrunningMicrosoftDynamicsCRMservicesthroughoutadatacenter.
BackwardscompatibilityforMicrosoftDynamicsCRM2011plug-ins.
Synchronousandasynchronousexecutionofplug-ins.
Synchronousplug-insareexecutedinapre-definedorderaspartofthemainMicrosoftDynamicsCRMeventprocessing.
Asynchronousplug-insarequeuedandexecutedindependently.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page71of140ArchitectureTheMicrosoftDynamicsCRMeventprocessingsubsystemexecutesplug-insbasedonamessagepipelineexecutionmodel.
AmessageissenttotheorganizationWebservicewhenthere'sanSDKmethodcallbyaplug-inorotherapplication.
Themessagecontainsbusinessentityinformationandcoreoperationinformation.
Themessageispassedthroughtheeventexecutionpipelinewhereitcanbereadormodifiedbytheplatformcoreoperationandanyregisteredplug-ins.
ThefollowingfigureillustratestheoverallarchitecturethatMicrosoftDynamicsCRMplatformwithrespecttosynchronousandasynchronousprocessing.
Figure13-EventExecutionPipelineTheeventexecutionpipelinecanprocesseventssynchronouslyorasynchronously.
Theplatformcoreoperationandanyplug-insregisteredforsynchronousexecutionareexecutedimmediately.
Synchronousplug-insregisteredfortheeventareexecutedinawell-definedorder.
ExtendingMicrosoftDynamicsCRM2013Page72of14011/09/2014Plug-insregisteredforasynchronousexecutionarequeuedwiththeasynchronousserviceandexecutedinthefuture.
PipelineStagesTheeventpipelineisdividedintomultiplestageswithfourofthemavailabletoregistercustomdevelopedplug-ins.
Multipleplug-insthatareregisteredineachstagecanbefurtherorderedorrankedinthatstageduringtheplug-inregistration.
Anyparticularplug-inregisteredcanresideinonlyoneparticularstage.
Thismeansthatifaplug-inhastooperateinmultiplestagesithastoberegisteredonetimeforeachstage.
EventStagenameStagenumberDescriptionPre-EventPre-validation10Stageinthepipelineforplug-insthataretoexecutebeforethemainsystemoperation.
Plug-insregisteredinthisstagemayexecuteoutsidethedatabasetransaction.
Pre-EventPre-operation20Stageinthepipelineforplug-insthataretoexecutebeforethemainsystemoperation.
Plug-insregisteredinthisstageareexecutedwithinthedatabasetransaction.
PlatformCoreOperationMainOperation30In-transactionmainoperationofthesystem,suchascreate,update,delete,andsoon.
Nocustomplug-inscanberegisteredinthisstage.
Forinternaluseonly.
Post-EventPost-operation40Stageinthepipelineforplug-inswhicharetoexecuteafterthemainoperation.
Plug-insregisteredinthisstageareexecutedwithinthedatabasetransaction.
Lesson5-3PluginIsolation,TrustsandStatisticsIsolationMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnlinesupporttheexecutionofplug-insandcustomworkflowactivitiesinanisolatedenvironment.
Inthisisolatedenvironment,alsoknownasasandbox,aplug-inorcustomactivitycanmakeuseofthefullpoweroftheMicrosoftDynamicsCRMSDKtoaccesstheorganizationwebservice.
Accesstothefilesystem,systemeventlog,certainnetworkprotocols,registry,andmoreispreventedinthesandbox.
However,sandboxplug-insandcustomactivitiesdohaveaccesstoexternalendpointsliketheWindowsAzurecloudservice.
MicrosoftDynamicsCRMcollectsrun-timestatisticsandmonitorsplug-insandcustomworkflowactivitiesthatexecuteinthesandbox.
IfthesandboxworkerprocessthathoststhiscustomcodeexceedsthresholdCPU,memory,orhandlelimitsorisotherwiseunresponsive,thatprocesswillbekilledbytheplatform.
Atthatpointanycurrentlyexecutingplug-inorcustomworkflowactivityinthatworkerprocesswillfailwithexceptions.
However,thenexttimethattheplug-inorcustomExtendingMicrosoftDynamicsCRM201311/09/2014Page73of140workflowactivityisexecuteditwillrunnormally.
Thereisoneworkerprocessperorganizationsofailuresinoneorganizationwillnotaffectanotherorganization.
Insummary,thesandboxistherecommendedexecutionenvironmentforplug-insasitismoresecure,supportsrun-timemonitoringandstatisticsreporting,andissupportedonallMicrosoftDynamicsCRMdeployments.
Inaddition,MicrosoftDynamicsCRMOnlineonlysupportsexecutionofpluginsandcustomworkflowactivitiesiftheyareregisteredinthesandbox.
TrustsDevelopershavetheoptionofregisteringtheirplug-insinthesandbox,knownaspartialtrust,oroutsidethesandbox,knownasfulltrust.
Fulltrustissupportedforon-premisesandInternet-facingMicrosoftDynamicsCRMdeployments.
ForaMicrosoftDynamicsCRMOnlinedeployment,plug-insorcustomworkflowactivitiesmustberegisteredinthesandbox(partialtrust)wheretheyareisolatedaspreviouslydescribed.
Run-timestatisticsTheMicrosoftDynamicsCRMplatformcollectsrun-timeinformationaboutplug-insandcustomworkflowactivitiesthatexecuteinthesandbox.
ThisinformationisstoredinthedatabaseusingPluginTypeStatisticentityrecords.
Theserecordsarepopulatedwithin30minutestoonehourafterthesandboxedcustomcodeexecutes.
SeethePluginTypeStatisticattributestofindoutwhatinformationiscollected.
Youcanretrievethisinformationbyusingtheretrievemessageormethod.
AccessSandboxedplug-insandcustomworkflowactivitiescanaccessthenetworkthroughtheHTTPandHTTPSprotocols.
Thiscapabilityprovidessupportforaccessingpopularwebresourceslikesocialsites,newsfeeds,webservices,andmore.
Thefollowingwebaccessrestrictionsapplytothissandboxcapability.
OnlytheHTTPandHTTPSprotocolsareallowed.
Accesstolocalhost(loopback)isnotpermitted.
IPaddressescannotbeused.
YoumustuseanamedwebaddressthatrequiresDNSnameresolution.
Anonymousauthenticationissupportedandrecommended.
ThereisnoprovisionforpromptingtheloggedonuserforcredentialsorsavingthosecredentialsLesson5-4DevelopingPluginsIPluginInterfacePlug-insarecustomclassesthatimplementtheIPlugininterface.
Youcanwriteaplug-ininany.
NETFramework4CLR-compliantlanguagesuchasMicrosoftVisualC#andMicrosoftVisualBasic.
NET.
ExtendingMicrosoftDynamicsCRM2013Page74of14011/09/2014TheIServiceProviderparameteroftheExecutemethodisacontainerforseveralserviceusefulobjectsthatcanbeaccessedwithinaplug-in.
Theserviceprovidercontainsinstancereferencestotheexecutioncontext,IOrganizationServiceFactory,ITracingService,andmoreContextTheexecutioncontextcontainsawealthofinformationthatdescribestherun-timeenvironmentthattheplug-inisexecutingin,informationrelatedtotheexecutionpipeline,andentitybusinessinformation.
Whenasystemeventisfiredforwhichaplug-inisregistered,thesystemcreatesandpopulatesthecontextandpassesittoaplug-inthroughtheproceedingsamplethatmentionsclassesandmethods.
Theexecutioncontextispassedtoeachregisteredplug-ininapipelinewhentheyareexecuted.
Eachplug-inintheexecutionpipelinecanmodifywritablepropertiesinthecontext.
Forexample,givenaplug-inregisteredforapre-event,anotherforaplug-inregisteredforapost-event,thepost-eventplug-incanreceiveacontextthathasbeenmodifiedbythepre-eventplug-in.
Thesamesituationappliestoplug-insthatregisteredinthesamestage.
AllthepropertiesintheiPlug-inexecutioncontextarereadonly.
However,plug-inscanmodifythecontentsofthesepropertiesthatarecollections.
Theinputparameterspropertycontainsthedatathatisintherequestmessagecurrentlybeingprocessedbytheeventexecutionpipeline.
Plug-incodecanaccessthisdata.
Thepropertiesisatypeparametercollectionwherethekeystotheaccessthatrequesteddataarethenamesoftheactualpublicpropertiesintherequest.
Forexample,ifthecreaterequestmethodisused,onepropertyofthatrequestisnamed"target,"whichisofthetypeentity.
Thisistheentitycurrentlybeingoperatedonbytheplatform.
Toaccessthedataoftheentity,usethename"target"asthekeyintheinputparameterscollection.
Itisnecessarytocastthereturnedinstance.
Similarly,theoutputparameterspropertycontainsthedatathatisintheresponsemessage,suchasa"create"responsecurrentlybeingpassedthroughtheeventexecutionpipeline.
However,onlysynchronouspost-eventandasynchronousregisteredplug-inshaveoutputparameterspopulatedbecausetheresponseistheresultofthecoreplatformoperation.
Note:Ifaplug-inisregisteredasapre-event,theoutputparameterspropertybagdoesnotcontainavaluefortheIDkeybecausethecoreoperationhasnotyetoccurred.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page75of140AssembliesRequiredTobeabletocompileplug-incode,youmustaddMicrosoft.
Xrm.
Sdk.
dllandMicrosoft.
Crm.
Sdk.
Proxy.
dllassemblyreferencestoyourproject.
TheseassembliescanbefoundintheSDK\BinfolderoftheSDK.
AutoSaveYourplug-indesignshouldtakeintoaccountawebformfeatureknownasauto-save.
Inthewebapplicationentityforms,thereisnoSavebutton.
TheMicrosoftDynamicsCRMwebapplicationautomaticallysaveschangeddataintheformwhenneeded.
Dependingonhowyouregisteredyourplug-in,thismayresultinyourplug-inbeingcalledveryfrequentlyforindividualfieldchangesinsteadofoneplug-inoneplug-ininvocationforallchanges.
Theauto-savefeatureonlyappliestowebformsforcontact,opportunity,leads,account,andcaseentities.
Itisabestpracticetoregisteryourplug-inorcustomworkflowactivitiesonentitiesandspecificfieldsthatmattermost.
Ifyoucanavoidit,donotregisteryourplug-inforchangestoallentityfields.
AssemblyVersioningandSolutionsPlug-inassembliescanbeversionedusinganumberformatofMajor.
Minor.
Build.
RevisiondefinedintheAssembly.
infofileoftheMicrosoftVisualStudio2010project.
Dependingonwhatpartoftheassemblyversionnumberischangedinanewersolution,thefollowingbehaviourapplieswhenanexistingsolutionisupdatedthroughimport.
Thebuildorrevisionassemblyversionnumberischanged.
Thisisconsideredanin-placeupgrade.
Theolderversionoftheassemblyisremovedwhenthesolutioncontainingtheupdatedassemblyisimported.
Anypre-existingstepsfromtheoldersolutionareautomaticallychangedtorefertothenewerversionoftheassembly.
Themajororminorassemblyversionnumber,exceptforthebuildorrevisionnumbers,ischanged.
Whenanupdatedsolutioncontainingtherevisedassemblyisimported,theassemblyisconsideredacompletelydifferentassemblythanthepreviousversionofthatassemblyintheexistingsolution.
Plug-inregistrationstepsintheexistingsolutionwillcontinuetorefertothepreviousversionoftheassembly.
Ifyouwantexistingplug-inregistrationstepsforthepreviousassemblytopointtotherevisedassembly,youwillneedtousethePlug-inRegistrationtooltomanuallychangethestepconfigurationtorefertotherevisedassemblytype.
Thisshouldbedonebeforeexportingtheupdatedassemblyintoasolutionforlaterimport.
ExtendingMicrosoftDynamicsCRM2013Page76of14011/09/2014Lesson5-5DeployingPluginsandImpersonationSigningAssembliesAllplug-inassembliesmustbesignedbeforetheycanberegisteredinMicrosoftDynamicsCRM2013StoragePlug-insnotregisteredinthesandboxcanbestoredintheMicrosoftDynamicsCRMserver'sdatabaseortheon-diskfilesystem.
Itisstronglyrecommendedtostoreproduction-readyplug-insintheMicrosoftDynamicsCRMdatabase,insteadofon-disk.
Plug-insstoredinthedatabaseareautomaticallydistributedacrossmultipleMicrosoftDynamicsCRMserversinadatacentreclusterandareincludedindatabasebackupsandredeployments.
On-diskstorageofplug-insisusefulfordebuggingplug-insusingMicrosoftVisualStudio.
Plug-insregisteredinthesandboxmustbestoredinthedatabase.
Foron-premiseorInternet-FacingMicrosoftDynamicsCRMinstallations,whendeployingplug-inson-disk,theplug-inassemblymustbemanuallycopiedtotheserverbeforeregistration.
Theassemblymustbedeployedtothefollowingfolder:\ProgramFiles\MicrosoftCRM\server\bin\assemblyImpersonationImpersonationisusedtoexecutebusinesslogiconbehalfofaMicrosoftDynamicsCRMsystemusertoprovidedesiredfeatureorserviceforthatuser.
ImpersonationDuringRegistrationOnemethodtoimpersonateasystemuserinaplug-inisbyspecifyingtheimpersonateduserduringplug-inregistration.
Whenregisteringaplug-inprogrammatically,iftheImpersonatingUserIdpropertyofSdkMessageProcessingStepissettoaspecificMicrosoftDynamicsCRMsystemuser,webservicecallsmadebytheplug-inexecuteonbehalfoftheimpersonateduser.
IfImpersonatingUserIdissettoavalueofnullorGuid.
Emptyduringplug-inregistration,theinitiatinguserorthestandard"system"useristheimpersonateduser.
Whetherthecalling/loggedonuseror"system"userisusedforimpersonationisdependentontherequestbeingprocessedbythepipelineImpersonationDuringExecutionImpersonationthatisdefinedduringplug-inregistrationcanbealteredinaplug-inatruntime.
Evenifimpersonationwasnotdefinedatplug-inregistration,plug-incodecanstilluseimpersonation.
TheplatformpassestheimpersonateduserIDtoaplug-inatruntimethroughtheUserIdproperty.
ThispropertycanhaveoneofthreedifferentvaluesasshowninthetablebelowExtendingMicrosoftDynamicsCRM201311/09/2014Page77of140UserIdValueConditionInitiatinguseror"system"userTheSdkMessageProcessingStep.
ImpersonatingUserIdattributeissettonullorGuid.
Emptyatplug-inregistration.
ImpersonateduserTheImpersonatingUserIdpropertyissettoavalidsystemuserIDatplug-inregistration.
"system"userThecurrentpipelinewasexecutedbytheplatform,notindirectresponsetoaservicemethodcall.
Anotheroptionistoimpersonatetheuserwhoseactionsinitiatedtheplug-inexecution.
ThiscanbedonebyusingtheInitiatingUserIdpropertyTheInitiatingUserIdpropertyoftheexecutioncontextcontainstheIDofthesystemuserthatcalledtheservicemethodthatultimatelycausedtheplug-intoexecute.
StepsEachpluginrequiresatleastonestep.
Astepdefines:Message(Event)EntityImpersonationRankStageSynchronousorAsynchronousAvailabilityinOutlookOfflineFigure14-RegisterPluginStepExtendingMicrosoftDynamicsCRM2013Page78of14011/09/2014ConfigurationSecureConfigurationandUnsecureConfigurationcanbeusedtoholdconfigurationinformationthataplugincanreferencesuchas:usernamesandpasswordsforothersystemsURLtowebservicesXMLconfigurationdataTheplugincanaccessthisinformationatruntime.
Thisyoucanwritegenericpluginsorpluginsthatneedtocallaccessdifferentservicese.
g.
differentURLsforDEV,TESTandPRODUnsecureinformationisaccessiblethroughtheUserInterfaceunderSolutions.
Secureinformationisaccessiblethroughaseparateprivilege.
PreandpostentityimagesAstepcanhavePreandPostentityimagesspecifiedPreEntityImagesandPostEntityImagescontainsnapshotsoftheprimaryentity'sattributesbefore(pre)andafter(post)thecoreplatformoperation.
MicrosoftDynamicsCRMpopulatesthepre-entityandpost-entityimagesbasedonthesecurityprivilegesoftheimpersonatedsystemuser.
Onlyentityattributesthataresettoavalueornullareavailableinthepreorpostentityimages.
YoucanspecifytohavetheplatformpopulatethesePreEntityImagesandPostEntityImagespropertieswhenyouregisteryourplug-in.
Theentityaliasvalueyouspecifyduringplug-inregistrationisusedasthekeyintotheimagecollectioninyourplug-incode.
Therearesomeeventswhereimagesarenotavailable.
Forexample,onlysynchronouspost-eventandasynchronousregisteredplug-inshavePostEntityImagespopulated.
Thecreateoperationdoesnotsupportapre-imageandadeleteoperationdoesnotsupportapost-image.
Inaddition,onlyasmallsubsetofmessagessupportpreandpostimagesasshowninthefollowingtableMessageRequestPropertyDescriptionAssignRequestTargetTheassignedentity.
CreateRequestTargetThecreatedentity.
DeleteRequestTargetThedeletedentity.
DeliverIncomingEmailRequestEmailIdThedeliveredemailID.
DeliverPromoteEmailRequestEmailIdThedeliveredemailID.
ExecuteWorkflowRequestTargetTheworkflowentity.
MergeRequestTargetTheparententity,intowhichthedatafromthechildentityisbeingmerged.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page79of140MergeRequestSubordinateIdThechildentitythatisbeingmergedintotheparententity.
SendEmailRequestEmailIdThesententityID.
SetStateRequestEntityMonikerTheentityforwhichthestateisset.
UpdateRequestTargetTheupdatedentityRegisteringforpreorpostimagestoaccessentityattributevaluesresultsinimprovedplug-inperformanceascomparedtoobtainingentityattributesinplug-incodethroughRetrieveRequestorRetrieveMultipleRequestrequests.
PluginRegistrationPlugins,StepsandImagesmustberegisteredinDynamicsCRM.
ThereareSDKcallsforyoutobuildyourowncodetoregisteryourplugin.
However,thereareeasiertoolsintheSDK.
PluginRegistrationToolThePlug-inRegistrationtoolprovidesagraphicaluserinterfaceandsupportsregisteringpluginsandcustomworkflowactivitieswithMicrosoftDynamicsCRM.
However,plug-insandcustomworkflowactivitiescanonlyberegisteredinthesandbox(isolationmode)ofMicrosoftDynamicsCRMOnline.
ThetoolcanbeaddedtotheVisualStudioToolsmenuasanexternaltooltospeedupthedevelopmentprocess.
DeveloperToolkitIfusingtheDevelpoertoolkit,youcanregisterapluginfromwithinVisualStudiousingDeployoptionontheCrmPackage.
Lesson5-6DebuggingPluginsDebuggingStepsToeffectivelytroubleshooterrors,itisimportanttoknowhowtoappropriatelydebugplug-ins.
Registeranddeploytheplug-inassemblyIfthereisanothercopyoftheassemblyatthesamelocationandyoucannotoverwritethatcopybecauseitislockedbyMicrosoftDynamicsCRM,youmustrestarttheserviceprocessthatwasexecutingtheplug-in.
Refertothetablebelowforthecorrectserviceprocess.
Copythesymbolfile(.
pdb)ofthecompiledplug-inassemblytotheserver\bin\assemblyfolderontheCRMserver.
ExtendingMicrosoftDynamicsCRM2013Page80of14011/09/2014ConfigurethedebuggerAttachthedebuggertotheprocessontheMicrosoftDynamicsCRMserverthatwillrunyourplug-in.
Refertothefollowingtabletoidentifytheprocess.
Plug-inRegistrationConfigurationServiceProcessFullTrustw3wp.
exeOutlookClientOfflineMicrosoft.
Crm.
Application.
Hoster.
exeasynchronousregisteredplug-ins(orcustomworkflowassemblies)CrmAsyncService.
exesandbox(isolationmode)Microsoft.
Crm.
Sandbox.
WorkerProcess.
exeIftherearemultipleprocessesrunningthesameexecutablefile,forexamplemultiplew3wp.
exeprocesses,attachthedebuggertoallinstancesoftherunningexecutableprocess.
Next,setoneormorebreakpointsinyourplug-incode.
Testtheplug-inRuntheMicrosoftDynamicsCRMapplication,orothercustomapplicationthatusestheSDK,andperformwhateveractionisrequiredtocausetheplug-intoexecute.
Forexample,ifaplug-inisregisteredforanaccountcreationevent,createanewaccount.
Debugyourplug-incodeMakeanyneededchangestoyourcodesothatitperformsasyouwant.
Ifthecodeischanged,compilethecodeintoanassemblyandrepeatsteps1through4inthisprocedureasnecessary.
However,ifyouchangetheplug-inassembly'smajororminorversionnumbers,youmustunregistertheearlierversionoftheassemblyandregisterthenewversion.
Registertheplug-ininthedatabaseAftertheedit/compile/deploy/test/debugcycleforyourplug-inhasbeencompleted,unregisterthe(on-disk)plug-inassemblyandthenreregistertheplug-inintheMicrosoftDynamicsCRMdatabaseDebugginginthesandboxItisimportanttoperformthesestepsbeforethefirstexecutionofasandboxedplug-in.
Iftheplug-inhasalreadybeenexecuted,eitherchangethecodeoftheassembly,causingthehashoftheassemblytochangeontheserver,orrestarttheMicrosoftDynamicsCRMSandboxProcessingServiceonthesandboxserver.
ConfiguretheServerThesandboxhostprocessmonitorsthesandboxworkerprocesswhichisexecutingtheplug-in.
Thehostprocesschecksiftheplug-instopsresponding,ifitisexceedingmemorythresholds,andmore.
Iftheworkerprocessdoesn'trespondforthan30seconds,itwillbeshutdown.
InordertodebugaExtendingMicrosoftDynamicsCRM201311/09/2014Page81of140sandboxplug-in,youmustdisablethisshutdownfeature.
Todisabletheshutdownfeature,setthefollowingregistrykeyto1(DWORD):HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM\SandboxDebugPluginsRegisteranddeploytheplug-inassemblyRegistertheplug-ininthesandbox(isolationmode)anddeployittotheMicrosoftDynamicsCRMserverdatabase.
Copythesymbolfile(.
pdb)ofthecompiledplug-inassemblytotheserver\bin\assemblyfolderontheserverrunningthesandboxworkerprocessnamedMicrosoft.
Crm.
Sandbox.
WorkerProcess.
exe.
ThisistheserverhostingtheSandboxProcessingServicerole.
Followtheinstructionsinstepsabovetodebugtheplugin.
ErrorHandlingForsynchronousplug-ins,theMicrosoftDynamicsCRMplatformhandlesexceptionspassedbacktotheplatformbydisplayinganerrormessageinadialogofthewebapplicationuserinterface.
Forasynchronousplug-ins,theexceptionmessageiswrittentoaSystemJob(AsyncOperation)record.
Forplug-insnotregisteredinthesandbox,theexceptionmessage(System.
Exception.
Message)isalsowrittentotheApplicationeventlogontheserverthatrunstheplug-in.
TheeventlogcanbeviewedbyusingtheEventViewerAdministrativeTool.
BecausetheApplicationeventlogisnotavailabletosandboxedplug-ins,sandboxedplug-insshouldusetracing.
Optionally,theplug-incandisplayacustomerrormessageinthewebapplicationbyhavingitthrowanInvalidPluginExecutionExceptionexceptionwiththecustommessageastheMessagepropertyvalue.
LoggingandtracingAnalternativemethodtodebugaplug-inistousetracing.
Tracingassistsdevelopersintroubleshootingplug-insbyprovidingrun-timeplug-ininformationasanaidindiagnosingthecauseofplug-infailure.
TracingisespeciallyusefultodebugMicrosoftDynamicsCRMOnlineregisteredplug-insasitistheonlysupporteddebuggingmethodforthatscenario.
ThetracingdiscussedhereisdifferentfromASP.
NETtracing.
TracingisimplementedintheMicrosoftDynamicsCRMSDKthroughtheuseofthetracingserviceITracingService.
DevelopersaddTracestatementstotheirplug-incode,thenbuildanddeploytheplug-in.
Duringexecutionandonlywhenthatplug-inpassesanexceptionbacktotheplatformatrun-time,tracinginformationisdisplayedtotheuser.
Forasynchronousregisteredplug-in,thetracinginformationisdisplayedinadialogboxoftheMicrosoftDynamicsCRMwebapplication.
Foranasynchronousregisteredplug-in,thetracinginformationisshownintheDetailsareaoftheSystemJobforminthewebapplication.
Theamountandnatureofthisinformationisuptoyouasadevelopertocodeintoyourplug-ins.
Themainreasonforimplementingthistypeoftracingistosupporttheisolated(sandboxed)plug-inandcustomworkflowactivitiescapabilityinMicrosoftDynamicsCRM.
SandboxedcustomcodeisExtendingMicrosoftDynamicsCRM2013Page82of14011/09/2014notabletowriteinformationtothesystemeventlogorthefilesystem.
Thetracingservicewasimplementedtoprovidesandboxedplug-insandcustomworkflowactivitieswithameanstooutputrun-timeinformationwhenanexceptionisthrown.
Inaddition,tracingisalsosupportedinplug-insthatarenotsandboxed.
Animportantdesignfeatureoftracingisthatthetracinginformationisonlymadeavailablewhenanexceptionispassedfromtheplug-inorcustomworkflowactivitybacktotheplatform.
Whentheerrordialogboxisdisplayedinthewebapplication,theusermustclicktheDownloadLogFilebuttontoviewthelogcontainingexceptionandtraceoutput.
Ifanexceptionisnotthrownoriscaughtbytheplug-in/customactivitycode,anytracinginformationgeneratedbyyourcustomcodeislost.
Analternateapproachistocreateacustomentitytotrackanyrun-timeplug-ininformationthatyouwanttorecord.
Whentheplug-inexecutes,havetheplug-instoreitsexceptioninformationinarecordofthecustomentity.
Inthisway,youareloggingyourrun-timeplug-ininformationtotheMicrosoftDynamicsCRMdatabase.
Thismethodworksforanyplug-inregardlessofhowitisregistered.
However,iftheplug-inexecuteswithinthedatabasetransactionandanexceptionoccursthatcausesatransactionrollback,anyentitydatachangesbytheplug-inwillbeundone.
Lesson5-7CustomWorkflowActivitiesOverviewAdevelopercancreatecustomcodewhichcanacceptinformationfromaworkflowordialog,processit,andsendinformationbacktoit.
MicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnlinesupportstheregistrationandexecutionofcustomworkflowactivitiesinadditiontotheout-of-boxactivitiesprovidedbyWindowsWorkflowFoundation.
WindowsWorkflowFoundationincludesanactivitylibrarythatprovidesactivitiesforcontrolflow,sendingandreceivingmessages,doingworkinparallel,andmore.
However,tobuildapplicationsthatsatisfyyourbusinessneeds,youmayneedactivitiesthatperformtasksspecifictothatapplication.
Tomakethispossible,WindowsWorkflowFoundationsupportsthecreationofcustomworkflowactivities.
YoucanwritecustomworkflowactivitiesinMicrosoftVisualC#orMicrosoftVisualBasic.
NETcodebycreatinganassemblythatcontainsoneormoreclassesderivedfromtheWindowsWorkflowFoundationCodeActivityclass.
Thisassemblyisannotatedwith.
NETattributestoprovidethemetadatathatMicrosoftDynamicsCRMusesatruntimetolinkyourcodetotheworkflowengine.
Customworkflowactivitiesaresupportedforworkflowsanddialogs(processes)whenbuiltusingWindowsWorkflowFoundation4.
CustomworkflowactivitiescreatedbyusingWindowsWorkflowFoundation3.
5canonlybeusedwithworkflows(notdialogs)inMicrosoftDynamicsCRM2013(on-premisesandIFD),andonlywhennotregisteredinthesandbox(isolationmode).
Ifyouwanttouseyourcustomworkflowactivitieswithbothworkflowsanddialogs,youmustuseWindowsWorkflowFoundation4tocreatethecustomworkflowactivities,orupdateyouroldercustomactivitiescodetoworkwithWindowsWorkflowFoundation4.
Inaddition,toregisterExtendingMicrosoftDynamicsCRM201311/09/2014Page83of140customworkflowactivitiesinthesandbox(partialtrust),yourcustomworkflowactivitiesmustbebuiltusingMicrosoft.
NETFramework4PU3(platformupdate3)or.
NET4.
5.
CodeActivityTocreateacustomworkflowactivity,createaclassthatinheritsfromtheCodeActivityworkflowbaseclass.
ThisclassisavailableintheSystem.
Activitiesnamespace.
YouwillneedtoaddareferencetoSystem.
Activitiesinyourproject.
ActivitiesthatinheritfromtheCodeActivityclasscanoverridetheExecutemethodtoproducecustomfunctionality.
ContextAswithPlugins,theexecutioncontextisavailablethatcontainsawealthofinformationthatdescribestherun-timeenvironmentthatthecustomassemblyisexecutingin.
AssembliesRequiredCustomworkflowassembliesrequiretheMicrosoft.
Xrm.
Sdk.
Workflow.
dllassemblyreferenceaswellastheMicrosoft.
Xrm.
Sdk.
dllandMicrosoft.
Crm.
Sdk.
Proxy.
dllassemblyreferencestobeaddedyourproject.
TheseassembliescanbefoundintheSDK\BinfolderoftheSDK.
YouwillalsoneedtoaddareferencetoSystem.
Acitivities.
ParametersAcustomworkflowassemblycanincludeinputandoutputparametersthatareacceptedbythecode,processed,andthenpassedasavaluebacktotheworkflow.
Thisallowstheworkflowordialogtousethatreturnedoutputwithintherestoftheworkflowbeingprocessed.
DataTypesTheMicrosoftDynamicsCRMtypesarefoundintheMicrosoft.
Xrm.
Sdknamespace.
UsetheInputAttributeandOutputAttributeclassestospecifyinputandoutputproperties.
Thefollowingtypesaresupportedforcustomworkflowactivities:BoolDateTimeDecimalDoubleEntityReferenceIntMoneyOptionSetValueStringExtendingMicrosoftDynamicsCRM2013Page84of14011/09/2014ApartfromtheInput,Output,andDefaultattributes,someofthesupportedMicrosoftDynamicsCRMtypesinthecustomworkflowactivitiesrequireyoutospecifyadditionalattributessuchasReferenceTargetandAttributeTarget.
InputParameterThefollowingsampleshowshowtoaddtheinputattributetoaMoneyparameterusedinacustomworkflowactivity.
Italsoshowshowtospecifyadefaultvaluefortheproperty.
[Input("Moneyinput")][Default("232.
3")]publicInArgumentMoneyParameter{get;set;}OutputParameterThefollowingsampleshowshowtoaddtheoutputattributetoaMoneyparameterusedinacustomworkflowactivity.
Italsoshowshowtospecifyadefaultvaluefortheproperty.
[Output("Moneyoutput")]publicOutArgumentMoneyParameter{get;set;}InputandOutputParameterThefollowingsampleshowshowtoaddtheinputandoutputattributestoaMoneyparameterusedinacustomworkflowactivity.
Italsoshowshowtospecifyadefaultvaluefortheproperty.
[Input("Moneyinput")][Output("Moneyoutput")][Default("232.
3")]publicInOutArgumentMoneyParameter{get;set;}DefaultAttributeYoucanusetheDefaultAttributeclasstospecifyadefaultvalueforaninputparameter.
ThefollowingexamplesshowhowtosetthedefaultvaluefordifferenttypesusingtheDefaultattribute.
[Input("Boolinput")][Default("True")]publicInArgumentBool{get;set;}and[Input("Intinput")][Default("2322")]publicInArgumentInt{get;set;}andforanOptionSetReferenceTargetAttributeTheEntityReferenceattributetyperequiresyoutospecifytheentitytypebeingreferencedusingtheReferenceTargetAttributeclass.
ThefollowingsampleshowshowtoaddtheinputattributetoanAccountReferenceparameterinacustomworkflowactivitybyusingtheReferenceTargetattribute.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page85of140[Input("EntityReferenceinput")][ReferenceTarget("account")][Default("3B036E3E-94F9-DE11-B508-00155DBA2902","account")]publicInArgumentAccountReference{get;set;}AttributeTargetAttributeTheOptionSetValueattributetyperequiresyoutospecifytheentityandtheattributebeingreferencedusingtheAttributeTargetAttributeclass.
ThefollowingsampleshowshowtoaddtheinputandoutputattributestoanOptionSetValueparameterinacustomworkflowactivitybyusingtheAttributeTargetattribute.
[Input("OptionSetValueinput")][AttributeTarget("account","industrycode")][Default("3")]publicInArgumentOptionSetValue{get;set;}RequiredArgumentAttributeYoucanusetheSystem.
Activities.
RequiredArgumentAttributeclasstospecifythataninputparameterisrequired.
[Input("UpdateNextBirthdatefor")][RequiredArgument][ReferenceTarget("contact")]publicInArgumentContact{get;set;}DeployingAfteryouhavecreatedanassemblythatcontainsoneormorecustomworkflowactivities,youregisterthisassemblywithMicrosoftDynamicsCRM.
Thisprocessissimilartoregisteringaplug-in.
ThecustomworkflowactivitycanthenbeincorporatedintoaworkflowordialogintheProcessforminMicrosoftDynamicsCRM.
DebuggingTodebugacustomworkflowactivity,copythe.
pdbfilefortheassemblytothe%installdir%\server\bin\assemblyfolder.
Theassemblycanbedeployedason-diskorstoredinthedatabase.
Therecommendeddeploymentisinthedatabase,butfordebuggingyoushouldchooseon-disk.
Next,attachthedebuggertotheCrmAsyncService.
exeprocess.
Makesurethatyouremovethe.
pdbfilewhenyouhavefinisheddebuggingbecauseitusesmemorytohaveitloaded.
ExtendingMicrosoftDynamicsCRM2013Page86of14011/09/2014Lesson5-8DeclarativeWorkflowsOverviewMicrosoftDynamicsCRM2013on-premisedeploymentsletuserscreatecustomXAMLworkflows.
CustomXAMLworkflows,alsocalleddeclarativeworkflows,allowdeveloperstheabilitytoharnessthepowerofWindowsWorkflowFoundationtocreatereusableworkflowsforMicrosoftDynamicsCRM.
UsingtheMicrosoftVisualStudioWorkflowDesigner,workflowscanbecreatedormodifiedbydraggingworkflowactivitiesfromthetoolboxontothedesignsurface,createvariables,andsetpropertiesoftheseactivitiestoimplementtheworkflow'sfunctionality.
Workflowcreatorscanusebuilt-inWindowsWorkflowFoundationactivitiesortheprocessactivitiesthatarespecifictoMicrosoftDynamicsCRM.
Additionally,throughdeclarativeworkflows,logicsuchaswhileloopscanbeincorporatedintoaMicrosoftDynamicsCRMworkflowlogicflowwherethenativeMicrosoftDynamicsWorkflowsdonotenabledesignerstodothisthroughtheinterface.
PrerequisitesforworkingwithcustomXAMLworkflowsYoumustuseMicrosoftVisualStudiotodevelopcustomXAMLworkflowsforMicrosoftDynamicsCRM.
ToworkwiththeXAMLworkflowsthatarecreatedormodifiedoutsideofMicrosoftDynamicsCRM,makesurethat:YouruseraccounthastheDeploymentAdministratorprivilegeinMicrosoftDynamicsCRM.
DeclarativeworkflowsareenabledontheMicrosoftDynamicsCRMserver.
Bydefaulttheyarenotenabled.
YoucanuseWindowsPowerShelltoenableordisableXAMLworkflows.
EnableXAMLworkflowsOpenaWindowsPowerShellcommandwindow.
Add-PSSnapinMicrosoft.
Crm.
PowerShell$setting=get-crmsettingcustomcodesettings$setting.
AllowDeclarativeWorkflows="True"set-crmsetting$settingDisableXAMLworkflowsOpenaWindowsPowerShellcommandwindow.
Add-PSSnapinMicrosoft.
Crm.
PowerShell$setting=get-crmsettingcustomcodesettings$setting.
AllowDeclarativeWorkflows=0set-crmsetting$settingExtendingMicrosoftDynamicsCRM201311/09/2014Page87of140UsingtheVisualStudioWorkflowDesignerUsingtheVisualStudioWorkflowDesigner,youcandothefollowing:Visuallycreateworkflowswithouthavingtowritecode.
YoucancreateaworkflowprojectinVisualStudiobyusingthebuilt-inVisualStudioActivityLibrarytemplate,andthenuseaWorkflowactivityastherootactivity.
AddtheMicrosoftDynamicsCRMworkflowactivitiesinthetoolbox.
Afteraworkflowprojectiscreated,youcanaddactivitiestotherootactivity.
Moveactivitiesinaworkflow.
Someactivities,forexample,theSequenceactivity,cancontainmultiplechildactivities.
Youcancreatevariablestoholdvaluesandreferencesthatareimportanttoyourworkflowbyusingthevariablesdesigner.
Modifypre-existingworkflows.
Inthiscase,workflowsmustfirstbeexportedfromMicrosoftDynamicsCRM,andcanbemodifiedinVisualStudiobeforebeingimportedbackintoMicrosoftDynamicsCRM.
Lesson5-9OutlookandPluginsOfflineworkingMicrosoftDynamicsCRMforMicrosoftOfficeOutlookwithOfflineAccessenablesyoutocontinueyourworkwhenyouaredisconnectedfromtheserver.
Theeventandplug-ininfrastructureletsyouleveragedevelopmentinvestmentsacrosssolutionsbyusingthesameAPIsandprogrammingmodel.
TheIOrganizationServicemethodsandtheMicrosoftDynamicsCRMODataservicemethodsfunctionbothonlineandoffline.
WhenusingamethodsuchasCreateorUpdateoffline,thedataiswrittenlocallyandthenwhentheuserconnectstotheserver,theactionsareplayedbacktotheserver.
Tofindoutwhetheramessageissupportedoffline,seeMicrosoft.
Crm.
Sdk.
MessagesintheSDK.
YoucanalsodeterminewhetheranIOrganizationServicemessageworksofflinebycheckingtheSdkMessage.
Availabilityattributeforthedesiredmessage.
Ifthemessageworksformultipleentitytypes,youmustalsochecktheSdkMessageFilter.
Availabilityattributetoseewhetherthemessageisavailableofflinefortheentityyouwanttoworkwith.
Forexample,theCreatemessageisavailableoffline,butnotforthequeue,user,orsiteentities.
TracingcanbeenabledontheMicrosoftDynamicsCRMforMicrosoftOfficeOutlookwithOfflineAccessfordebugging.
DeploymentDeploymentofpluginstoOutlookclientsishandledautomaticallybytheGoOfflineprocess.
CrmOutlookServiceMicrosoftDynamicsCRMcontainstheassemblyMicrosoft.
Crm.
Outlook.
Sdk,whichyoucanusewhencustomizingMicrosoftOutlook.
Thisincludesmethodstodeterminewhichclientisbeingusedandwhethertheuserisonlineoroffline.
ExtendingMicrosoftDynamicsCRM2013Page88of14011/09/2014TheMicrosoft.
Crm.
Outlook.
SdkassemblyprovidesprogrammaticsupportforbasicMicrosoftOutlookactionssuchassynchronization,goingofflineoronline,andCRMforOutlookstateverification.
MethodsThefollowingtableliststhemethodsthatareavailableinCrmOutlookService:MethodDescriptionGoOfflineTakesMicrosoftDynamicsCRMforMicrosoftOfficeOutlookwithOfflineAccessintoanofflinestateandtriggersasynchronizationoftheofflinedatabasewiththeonlineserver.
Thismethodcannotbecalledfromaplug-in.
GoOnlineSynchronizesMicrosoftDynamicsCRMforMicrosoftOfficeOutlookwithOfflineAccesswiththeonlineMicrosoftDynamicsCRMserver.
Thismethodcannotbecalledfromaplug-in.
SetOfflineSetsMicrosoftDynamicsCRMforMicrosoftOfficeOutlookwithOfflineAccessintoanofflinestatewithouttriggeringasynchronizationoftheofflinedatabasewiththeonlineserver.
SyncTriggersasynchronizationeventbetweenMicrosoftOutlookandtheMicrosoftDynamicsCRMserverPropertiesThefollowingtableliststhepropertiesavailableinCrmOutlookService:PropertyDescriptionIsCrmClientLoadedGetsavaluethatindicateswhetherCRMforOutlookisloadedbyMicrosoftOutlook.
IsCrmClientOfflineGetsavaluethatindicateswhetherMicrosoftDynamicsCRMforMicrosoftOfficeOutlookwithOfflineAccessisoffline.
IsCrmDesktopClientGetsavaluethatindicateswhetherCRMforOutlookisinstalled.
ServerUriGetstheserverURItousetoconnecttotheMicrosoftDynamicsCRMserverbasedonthestateofCRMforOutlook.
StateGetsthestateofMicrosoftDynamicsCRMforMicrosoftOfficeOutlookwithOfflineAccess.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page89of140Lesson5-10AzureOverviewMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnlinesupportsintegrationwithWindowsAzure.
ByintegratingMicrosoftDynamicsCRMwithWindowsAzure,developerscanregisterplug-inswithMicrosoftDynamicsCRMthatcanpassrun-timemessagedata,knownastheexecutioncontext,tooneormoreWindowsAzuresolutionsinthecloud.
ThisisespeciallyimportantforMicrosoftDynamicsCRMOnlinebecauseWindowsAzureisoneoftwosupportedsolutionsforcommunicatingrun-timecontextobtainedinaplug-intoexternallineofbusiness(LOB)applications.
Theothersolutionistheexternalcustomendpointaccesscapabilityfromaplug-inregisteredinthesandbox.
TheWindowsAzureServiceBuscombinedwiththeWindowsAzureAccessControlService(ACS)providesasecurecommunicationchannelforMicrosoftDynamicsCRMrun-timedatatoexternallineofbusinessapplications.
ThiscapabilityisespeciallyusefulinkeepingdisparateMicrosoftDynamicsCRMsystemsorotherMicrosoftDynamicsCRMserverssynchronizedwithMicrosoftDynamicsCRMbusinessdatachanges.
IntegrationMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnlinecanbeenintegratedwiththeWindowsAzureplatformbycouplingtheMicrosoftDynamicsCRMeventexecutionpipelinetotheWindowsAzureServiceBusinthecloud.
Inessence,theMicrosoftDynamicsCRMpipelineconnectstotheWindowsAzureServiceBusenablingthedatathathasbeenprocessedaspartofthecurrentMicrosoftDynamicsCRMoperationtobepostedtothebus.
WindowsAzureServiceBussolutionsthatare"CRMaware"canlistenforandreadthedatathatispostedontheservicebusbyMicrosoftDynamicsCRM.
TheposteddataisstoredinaRemoteExecutionContextclassinstancethatisanextendedversionofIExecutionContextpassedatruntimetoMicrosoftDynamicsCRMasynchronousplug-ins.
ThisintegrationbetweenMicrosoftDynamicsCRMandtheWindowsAzureplatformprovidesasecurechannelforcommunicatingMicrosoftDynamicsCRMrun-timedatatoexternalcloud-basedline-of-businessapplications.
KeyelementsoftheintegrationThekeyelementsthatimplementtheintegrationbetweenMicrosoftDynamicsCRMandtheWindowsAzureServiceBusareasfollows.
AsynchronousServiceTheasynchronousserviceisresponsibleforpostingtheMicrosoftDynamicsCRMremoteexecutioncontexttotheWindowsAzureServiceBus.
Eachpostisperformedbyasystemjoboftheasynchronousservice.
AusercanviewthestatusofeachsystemjobusingtheMicrosoftDynamicsCRMwebapplication.
ExtendingMicrosoftDynamicsCRM2013Page90of14011/09/2014Plug-insTherearetwokindsofasynchronousregisteredplug-inssupportedbytheintegrationfeature:out-of-box(OOB),andcustom.
AnAzureawareplug-inisprovidedwithMicrosoftDynamicsCRM.
ThisOOBplug-inexecutesinfulltrustwiththeMicrosoftDynamicsCRMplatform.
WhenregisteredwithMicrosoftDynamicsCRM,theplug-incannotifytheasynchronousservicetopostthecurrentrequest'scontexttotheWindowsAzureServiceBus.
Adeveloperneedstoregisterasteponthisplug-inthatidentifiesthetargetmessageandentityinordertoenabletheservicebuspostingfunctionality.
Youcanalsowriteyourowncustomplug-inthatis"WindowsAzureaware".
Thecustomplug-inexecutesinpartialtrustmodeinthesandboxandcancallanyMicrosoftDynamicsCRMSDKmethods.
Acustomplug-incaninitiatepostingoftheMicrosoftDynamicsCRMcontexttotheservicebusbyincludingsomestandardlinesofcodethatnotifiestheasynchronousservicetoposttherequestcontext.
Thiscloud-specificcodemakestheplug-ins"WindowsAzureaware".
CustomWorkflowActivitiesCustomworkflowactivitiescanbewrittentopostthecurrentrequest'sdatacontexttotheWindowsAzureServiceBus.
WindowsAzureServiceBusTheservicebusrelaystheremoteexecutioncontextbetweenMicrosoftDynamicsCRMandWindowsAzureServiceBussolutionlisteners.
TheWindowsAzureAccessControlService(ACS)managesclaimsbasedauthenticationsecurity.
WindowsAzureSolutionFortheCRM-AzureintegrationfeaturetoworktheremustbeatleastonesolutioninaWindowsAzureServiceBussolutionaccount,wherethesolutioncontainsoneormoreserviceendpoints.
Forarelayendpointcontract,alistenerthatis"CRMaware"mustbeactivelylisteningontheendpointfortheMicrosoftDynamicsCRMrequestontheservicebus.
Foraqueueendpointcontract,alistenerdoesnothavetobeactivelylistening.
Alistenerismade"CRMaware"bylinkingittotheMicrosoft.
Xrm.
SdkassemblysothattypeRemoteExecutionContextisdefined.
ThesolutionrulesmustbeconfiguredtoallowtheMicrosoftDynamicsCRMremoteexecutioncontexttobepostedtotheservicebus.
Toenablethisposting,ACSneedstorecognizetheMicrosoftDynamicsCRMdeploymentasasupportedissuer.
BasicMicrosoftDynamicsCRMtoAzureservicebusscenarioAsapre-requisite,ACShasbeenconfiguredtorecognizeMicrosoftDynamicsCRMasthesupportedissuerandtheWindowsAzureServiceBussolutionconfiguredwithrulestoallowMicrosoftDynamicsCRMtoposttotheendpointonwhichthelistenerislistening.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page91of140Figure15-AzureServiceBusIntegrationThesequenceofeventsasidentifiedinthisdiagramareasfollows:1.
AlistenerisregisteredonaWindowsAzureServiceBussolutionendpointandbeginsactivelylisteningfortheMicrosoftDynamicsCRMremoteexecutioncontextontheservicebus.
2.
AuserperformssomeoperationinMicrosoftDynamicsCRMthattriggersexecutionoftheregisteredOOBplug-inoracustomWindowsAzureawareplug-in.
Theplug-ininitiatesapost,throughanasynchronousservicesystemjob,ofthecurrentrequestcontexttotheservicebus.
3.
ACSauthenticatestheclaimspostedbyMicrosoftDynamicsCRM.
Theservicebusthenrelaystheremoteexecutioncontexttothelistener.
Thelistenerprocessesthecontextinformationandperformssomebusinessrelatedtaskwiththatinformation.
Theasynchronousserviceisnotified,bytheservicebus,ofasuccessfulpostandsetstherelatedsystemjobtoacompletedstatusContractsForeachsolutionendpoint,youconfigureacontractthatdefinesthehandlingoftheseremoteexecutioncontext"messages"ontheservicebusandthesecuritythatshouldbeusedonthatendpoint.
Servicebusmessagesarereceivedatanendpointusingoneofthesupportedcontractslistedbelow.
QueueAqueuecontractprovidesamessagequeueinthecloud.
Withaqueuecontract,alistenerdoesnothavetobeactivelylisteningformessagesontheendpoint.
Forqueues,thereisadestructivereadandanon-destructiveread.
Adestructivereadreadsanavailablemessagefromthequeueandthemessageisremoved.
Anon-destructivereaddoesnotremoveamessagefromthequeue.
ExtendingMicrosoftDynamicsCRM2013Page92of14011/09/2014TherearetwotypesofqueuessupportedinMicrosoftDynamicsCRM:amessagebufferqueue,andapersistentqueue.
Formessagebufferqueues,messagesinthequeueareautomaticallydeletedifnotreadwithinapre-configuredlengthoftimethattypicallyislessthan10minutes.
Persistentqueueshaveamuchlongermessageavailabilitydurationthatcanbespecifiedincode.
One-wayAone-waycontractrequiresanactivelistener.
Ifthereisnoactivelisteneronanendpoint,theMicrosoftDynamicsCRMposttotheservicebusfails.
MicrosoftDynamicsCRMwillretrythepostinexponentiallylargerandlargertimespansuntiltheasynchronoussystemjobthatispostingtherequestiseventuallyabortedanditsstatusissettoFailed.
Two-wayAtwo-waycontractissimilartoaone-waycontractexceptthatastringvaluecanbereturnedfromthelistenertoMicrosoftDynamicsCRM.
RESTARESTcontractissimilartoatwo-waycontractexceptitisonaRESTendpoint.
TopicSimilartoaqueueexceptthatoneormorelistenerscansubscribetoreceivemessagesfromthetopic.
ListenersAlistenerisstructuredaroundwhatisknownasABC:address,binding,andcontract.
ThefollowinginformationidentifiestheABCsofaone-waylistener.
Address:serviceURIBinding:WS2007HttpRelayBindingContract:IServiceEndpointPluginAfteryourlistenerisregisteredwithanendpoint,thelistener'sExecutemethodisinvokedwheneveramessageispostedtotheservicebusbyMicrosoftDynamicsCRM.
TheExecutemethoddoesnotreturnanydatafromthemethodcall.
Atwo-waylisteneriscodedinasimilarfashionasaone-waylistener.
TheABCsofatwo-waylistenerareasfollows:Address:serviceURIBinding:WS2007HttpRelayBindingContract:ITwoWayServiceEndpointPluginForthistwo-waycontract,theExecutemethodreturnsastringfromthemethodcall.
ARESTlisteneriscodedinasimilarfashionasatwo-waylistener.
TheABCsofaRESTlistenerareasfollows:ExtendingMicrosoftDynamicsCRM201311/09/2014Page93of140Address:serviceURIBinding:WebHttpRelayBindingContract:IWebHttpServiceEndpointPluginFortheRESTcontract,theExecutemethodreturnsastringfromthemethodcall.
OutoftheBoxAzurePluginAninternalplug-innamedServiceBusPluginisprovidedwithMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnline.
Theplug-incontainsthebusinesslogictoposttheMicrosoftDynamicsCRMmessageexecutioncontexttotheWindowsAzureServiceBus.
Tousethisplug-in,youneedtoregisteraWindowsAzureServiceBussolutionendpointandastepfortheplug-inusingthePluginRegistrationTool.
ThestepdefineswhatmessageandentitycombinationbeingprocessedbythecoreMicrosoftDynamicsCRMoperationshouldtriggertheplug-intoexecute.
OnlytheexecutioncontextispostedtoAzure.
Note:TheServiceBusPlugincanonlyberegisteredtorunasynchronously.
Youcanwriteacustomplug-inthatincludestherequiredlinesofcodetoposttotheservicebus.
Theplug-inisregisteredinasimilarway,exceptthatitmustberegisteredinthesandboxandrununderpartialtrust.
Youcanalsowriteacustomworkflowactivitythatcanposttheexecutioncontexttotheservicebusandincludethisactivityinyourworkflows.
Lesson5-11PluginsvsCustomWorkflowActivitiesDeterminingWhentoUsePlug-insGenerally,ifdevelopingcustomcodeandassemblies,workingwithplug-insismorepowerfulthandevelopingawholesolutioninworkflow.
Thisisforthefollowingreasons:AllcodeisinC#orVisualBasic.
NET.
Plug-insarenotboundbythefeaturesandlogicpatternsthattheworkfloweditorsupports.
Itispossibletostepthroughanddebugallaspectsofthecode.
Itisnotpossibletostepthroughaprocess,althoughyoucanstepthroughcustomworkflowactivities.
Whenfacedwithasituationwhereprocessesorplug-inscanbeused,considertheguidelinesthatareshownhere:EaseofdevelopmentBestChoice:Dependswhethercustomworkflowactivitiesarerequired.
Processes:Forsimpleoperationsthataresupportedbyprocessesanddonothavecustomworkflowactivities,processesaretheeasiest.
ExtendingMicrosoftDynamicsCRM2013Page94of14011/09/2014Plug-ins:Foradvancedoperationsoroperationsthatarenotsupportedbyprocesses,plug-inscouldbeeasier.
Modificationsbynon-developersBestChoice:ProcessesProcesses:Processeshavetheadvantagewhenthelogicissupportedbyprocessesnatively.
Non-developerscanusecustomworkflowactivitiescreatedbydeveloperstoincludeadditionalcapabilitiesintheprocessrulestheydesign.
Plug-ins:Plug-insusuallyrequireadevelopertoapplychanges.
Howeveraplug-incanreferenceanexternalfile,registrysettingordatabasesothatanon-developercanmodifythebehaviouroftheplug-in.
OnDemandApplicationBestChoice:ProcessesProcesses:ProcessescanbeappliedmanuallyfromtheMicrosoftDynamicsCRM2013application.
Plug-ins:Plug-insdonotapplyhere.
Webresourcesandcodecanbedevelopedifoptingnottouseworkflow.
ThesepagescanbeintegratedintheMicrosoftDynamicsCRM2013applicationthroughcustombuttons,menucommandsorIFrames.
LogicSupportBestChoice:Plug-ins.
Processes:Limitedtowhattheeditorsupportsunlessusingacustomworkflowactivity.
Plug-ins:Thisislimitedonlybythecapabilitiesoftheavailabledevelopmentresources.
ImmediacyTherequirementtoaffectdatabeforecommittingittothedatabasesothatusershaveinstantfeedback.
BestChoice:Plug-insorClient-sidecodeProcesses:UntilDynamicsCRM2013eventbasedactivitieswerealwaysasynchronousandusersdidnotseetheresultofanydatachangesimmediatelywithinMicrosoftDynamicsCRMapplication.
However,withtheadventofsynchronousworkflowstherearetimeswhenworkflowisthecorrectanswerevenwhenimmediacyisneeded.
Plug-ins:Plug-insallowfordatachangestobemadethatarevisibleaftertheformisreloadedfollowingaSave.
Pre-eventplug-inscanalsocancelanysubmittedchanges.
Client-Sidecode:Mostresponsive.
Butbecauseitdoesnotoccurattheplatformlayer,scenarioscanarisewhereuserswithdifferentinterfacesgetdifferentapplicationbehaviour.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page95of140PlatformLayerDataValidationTherequirementtoperformdatavalidationandreturnerrorswhenrequirementsarenotmet.
BestChoice:Plug-insProcesses:Workflowactivitiesnormallyrunasynchronouslyaftertheeventoccursandcannotreturnerrorstotheclientorcanceltheevent.
SynchronousworkflowsarenowpossibleinCRM2013Plug-ins:Inpre-eventplug-ins,validationcanbeperformed,theeventthatfiredtheplug-incanbecancelledandanerrorcanbereturnedtotheclient.
Lesson5-12DeveloperToolkitDeveloperToolkitTheDeveloperToolkitforMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnlineisincludedintheSDKpackageatSDK\Tools\DeveloperToolkit.
TheDeveloperToolkitisasetofMicrosoftVisualStudio2010andMicrosoftVisualStudio2012integrationtoolsfocusedonacceleratingthedevelopmentofcustomcodeforMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnline.
TheDeveloperToolkitsupportscreationanddeploymentofplug-ins,customworkflowassemblies,XAMLworkflowsandwebresources.
AdevelopercanwritecustomcodewithinVisualStudioanddeploythecodetoanunmanagedsolutiononaMicrosoftDynamicsCRMserver.
WiththeDeveloperToolkit,youcandothefollowing:EasilygeneratestronglytypedproxyclasseswithouthavingtorunCrmSvcUtil.
exe.
GetaccesstoentityandoptionsetdefinitionswithinVisualStudio.
Generateplug-incodesoyoucanimmediatelybegintowritecodeforbusinesslogic.
Editandregisterplug-inswithoutusingthePlug-inregistrationtool.
Createnewwebresourcesorextractexistingwebresources,addthemtoyoursolution,editthem,anddeploychangesallwithinVisualStudio.
CreateandeditworkflowanddialogprocessesfromwithinVisualStudio.
CreateanddeployXAMLworkflowsinVisualStudio.
GeteasyaccesstosecurityroleandfieldsecurityprofileinformationinVisualStudioExtendingMicrosoftDynamicsCRM2013Page96of14011/09/2014Module6–ClientSideScriptThekeyobjectivesofthismodulearetoprovideanunderstandingofthetypesofclientsidescriptingthatcanbeusedinDynamicsCRM.
ObjectivesThekeyobjectivesofthismoduleareto:UnderstanduseofJavaScriptinDynamicsCRMUnderstandtheXrm.
PagemodelUnderstanduseofWebResourcesURLAddressableFormsandParametersDebuggingLesson6-1UseofJavaScriptOverviewMicrosoftJScriptlibrariesareJavaScript(JScript)webresourcesthatcontainfunctionswhichcanbeusedtodothefollowing:Handleformandfieldevents.
Performactionsforcontrolsconfiguredintheribbon.
SupportotherfunctionsWhereJavaScriptcanbeinMicrosoftDynamicsCRMYoucanuseJavaScripttoperformactionsinformscripts,commandbar(ribbon)commands,andwebresources.
FormscriptsThemostcommonuseofJavaScriptinMicrosoftDynamicsCRMistoaddfunctionsaseventhandlersforentityformevents.
Commandbar(ribbon)commandsWhenyoucustomizetheMicrosoftDynamicsCRMcommandbar,youcanconfigurecommandsforcontrolsthatyouadd.
Thesecommandscontainrulesthatcontrolwhetherthecontrolisenabledandwhatactionisperformedwhenthecontrolisused.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page97of140WebresourcesMicrosoftDynamicsCRMprovidesanorganization-ownedentitythatstoresabinaryrepresentationofafilethatcanbeaccessedbyusingaURL.
Thisfileiscalledawebresource.
Thereareseveraltypesofwebresources.
AwebresourcethatrepresentsaJavaScriptlibraryiscalledaJScriptwebresource.
Youcanuseawebpage(HTML)webresourcetoprovideauserinterfacewithJavaScriptlibrariesincludedjustasyouwouldforfilesonawebserver.
BecausethesefilesarepartofMicrosoftDynamicsCRM,userswhoaccessthemarealreadyauthenticated.
Therefore,youcanuseMicrosoftDynamicsCRMwebserviceswithouthavingtowritecodetoauthenticatetheuser.
Lesson6-2Xrm.
PageModelOverviewMicrosoftDynamicsCRM2013includesanenhancedclientscriptingmodel.
Thescriptingmodelprovidesdevelopersmoreflexibilitywhentheyworkwiththeformcontrolsandthedataassociatedwiththem.
TheXrm.
PageobjectprovidesahierarchyofobjectsthatcanbeusedtointeractwithMicrosoftDynamicsCRM2013formsinthefollowingways:Showandhideuserinterfaceelements.
Supportmultiplecontrolsforeachattribute.
Accessmultipleformsforeachentity.
Manipulateformnavigationitems.
Getorsetattributevalues.
FulldetailsarelocatedintheSDKundertheClient-SideProgrammingReferencetopic.
Xrm.
PageobjecthierarchyAsshowninthefollowingdiagram,Xrm.
Pageprovidesanamespacecontainerforthreeobjectsdescribedinthefollowingtable:ObjectDescriptioncontextProvidesmethodstoretrieveinformationspecifictoanorganization,auser,orparametersthatwerepassedtotheforminaquerystring.
dataProvidesaccesstotheentitydataandmethodstomanagethedataintheform.
uiContainsmethodstoretrieveinformationabouttheuserinterface,inadditiontocollectionsforseveralsubcomponentsoftheform.
ExtendingMicrosoftDynamicsCRM2013Page98of14011/09/2014Figure16-Xrm.
PagemodelXrm.
Page.
contextXrm.
Page.
contextprovidesmethodsthatareusedtoretrieveinformationthatisspecifictoanorganization,auser,orparametersthatwerepassedtotheforminaquerystring.
ContextPropertiesandMethodsThecontextobjectisavailableinformsbyreferencingXrm.
Page.
context.
Forwebresourcesexecutedoutsideofaform,usetheGetGlobalContextfunctiontoretrieveacontextobject.
Propertiesofthecontextare:client-ProvidesaccesstothegetClientandgetClientStatemethodsyoucanusetodeterminewhichclientisbeingusedandwhethertheclientisconnectedtotheserver.
getClientUrl-ReturnsthebaseURLthatwasusedtoaccesstheapplication.
getCurrentTheme-ReturnsastringrepresentingthecurrentMicrosoftOfficeOutlookthemechosenbytheuser.
getOrgLcid-ReturnstheLCIDvaluethatrepresentsthebaselanguagefortheorganization.
getOrgUniqueName-Returnstheuniquetextvalueoftheorganization'sname.
getQueryStringParameters-Returnsadictionaryobjectofkeyvaluepairsthatrepresentthequerystringargumentsthatwerepassedtothepage.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page99of140getUserId-ReturnstheGUIDoftheSystemUsergetUserLcid-ReturnstheLCIDvaluethatrepresentstheprovisionedlanguagethattheuserselectedastheirpreferredlanguage.
getUserName-Returnsthenameofthecurrentuser.
getUserRoles-ReturnsanarrayofstringsthatrepresenttheGUIDvaluesofeachofthesecurityrolesthattheuserisassociatedwithoranyteamsthattheuserisassociatedwith.
isOutlookClient-Deprecated.
Useclient.
getClientinstead.
isOutlookOnline-Deprecated.
Useclient.
getClientStateinstead.
prependOrgName-Prependstheorganizationnametothespecifiedpath.
RemovedMethodsThegetAuthenticationHeaderandgetServerUrlmethodsweredeprecatedwithMicrosoftDynamicsCRM2011andarenolongerpresentinMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnline.
Xrm.
Page.
dataPropertiesandMethodsXrm.
Page.
dataprovidesmethodstoworkwiththeform.
Youcanrefreshthedataintheformandsavetheformasynchronously:refresh-Asynchronouslyrefreshesandoptionallysavesallthedataoftheformwithoutreloadingthepage.
save-Savestherecordasynchronouslywiththeoptiontosetcallbackfunctionstobeexecutedafterthesaveoperationiscompleted.
Xrm.
Page.
data.
entityXrm.
Page.
dataprovidesanentityobjectthatprovidescollectionsandmethodstomanagedatawithintheentityform.
PropertiesandMethodsattributes-Thecollectionofattributesfortheentity.
getDataXml-Returnsastringrepresentingthexmlthatwillbesenttotheserverwhentherecordissaved.
getEntityName-Returnsastringrepresentingthelogicalnameoftheentityfortherecord.
getId-ReturnsastringrepresentingtheGUIDidvaluefortherecord.
ExtendingMicrosoftDynamicsCRM2013Page100of14011/09/2014getIsDirty-ReturnsaBooleanvaluethatindicatesifanyfieldsintheformhavebeenmodified.
OnSave-UsetheaddOnSaveandremoveOnSavemethodstoaddorremoveeventhandlerstothesaveeventgetPrimaryAttributeValue-Getsastringforthevalueoftheprimaryattributeoftheentity.
save-Savestherecordwiththeoptionstoclosetheformoropenanewformafterthesaveiscompleted.
Savehasanoptionalargument:save()-Ifnoparameterisincludedtherecordwillsimplybesaved.
ThisistheequivalentofusingtheSavecommand.
save("saveandclose")-ThisistheequivalentofusingtheSaveandClosecommand.
save("saveandnew")-ThisistheequivalentoftheusingtheSaveandNewcommand.
Xrm.
Page.
data.
entityattributeAttributescontainthedataintheform.
UsetheXrm.
Page.
data.
entity.
attributescollectionortheXrm.
Page.
getAttributeshortcutmethodtoaccessacollectionofattributesPropertiesandMethodsBooleanandOptionSetAttributemethods-thegetInitialValue,getOption,getOptions,getSelectedOption,andgetTextmethodsprovidewaystogetinformationaboutBooleanorOptionSetattributes.
Controls-Accesscontrolsassociatedwithattributes.
getAttributeType-Getthetypeofattribute.
getFormat-Gettheattributeformat.
getIsDirty-Determinewhetherthevalueofanattributehaschangedsinceitwaslastsaved.
getIsPartyList-Determinewhetheralookupattributerepresentsapartylistlookup.
getMaxLength-Getthemaximumlengthofstringwhichanattributethatstoresstringdatacanhave.
getName-Getthenameoftheattribute.
getParent-GetareferencetotheXrm.
Page.
data.
entityobjectthatistheparenttoallattributes.
getUserPrivilege-DeterminewhatprivilegesauserhasforfieldsusingFieldLevelSecurity.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page101of140NumberAttributemethods-UsethegetMax,getMin,andgetPrecisionmethodstoaccessinformationaboutthepropertiesofnumberattributes.
OnChangeEvent-UsetheaddOnChange,removeOnChange,andfireOnChangemethodsandtomanageeventhandlersfortheOnChangeevent.
RequiredLevel-UsethesetRequiredLevelandgetRequiredLevelmethodstocontrolwhetheranattributemusthaveavalueinordertosavearecord.
SubmitMode-UsethesetSubmitModeandgetSubmitModemethodstocontrolwhetherthevalueofanattributewillbesubmittedwhenarecordissaved.
Value-UsethegetValueandsetValuemethodstodeterminethevaluessetforanattributeandchangethevalue.
Xrm.
Page.
uiXrm.
Page.
uiprovidescollectionsandmethodsthatareusedtomanagetheuserinterfaceoftheform.
PropertiesandMethodsclose-Methodtoclosetheform.
controls-Acollectionofallthecontrolsonthepage.
formSelector-UsetheformSelector.
getCurrentItemmethodtoretrieveinformationabouttheformcurrentlyinuseandtheformSelector.
itemscollectioncontaininginformationaboutalltheformsavailablefortheuser.
getCurrentControl-Methodtogetthecontrolobjectthatcurrentlyhasfocusontheform.
getFormType-Methodtogettheformcontextfortherecord.
navigation.
items-Acollectionofallthenavigationitemsonthepage.
FormNotification-UsesetFormNotificationtodisplayformlevelnotificationsandclearFormNotificationtoremovenotifications.
refreshRibbon-Methodtocausetheribbontore-evaluatedatathatcontrolswhatisdisplayedinit.
Tabs-Acollectionofallthetabsonthepage.
ViewPortMethods-TheViewPortistheareaofthepagecontainingformdata.
Itcorrespondstothebodyoftheformanddoesnotincludethenavigation,header,footerorformassistantareasofthepage.
UsethegetViewPortHeightandgetViewPortWidthmethodstogetthecurrentsizeoftheViewPort.
ExtendingMicrosoftDynamicsCRM2013Page102of14011/09/2014Xrm.
Page.
uicontrolsYouaccesscontrolsusingthefollowingcollections:Xrm.
Page.
ui.
controls,Xrm.
Page.
uiSection.
controls,orXrm.
Page.
data.
entityAttribute.
controls.
TheXrm.
Page.
getControlmethodisashortcutmethodtoaccessXrm.
Page.
ui.
controls.
ForcontrolsthatareboundtoattributesitiscommontoaccesscontrolsthroughtheXrm.
Page.
data.
entityAttribute.
controlscollectionPropertiesandMethodsDisabled-DetectthestateandenableordisablecontrolsusingthegetDisabledandsetDisabledmethods.
getAttribute-Gettheattributethatthecontrolisboundto.
getControlType-Getinformationaboutthetypeofcontrol.
getName-GetthenameofthecontrolgetParent-Getthesectionobjectthatthecontrolisin.
Label-GetorchangethelabelforacontrolusingthegetLabelandsetLabelmethods.
LookupControlMethodsandEvents-ControltheresultsdisplayedforausertochoosefromwhentheysetthevalueofalookupcontrolusingtheaddCustomFilter,addCustomView,getDefaultView,setDefaultViewmethods.
YoucanaddorremoveeventhandlersforthePreSearchEventusingtheaddPreSearchandremovePreSearchmethods.
Notification-DisplayandremovenotificationstousersaboutacontrolusingthesetNotificationandclearNotificationmethods.
OptionSetControlMethods-ModifytheoptionsdisplayedinOptionSetcontrolsusingtheaddOption,clearOptions,andremoveOptionmethods.
Refresh-Refreshthedatadisplayedinasubgrid.
setFocus-Setfocusonacontrol.
setShowTime-Specifywhetheradatecontrolshouldshowthetimeportionofthedate.
Visible-DeterminewhichcontrolsarevisibleandshoworhidethemusingthegetVisibleandsetVisiblemethods.
WebResourceandIFRAMEControlMethods-InteractwithwebresourceandIFRAMEcontrolsusingthegetData,setData,getInitialUrl,getObject,setSrcandgetSrcmethods.
Xrm.
Page.
ui.
formSelectorFormItemsareavailablefromtheXrm.
Page.
ui.
formSelector.
getCurrentItemortheXrm.
Page.
ui.
formSelector.
itemscollection.
AformitemrepresentsaformthatisavailabletoauserExtendingMicrosoftDynamicsCRM201311/09/2014Page103of140becauseitisassociatedwithasecurityrolethattheuserisalsoassociatedto.
Oftentherewillbeonlyoneform.
Whenmorethanoneformisavailable,thesemethodscanbeusedtochangetheformtheuserisviewing.
PropertiesandMethodsgetId-ReturnstheGUIDIDoftheform.
getLabel-Returnsthelabeloftheform.
Navigate-Opensthespecifiedform.
Xrm.
Page.
ui.
navigationEachitemrepresentsoneoftheavailablenavigationoptionsavailableinthenavigationbarforentitiesthathavebeenupdatedtothenewuserexperienceorontheleftsideoftheformforentitiesthathavenotbeenupdated.
PropertiesandMethodsgetId-Returnsthenameoftheitem.
Label-GetorchangethelabelforanavigationitemusingthegetLabelandsetLabelmethods.
setFocus-Setsthefocusontheitem.
Visible-DeterminewhichnavigationitemsarevisibleandshoworhidethemusingthegetVisibleandsetVisiblemethods.
Xrm.
Page.
uitabAtabisagroupofsectionsonapage.
Itcontainsmethodstomanipulatetabsaswellasaccesstosectionswithinthetabthroughthesectionscollection.
PropertiesandMethodsDisplayState-UsethegetDisplayStateandsetDisplayStatemethodstodeterminewhetherthetabiscollapsedortocollapseandexpandthetab.
getName-Methodtogetthenameofthetab.
getParent-MethodtoreturntheXrm.
Page.
ui(client-sidereference)objectthatistheparenttoalltabs.
Label-UsethegetLabelandsetLabelmethodstodeterminethelabelforthetabortohideandshowthetablabel.
Sections-Acollectionofsectionswithinthetab.
setFocus-Methodtosetfocusonatab.
ExtendingMicrosoftDynamicsCRM2013Page104of14011/09/2014Visible-UsethegetVisibleandsetVisiblemethodstodeterminethetabisvisibleortohideandshowthetabXrm.
Page.
uisectionAsectioncontainsmethodstomanagehowitappearsaswellasaccessingthetabthatcontainsthesection.
PropertiesandMethodsControls-Acollectionofcontrolsinthesection.
getName-Methodtoreturnthenameofthesection.
getParent-Methodtoreturnthetabcontainingthesection.
Label-UsethegetLabelandsetLabelmethodstoretrieveorchangethelabelforthesection.
Visible-UsethegetVisibleandsetVisiblemethodstocheckwhetherthesectionisvisibleorhideandshowthesection.
Xrm.
UtilityTheXrm.
Utilityobjectprovidesacontainerforusefulfunctionsnotdirectlyrelatedtothecurrentpage.
Thesefunctionsareavailableineveryapplicationpagethatsupportsscripting.
Youcanusetheminformscriptsorinribboncommands.
ForHTMLwebresources,theyareavailablewhenyouincludetheClientGlobalContext.
js.
aspxpage.
PropertiesandMethodsDialogs-UsealertDialogandconfirmDialogdisplaymessagestousersandsetcodetoexecutebasedontheirresponse.
ThesefunctionsmustbeusedwithMicrosoftDynamicsCRMfortabletsinplaceofthewindow.
alertandwindow.
confirmmethods.
isActivityType-Determineifanentityisanactivityentity.
openEntityForm-Opensanentityform.
openWebResource-OpensanHTMLwebresource.
ShortcutsTheXrm.
Pageobjectincludestwoshortcutmethodsthatareusedtoprovidedirectaccesstocommonlyusedcontrols.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page105of140Xrm.
Page.
getAttributeThisshortcutprovidesdirectaccesstotheXrm.
Page.
data.
entity.
attributes.
getmethod.
ThefollowingexampleusestheXrm.
Page.
getAttributeshortcutmethodtogettheaccountnumberattribute.
varaccountnumber=Xrm.
Page.
getAttribute("accountnumber");Xrm.
Page.
getControlThisshortcutprovidesdirectaccesstotheXrm.
Page.
ui.
controls.
getmethod.
ThefollowingexampleusestheXrm.
Page.
getControltogettheaccountnumbercontrol.
varaccountnumber=Xrm.
Page.
getControl("accountnumber");Lesson6-3WebResourcesAddingcustomwebcontent(forexample,HTML,Images,Silverlight,JavaScript)toCRMformsisacommonmethodthatisusedtoextendMicrosoftDynamicsCRMfunctionality.
AddingcustomvalidationandnewapplicationsthatinteractwithMicrosoftDynamicsCRM(forexample,HTMLpagesdisplayingMicrosoftDynamicsCRMdata)areafewexamplesthatuseclient-sidetechnologies.
WebResourcesactivatesthestorageofsharedblocksofcodeorresourcesthatcanbereusedacrosstheMicrosoftDynamicsCRMWebApplication.
WebresourcesrepresentfilesthatcanbeusedtoextendtheMicrosoftDynamicsCRMwebapplicationsuchashtmlfiles,JScript,andSilverlightapplications.
Youcanusewebresourcesinformcustomizations,theSiteMap,ortheapplicationribbonbecausetheycanbereferencedbyusingURLsyntax.
TheURLsyntaxforwebresourcesallowsforrelativepathreferences.
Withyourdevelopmenttools,youcancreateagroupofinterdependentfilesonadevelopmentserverbyusingfiletypescompatiblewithwebresources.
Then,ifyouuseaconsistentnamingconventionandrelativepathreferences,thewebsitewillfunctionafteryouuploadallthefilesintoMicrosoftDynamicsCRMBecauseWebResourcesarestoredinMicrosoftDynamicsCRMandaresolutioncomponents,theycanbeeasilyexportedandinstalledtoanyMicrosoftDynamicsCRMdeployment.
WebResourcesarealsoavailabletousersofMicrosoftDynamicsCRMforMicrosoftOfficeOutlookwithOfflineAccesswhenofflinebecausetheyaresynchronizedwiththeuser'sdata.
WebResourcesTypesTheavailableWebResourcesare:FileFileextensionsTypeWebpage(HTML).
htm,.
html1StyleSheet(CSS).
css2ExtendingMicrosoftDynamicsCRM2013Page106of14011/09/2014FileFileextensionsTypeScript(JScript).
js3Data(XML).
xml4Image(PNG).
png5Image(JPG).
jpg6Image(GIF).
gif7Silverlight(XAP).
xap8StyleSheet(XSL).
xsl,.
xslt9Image(ICO).
ico10WhereWebResourcescanbeUsedWebresourcescanbeusedinanumberofdifferentareaswithinMicrosoftDynamicsCRM2013.
Whileeachwebresourcehasitsowndistinctuse,notallwebresourcescanbeusedwithineachfunctionalareaoftheapplication.
Thefollowingtableoutlineswhereeachwebresourcecanbeusedwithintheapplication.
ResourceTypeFormsDashboardsSiteMapApplicationribbonOtherWebPage(HTML)xxxxScript(JScript)xxData(XML)UsedinthecontextofaWebPage(HTML)webresourceImage(PNG)xxxxCouldbeusedinthecontextofaSilverlight(XAP)orWebPage(HTML)webresourceImage(JPG)xxxxCouldbeusedinthecontextofaSilverlight(XAP)orWebPage(HTML)webresourceExtendingMicrosoftDynamicsCRM201311/09/2014Page107of140ResourceTypeFormsDashboardsSiteMapApplicationribbonOtherImage(GIF)xxxxCouldbeusedinthecontextofaSilverlight(XAP)orWebPage(HTML)webresourceSilverlight(XAP)xxxxCouldbeusedinthecontextofaSilverlight(XAP)orWebPage(HTML)webresourceStyleSheet(XSL)UsedinthecontextofaWebPage(HTML)webresourcealongwithaData(XML)webresourceImage(ICO)xxxxCouldbeusedinthecontextofaSilverlight(XAP)orWebPage(HTML)webresourceStyleSheet(CSS)UsedinthecontextofaWebPage(HTML)webresource.
ReferencingWebResourcesThereareseveralmethodsthatyoucanusetoreferencewebresources.
$webresourceDirectiveYoushouldalwaysusethe$webresourcedirectivewhenreferencingawebresourcefromaribboncontrolorfromaSiteMapsubarea.
Usethe$webresourcedirectiveanywheretheXMLallowsaURLvalue.
Thefollowingsampleshowshowtouseit.
$webresource:FullURLThefollowingsampleshowsthestyleofURLyoucanusetoviewwebresources/WebResources/ExtendingMicrosoftDynamicsCRM2013Page108of14011/09/2014WhenyouwritecodetoreferenceawebresourcethatwillneedtoworkforeitherMicrosoftDynamicsCRMOnlineoron–premisesMicrosoftDynamicsCRM,youshouldusethegetClientUrlfunction.
RelativeURLWhenreferencingawebresourcefromareasthatdonotsupportusingthe$webresource:directive,arelativeURLcanbeused.
Toenablethis,werecommendthatyouuseaconsistentnamingconventionforthewebresourcesthatreflectavirtualfilestructure.
Thesolutionpublisher'scustomizationprefixwillalwaysbeincludedasaprefixtothenameofthewebresource.
Thiscanrepresentavirtual"root"folderforallwebresourcesaddedbythatpublisher.
Youcanthenusetheforwardslashcharacter(/)tosimulateafolderstructurethatwillbehonouredbythewebserver.
Fromanotherwebresource,youshouldalwaysuserelativeURLstoreferenceeachother.
Forexample,forthewebpagewebresourcenew_/content/contentpage.
htmtoreferencetheCSSwebresourcenew_/Styles/styles.
css,createthelinkasfollows:Xrm.
Utility.
openWebResourceTheXrm.
Utility.
openWebResourcefunctionwillopenanHTMLwebresourceinanewwindowwithparameterstopassthenameofthewebresource,anyquerystringdatatobepassedinthedataparameter,andinformationaboutheightandwidthofthewindow.
LimitationsofWebResourcesThereisnotypeofWebResourcethatsupportsthecapabilitiesofanASP.
NET(.
aspx)pagetoexecutecodeontheserver.
WebResourcesarelimitedtostaticfilesorfilesthatareprocessedinthebrowser.
AWebResourcecancontaincodethatisprocessedinthebrowsertoexecutewebservicecallstointeractwithMicrosoftDynamicsCRMdata.
WebResourcesareavailableonlybyusingtheMicrosoftDynamicsCRMwebapplicationsecuritycontext.
OnlylicensedMicrosoftDynamicsCRMuserswhohavethenecessaryprivilegescanaccessthem.
ThemaximumsizeoffilesthatcanbeuploadedisdeterminedbytheOrganization.
MaxUploadFileSizeproperty.
ThispropertyissetintheEmailtaboftheSystemSettingsintheCRMapplication.
Thissettinglimitsthesizeoffilesthatcanbeattachedtoemailmessages,notes,andwebresources.
Thedefaultsettingis5MB.
HTMLWebResourcesCapabilitiesofHTMLWebResourcesBecauseanHTMLwebresourceisjuststreamedtotheuser'sbrowser,anHTMLwebresourcecanincludeanycontentthatisrenderedontheuser'sbrowser.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page109of140LimitationsofHTMLWebResourcesAnHTMLwebresourcecannotcontainanycodethatmustbeexecutedontheserver.
ASP.
NETpagescannotbeuploadedasHTMLwebresources.
HTMLwebresourcescanonlyacceptonecustomquerystringparametercalled"data".
PassingParameterstoHTMLWebResourcesHTMLwebresourcecanacceptonlytheparametersinthefollowingtable.
ParameterNameDescriptiontypenameEntityNameThenameoftheentity.
typeEntityTypeCodeAnintegerthatuniquelyidentifiestheentityinaspecificorganization.
idObjectGUIDTheGUIDthatrepresentsarecord.
orgnameOrganizationNameTheuniquenameoftheorganization.
userlcidUserLanguageCodeThelanguagecodeidentifierbeingusedbythecurrentuser.
orglcidOrganizationLanguageCodeThelanguagecodeidentifierthatrepresentsthebaselanguagefortheorganization.
dataOptionalDataParameterAnoptionalvaluethatmaybepassed.
formidFormIdTheGUIDthatrepresentsaformid.
pagemodeForinternaluseonly.
securityForinternaluseonly.
tabSetForinternaluseonly.
Silverlight(XAP)WebResourcesMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnlinesupportaddingSilverlight4.
0webresourcestoentityforms.
YoucandisplaySilverlight5.
0webresourceswithinanHTMLwebresourceusingahostingelementthatisconfiguredforthatversionSilverlightsupportMicrosoftSilverlightwebresourcesremainsupportedinMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnlineforbackwardscompatibility.
Forcomponentsthatwillbeabletobepresentedonallclients,werecommendusingHTMLwebresourceswithHTML5insteadofSilverlight.
ExtendingMicrosoftDynamicsCRM2013Page110of14011/09/2014HTML5isthepreferredclienttechnologyfortheweb,overwebplug-inslikeSilverlightandFlash.
HTML5canbeconsumedfromanydevice(PC,tablet,smartphone,andmore)andheavilyusesJavaScript(andmanypowerfulJavaScriptlibraries,suchasjQuery)andCSS.
JscriptWebResourcesUseScript(JScript)webresourcestocreatealibraryofJavaScriptfunctionsthatcanbeaccessedfromanywhere.
CapabilitiesofscriptwebresourcesWithScriptwebresources,youcanmoreefficientlymanagecodeusedinformscripts,webpage(HTML)webresources,orribboncommandsbylinkingthemtosharedlibraryofJavaScriptfunctions.
LimitationsofscriptwebresourcesLikeallwebresources,scriptwebresourcesusetheMicrosoftDynamicsCRMwebapplicationsecuritycontext.
OnlylicensedMicrosoftDynamicsCRMuserswhohavethenecessaryprivilegescanaccessthemImageWebResourcesUseimageWebresourcestomakeimagesavailableforuseinMicrosoftDynamicsCRM.
CapabilitiesofImageWebResourcesWithimageWebresourcesyoucanaddimageswhereyouneedthem.
Commonusesincludethefollowing:CustomentityiconsIconsforcustomRibboncontrolsandSiteMapsubareasDecorativegraphicsforentityformsandWebpageWebresources.
BackgroundimagesthatareusedbyCSSWebresourcesLimitationsofImageWebResourcesLikeallWebresources,imageWebresourcesusetheMicrosoftDynamicsCRMsecuritycontext.
OnlylicensedMicrosoftDynamicsCRMuserswhohavethenecessaryprivilegescanaccessthem.
Onlythefourspecifiedtypesofimagefiles(*.
jpg,*.
png,*.
gif,*.
ico)aresupported.
Stylesheet(XSL)WebResourcesUseStylesheet(XSL)WebresourcestotransformXMLdata.
Data(XML)WebResourcesUseData(XML)Webresourcestosaveandaccessdata.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page111of140CapabilitiesofXMLWebresourcesUseXMLWebresourcestocachedatathatyouwanttouseinyoursolution.
LimitationsofXMLWebresourcesUseXMLWebresourcestocacheconfigurationsettingsormetadataforyoursolutions.
AnXMLWebresourcedoesnotrepresentarobustsolutionfordatathatisfrequentlyupdatedbymultipleusers.
WhileoneuserisupdatinganXMLWebresource,anotheruser(orautomatedprocess)couldupdatetheWebresourceandthatdatawouldbelostwhenthefirstusersavestheirchanges.
Stylesheet(CSS)WebResourcesUsecascadingstylesheet(CSS)webresourcestocreatestylesheetsforuseinwebpagewebresources.
CapabilitiesofCSSwebresourcesWithCSSwebresources,youcanmanagetheappearanceofwebpagewebresourcesbylinkingthemtoasharedlibraryofCSSstyles.
LimitationsofCSSwebresourcesLikeallwebresources,CSSwebresourcesareonlyavailableintheMicrosoftDynamicsCRMsecuritycontext.
OnlylicensedCRMuserswhohavethenecessaryprivilegescanaccessthem.
Lesson6-4FormsandClient-SideEventsOverviewMicrosoftDynamicsCRM2013includesanenhancedclientscriptingmodel.
Thescriptingmodelprovidesdevelopersmoreflexibilitywhentheyworkwiththeformcontrolsandthedataassociatedwiththem.
FulldetailsarelocatedintheSDKundertheClient-SideProgrammingReferencetopic.
OnLoadEventTheOnLoadeventoccursaftertheformhasloadedandthereforeitcannotpreventthewindowfromloading.
TheOnLoadeventcanbeusedtoapplylogicabouthowtheformshouldbedisplayed,tosetpropertiesonfields,andinteractwithotherpageelements.
SomeactionsthatcanbeperformedbyusingtheOnLoadeventincludethefollowing:PerformcalculationsbasedonchangingvaluesAlertausertoasituationDisablefieldsthatshouldnotbeupdatedExtendingMicrosoftDynamicsCRM2013Page112of14011/09/2014OnSaveEventTheOnSaveeventoccurswhenauserclickstheSaveorSaveandClosebuttonsorotheractionsthatcausetheformtobesaved,suchastheSavemethod.
Theeventalwaysoccurs,evenwhenthedataintheformhasnotchanged.
TheOnSaveeventdoesnotcorrespondtothestandardHTMLOnSubmitevent.
AscriptcandetectwhichactionisperformedtotriggertheformsavebyusingthegetSaveModemethodinthesaveeventargumentsretrievedfromthegetEventArgsmethodexecutioncontext.
TheOnSaveeventcanbecanceledtopreventthedatafrombeingsaved.
ThereforeitisverycommontousetheOnSaveeventtovalidatedata.
OnChangeEventTheOnChangeeventisavailableoneveryfield.
TheOnChangeeventrequirestwoconditionstobetrue:Thedatainthefieldmustchange.
Thefieldmustlosefocus.
Aftertheevent,thedatainthefieldwillbere-validated.
Thismeansthattheeventcannotbeusedtoenterinvaliddata.
SomeactionsthatcanbeperformedbyusingtheOnChangeeventincludethefollowing:Performcalculationstochangeotherfieldsbasedonchangingvalues.
Changetheformattingoffields,suchastelephonenumbers.
Implementdynamicoptionsets.
TabStateChangeEventThiseventoccurswhenatabisexpandedorcollapsed,andenablestheexecutionofcodetobedeferreduntilatabisexpanded.
ThiseventisimportantifascriptmodifiesthesrcpropertyofanIFRAMEcontrol.
AnIFRAMEwillberefreshedwhenthetabisexpandedandanychangestothesrcpropertywillberemoved.
Therefore,ifcodeinteractswiththesrcpropertyofanIFRAME,itshouldalwaysbeincludedintheTabStateChangeeventinsteadoftheOnloadevent.
OnReadyStateCompleteEventTheOnReadyStateCompleteeventindicatesthecontentoftheIFRAMEhasloadedandcanbeaccessedincode.
AnyscriptthatinteractswiththecontentsofanIFRAMEwillfailunlessthecontentsoftheIFRAMEhascompletedloading.
ThiseventprovidesalocationtoincludescriptsthatwillexecuteafterthecontentsoftheIFRAMEhavecompletedloading.
UsingJavaScriptinFormsTouseafunctioninaJavaScriptlibrary,theJavaScriptlibrarymustfirstbecreatedasaJscriptwebresource.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page113of140TheJscriptwebresourcemustthenbeaddedtotheform.
TherequiredfunctionwithintheJscriptwebresourceisthenspecifiedagainsttherequiredevent.
LimitationsJScriptwebresourcescanbeassociatedto,andloadedwithanentityform,uptoamaximumof50.
Afterassociatingalibrarytotheform,itisavailabletoalleventsintheform.
Foranyevent,upto50functionscanbeassignedaseventhandlers.
AssociateFunctionsatRunTimeFunctionscanbeaddedtotheOnChangeattributeandtheformOnSaveeventsatrun-timebyusingeitherofthefollowingmethods:Xrm.
Page.
data.
entityattribute.
addOnChangeXrm.
Page.
data.
entity.
addOnSaveWhenthesemethodsareused,thefunctionisaddedatthebottomoftheeventhandlerpipeline.
ThecorrespondingremoveOnChangeandremoveOnSavemethodscanbeusedtoremovefunctionsaddedinthismanner.
FormTypesInMicrosoftDynamicsCRM,severaldifferentformtypescanbeusedtoviewandeditentities.
Thefollowingtabledescribestheformtypesavailable.
TheformsareaccessedbyusingtheXrm.
Page.
uiobjectandtheirformtypecanbequeriedwiththeXrm.
Page.
ui.
getFormType()method.
Thisreturnsanumberthatcorrespondstothetypeofform.
ValueFormType0Undefined1Create2Update3ReadOnly4Disabled5QuickCreate(Deprecated)6BulkEdit11ReadOptimized(Deprecated)Note:QuickCreateformsreturn1.
Thevalue5wasusedforanearliertypeofquickcreateformthatwasremovedinCRM3.
0.
ExtendingMicrosoftDynamicsCRM2013Page114of14011/09/2014ExecutioncontextasaParameterWhenyouregisterafunctionforaneventhandleryouhavetheoptiontopassanexecutioncontextobjectasthefirstparametertothefunction.
Thisobjectcontainsmethodsthatallowsyoutomanagedvariablesyouwishtosharewithothereventhandlersandthesaveevent.
AccessingContextOutsideofFormGetGlobalContextTheGetGlobalContextfunctionreturnsthesamecontextobjectfoundintheXrm.
Page.
context.
Whenyouneedcontextinformationoutsideaform,includeareferencetotheClientGlobalContext.
js.
aspxpageinanHTMLwebresource.
ClientGlobalContext.
js.
aspxYoucanusetheGetGlobalContextfunctionwhenyouincludeareferencetotheClientGlobalContext.
js.
aspxpagelocatedattherootofthewebresourcesdirectory.
Lesson6-5URLAddressableFormsOverviewURLaddressableelementsenableyoutoincludelinkstoMicrosoftDynamicsCRMforms,views,dialogs,andreportsinotherapplications.
Inthismanner,youcaneasilyextendotherapplications,reports,orwebsitessothatuserscanviewinformationandperformactionswithoutswitchingapplicationsURLAddressableFormsandViewsAllentityformsandviewsaredisplayedinthemain.
aspxpage.
Querystringparameterspassedtothispagecontrolwhatwillbedisplayed.
Forexample:Toopenanewaccountentityrecordformforon-premisesMicrosoftDynamicsCRM:http://mycrm/myOrg/main.
aspxetn=account&pagetype=entityrecordToopenanaccountentityrecordformforMicrosoftDynamicsCRMOnlinewheretheidis{91330924-802A-4B0D-A900-34FD9D790829}:http://myorg.
crm.
dynamics.
com/main.
aspxetn=account&pagetype=entityrecord&id=%7B91330924-802A-4B0D-A900-34FD9D790829%7DToopentheClosedOpportunitiesviewforMicrosoftDynamicsCRMOnline:http://myorg.
crm.
dynamics.
com/main.
aspxetn=opportunity&pagetype=entitylist&viewid=%7b00000000-0000-0000-00AA-000010003006%7d&viewtype=1039ExtendingMicrosoftDynamicsCRM201311/09/2014Page115of140YouwilltypicallyusethegetClientUrlmethodtoretrievetheorganizationrootUrlforbothon-premisesMicrosoftDynamicsCRMandMicrosoftDynamicsCRMOnline.
Togettheidvalueforanyrecord,usetheSendaLinkbuttonthecommandbar.
Thefollowingisanexampleofwhatwillbeopenedinyouremailapplication:.
TheidparameterpassedtotheURListheencodedidvaluefortherecord.
Inthisexampletheidvalueis{899D4FCF-F4D3-E011-9D26-00155DBA3819}.
TheencodedversionoftheGUIDsubstitutesopeningandclosingbrackets"{"and"}"with"%7B"and"%7D",respectivelyGettheURLforaViewOpentheviewyouwanttouse.
Inthecommandbar,clickSendaLink,andthenclickOfCurrentView.
PastethelinkintoNotepadandeditittoextractonlytheURLpartofthetextthatyouwant.
OpeningaDialogProcessbyUsingaURLAcommoncustomizationistoenableausertoopenaspecificdialogprocessinthecontextofaspecificrecord.
Forexample,youmightwanttoaddacustombuttontotheribbonforaspecificentityusingtheidvalueforcurrentrecordasaninputparameterforthedialogprocess.
Toopenadialogyouneedthefollowing:Theuniqueidentifierforthedialog.
Thelogicalnamefortheentitythedialogiscreatedfor.
TheuniqueidentifierfortherecordyouwanttohavethedialogrunagainstUsedas[organizationurl]/cs/dialog/rundialog.
aspxDialogId=[dialoguniqueidentifier]&EntityName=[entitylogicalname]&ObjectId=[uniqueidentifierfortherecord]FormParametersBydefault,MicrosoftDynamicsCRMletsaspecifiedsetofquerystringparameterstobepassedtoaform.
Youusetheseparameterstosetdefaultvalueswhenyoucreateanewrecordintheapplication.
Eachparametermustuseastandardnamingconventionthatincludesareferencetotheattributelogicalname.
Inyourapplications,youmaywanttopasscustomquerystringparameterstoanentityform.
Thistopicprovidesinformationabouthowyoucandefineasetofspecificparameternamesanddatatypesthatcanbeacceptedforaspecificentityform.
Therearetwowaystospecifywhichquerystringparameterswillbeacceptedbytheform:EditformpropertiesExtendingMicrosoftDynamicsCRM2013Page116of14011/09/2014EditformXMLQueryStringParametersThefollowingarethestandardquerystringparametersforthemain.
aspxpage:ParameterDescriptionetnThelogicalnameoftheentity.
Donotusetheetc(entitytypecode)parameterthatcontainsanintegercodefortheentity.
Thisintegercodevariesforcustomentitiesindifferentorganizations.
extraqsOptionalforforms.
Thisparametercontainsencodedparameterswithinthisparameter.
Whenanentityhasmorethanoneformdefined,youcanusethisparametertospecifywhichformtoopenbypassingtheencodedparameterformidwiththevalueequaltotheIDvalueoftheform.
Forexample,toopenaformwiththeIDof'6009c1fe-ae99-4a41-a59f-a6f1cf8b9daf',includethisvalueintheextraqsparameter:formid%3D6009c1fe-ae99-4a41-a59f-a6f1cf8b9daf%0D%0A.
pagetypeThetypeofpage.
Therearetwopossiblevalues:entityrecordDisplaysanentityrecordform.
entitylistDisplaysanentityview.
idOptionalforforms.
Usethiswhenyouopenaspecificentityrecord.
PassintheencodedGUIDidentifierfortheentity.
TheencodedversionoftheGUIDsubstitutesopeningandclosingbrackets"{"and"}"with"%7B"and"%7D",respectively,forexample{91330924-802A-4B0D-A900-34FD9D790829}is%7B91330924-802A-4B0D-A900-34FD9D790829%7D.
viewidRequiredforviews.
ThisistheIDofthesavedqueryoruserqueryentityrecordthatdefinestheview.
TheeasiestwaytogettheURLforaviewistocopyit.
viewtypeDefinestheviewtype.
Possiblevaluesareasfollows:1039Useforasystemview.
TheviewidrepresentstheIdofasavedqueryrecord.
4230Useforapersonalview.
TheviewidrepresentstheIdofauserqueryrecord.
CustomParametersWhenyoueditanentityform,ontheHometabintheFormgroup,clickFormProperties.
IntheFormPropertiesdialogbox,selecttheParameterstab.
Whenyouaddaparameteryoujustspecifyitsnameanddatatype.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page117of140Eachnameattributemustcontainatleastoneunderscore('_')character.
However,thenameofthequerystringparametercannotbeginwithanunderscore.
Thenamealsocannotstartwith'crm_'.
Itisstronglyrecommendthatyouusethecustomizationprefixofthesolutionpublisherasthenamingconvention.
Avalidquerystringparameternameattributevaluewouldbe'myISV_contact_specialvalue'.
Ifaquerystringparameterelementnameisnotunique,itmaybeoverwrittenbyanotherparameterdefinitionusingadifferentdatatype.
FieldsasParametersYoucanalsopasstheschemanameofanyfieldontheformasaquerystringparameter.
CRMwillautomaticallypopulatetheCRMfieldswiththevaluespassed.
EncodingInURLscertaincharacterssuchas&needtobeencodedsoastoensurethattheydon'tgetmisinterpretedasanyoftheotherpartsoftheURL.
ForQueryStringParameters,allcharactersincludedinthequerystringmustbeencodedusingtheencodeURIComponentmethod.
CommonencodedURIcomponents%3d(=)%26(&)UsetheJScriptdecodeURIComponentmethodtodecodethevaluespassed.
HandlingFormParametersWhenusingformlevelparameters,understandhowtheycanbeconsumedwithintheform.
ThiswillusuallybedoneontheOnLoadeventoftheformusingtheXrm.
Page.
context.
getQueryStringParametersmethodAspartoftheclient-sidecontext,thegetQueryStringParametersmethodenablesadevelopertocaptureanarrayofkeyvaluepairsrepresentingthequerystringargumentsthatwerepassedtothepage.
Lesson6-6BestPracticeBestPracticeThefollowingsectionsdescribebestpracticeswhenyouuseJavaScriptwithMicrosoftDynamicsCRM.
CommentsCommentyourcode.
ExtendingMicrosoftDynamicsCRM2013Page118of14011/09/2014DefineuniquenamesforyourJavaScriptfunctionsWhenyouaretheonlydeveloperforanHTMLpageyoucaneasilymanagethenamesoftheJavaScriptfunctionsyouuse.
InMicrosoftDynamicsCRM,othersolutionsmayaddJavaScriptfunctionstothepagewhereyourfunctionisused.
IftwoJavaScriptfunctionsonapagehavethesamename,thefirstfunctiondefinedisoverwrittenbythesecond.
Forthisreason,makesurethatyoudefineuniquenamesforyourJavaScriptfunctions.
Usetheprefixforyourpublisherwhennamingfunctions.
CreatevirtualfilestructureUseaconsistentnamingconventionfortheWebresourcesthatreflectavirtualfilestructure.
Thesolutionpublisher'sprefixwillalwaysbeincludedasaprefixtothenameofthewebresource.
ThiscanrepresentavirtualrootfolderforallWebresourcesaddedbythatpublisher.
Youcanthenusethebackslashcharacter(/)tosimulateafolderstructurethatwillbehonouredbytheWebserver.
Fromanotherwebresource,youcanthenuserelativeURLstoreferenceotherwebresourcese.
g.
NamespacedLibraryNamesAssociateeachfunctionwithaJScriptobjecttocreateakindofnamespacetousetocallfunctions,asshowninthefollowingexample.
//IftheMyUniqueNamenamespaceobjectisnotdefined,createit.
if(typeof(MyUniqueName)=="undefined"){MyUniqueName={};}//CreateNamespacecontainerforfunctionsinthislibrary;MyUniqueName.
MyFunctions={performMyAction:function(){//Codetoperformtheaction.
//Callanotherfunctioninthelibrarythis.
anotherAction();},anotherAction:function(){//Codeinanotherfunction}};Thenwhenusingthefunction,thefullnamecanbespecifiedasshowninthefollowingexample.
MyUniqueName.
MyFunctions.
performMyAction();ExtendingMicrosoftDynamicsCRM201311/09/2014Page119of140Ifcallingafunctionwithinanotherfunction,the"this"keywordcanbeusedasashortcuttotheobjectthatcontainsbothfunctions.
However,ifthefunctionisusedwithinanotherobject,suchasthedefinitionofacallbackfunctioninthesamelibrary,thefullnameshouldbeused.
AvoidusingunsupportedmethodsOntheInternet,youcanfindmanyexamplesorsuggestionsthatdescribeusingunsupportedmethods.
Thesemayincludeleveragingundocumentedinternalfunctionforpagecontrols.
Thesemethodsmayworkbutbecausetheyarenotsupportedyoucan'texpectthattheywillcontinuetoworkinfutureversionsofMicrosoftDynamicsCRM.
UsetheCustomCodeValidationTooltoidentifycodethatisusingunsupportedmethods.
Useacross-browserJavaScriptlibraryforHTMLwebresourceuserinterfacesAcross-browserJavaScriptlibrary,suchasjQuery,providesmanyadvantageswhendevelopingHTMLwebresourcesthatmustsupportmultiplebrowsers.
JavaScriptlibrarieslikejQueryprovideaunifieddevelopmentexperienceforallbrowserssupportedbyMicrosoftDynamicsCRM.
ThesecapabilitiesareappropriatewhenyouareusingHTMLwebresourcestoprovideuserinterfaces.
JavaScriptlibrarieslikejQueryprovideconsistentwaystointeractwiththeDocumentObjectModel(DOM).
DonotusejQueryforformscriptorcommandsWedonotrecommendorsupportusingjQueryforanypageswithintheapplication.
Thisincludesformscriptsandribboncommands.
Recognizelimitationsforcontentdeliverynetwork(CDN)librariesContentdeliverynetwork(CDN)JavaScriptlibrariesprovidemanyadvantagesforpublicwebsites.
BecausetheselibrariesarehostedontheInternet,youdonotneedtocreatewebresourcesthatcontainthecontentofthelibraries.
ForMicrosoftDynamicsCRMyoushouldconsiderthefollowingissuesbeforeyouuseaCDNJavaScriptlibrary.
UsersoftheMicrosoftDynamicsCRMforMicrosoftOfficeOutlookwithOfflineAccessclienthavethecapabilitytoworkwithnoInternetconnectionwhileworkingoffline.
IfyouaredependingonanInternetconnectionforyourJavaScriptlibraries,yourcodewillfail.
SomeorganizationswillrestrictInternetaccessforemployees.
UnlesstheyconfigurethenetworktoallowaccesstotheCDNlibrarysites,yourcodemayfailforthoseorganizations.
ThealternativetousingCDNlibrariesistocreateascript(JavaScript)webresourcewiththecontentsofthelibrary.
Becausewebresourcesareorganization-ownedentitiestheywillbesynchronizedwhenaMicrosoftDynamicsCRMforOutlookwithOfflineAccessusergoesoffline.
BecausethesewebresourcesnowbecomepartoftheapplicationtheywillnotbeblockedifanorganizationrestrictsaccesstotheInternet.
UsefeaturedetectionwhenwritingfunctionsformultiplebrowsersExtendingMicrosoftDynamicsCRM2013Page120of14011/09/2014Evenwhenyouuseacross-browserlibrarylikejQuery,youneedtobeveryawareofdifferencesbetweenbrowsers.
Youcangenerallydetectwhichbrowserisbeingusedbyqueryingthenavigator.
useragentproperty.
Thisiscalledbrowserdetection.
Browserdetectionisnotagoodstrategyformostcasesbecauseitcan'ttakeintoaccountwhatfeaturesnewerversionsofabrowserhave.
Also,somebrowsersprovidethecapabilitytomodifythenavigation.
useragentpropertysothattheyappeartobeadifferentbrowser.
Featuredetectionistherecommendedapproach.
Bydetectingwhatfeaturesareavailable,youcancreatecodepathsforthebrowsersyousupportwithoutknowingexactlywhichbrowserisbeingused.
DonotaccesstheDOMJavaScriptdevelopersareusedtointeractingwithDocumentObjectModel(DOM)elementsincode.
Youmightusethewindow.
getElementByIdmethodorthejQuerylibrary.
YouarefreetousethesetechniquesinyourHTMLwebresources,buttheyarenotsupportedtoaccesselementsinMicrosoftDynamicsCRMapplicationpagesorentityforms.
Instead,accesstoentityformelementsareexposedthroughtheXrm.
Pageobjectmodel.
TheMicrosoftDynamicsCRMdevelopmentteamreservestherighttochangehowpagesarecomposed,includingtheIDvaluesforelements,sousingtheXrm.
PageobjectmodelprotectsyourcodefromchangesinhowpagesareimplementedUseasynchronousdataaccessmethodsWhenyouaccessdatabyusingtheMicrosoftDynamicsCRMwebservicesthatusetheRESTorSOAPendpointforwebresources,alwaysuseanXMLHttpRequestthatisconfiguredtoexecuteasynchronously.
Thereasonisthatthebrowseroperatesonasinglethread.
Ifthatthreadisbeingusedtoexecutealong-runningprocesssynchronouslythebrowserwillstopresponding.
Lesson6-7DebuggingJavaScriptOverviewEachbrowserprovidessomekindofdebuggingextension.
InternetExplorerprovidesdevelopertoolsyoucanusetodebugscriptsinMicrosoftDynamicsCRM.
YoucanalsouseMicrosoftVisualStudio.
WhenyouuseJavaScriptlibrariesinMicrosoftDynamicsCRM,yourlibrariesareaddedtoapagethatincludesmanylibraries.
Itcansometimesbedifficulttoisolateyourspecificlibraryinthedebuggingenvironment.
WhenusingdebuggingtoolsinInternetExplorer,ontheScripttab,expandtheavailablescriptsandfindtheonewiththenamethatcorrespondstothenameofyourJavaScriptwebresource.
Debuggingtoolsfordifferentbrowsershavesimilarcapabilities.
Onceyouhavefoundyourlibrary,youcansetabreakpointandrecreatetheeventthatshouldcauseyourcodetorun.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page121of140InternetExplorerTheInternetExplorerdevelopertoolscanbeopenedbypressingF12whenviewingapageusingInternetExplorer.
Beforestartingtodebugclient-sidescripts,makesurethedevelopmentsettingsaresetcorrectlyandthelatestcodefromtheserverisbeingdebuggedinsteadofthecachedscripts.
Thefollowingsectionslisttherecommendeddevelopmentsettingsfordebugging.
InInternetExplorer,setthefollowingoptions:Loadpagecontent="Everytime"Friendlyerrors=OffScriptdebugging=OnEnablingtheEveryVisittothePageFeaturePerformthesestepstoenabletheEverytimeIvisitthewebpagefeature:1.
StartInternetExplorer.
2.
SelectTools,andthenInternetOptions.
3.
OntheGeneraltabintheBrowsinghistorysection,clickSettings.
4.
EnabletheEverytimeIvisitthewebpageoption.
5.
ClickOK.
SettingScriptDebuggingandFriendlyErrorsOptionsInInternetExplorer,enablethescriptdebuggingoptionanddisablethefriendlyerrorsoption.
Performthesestepstosettheseoptions:1.
StartInternetExplorer.
2.
OntheToolsmenu,clickInternetOptions.
3.
ClicktheAdvancedtab.
4.
CleartheDisablescriptdebugging(InternetExplorer)option.
5.
CleartheShowfriendlyHTTPerrormessagesoption.
6.
ClickOK7.
CloseInternetExplorer.
OtherBrowsersForGoogleChrome,pressF12toopendevelopertools.
FirebugisapopularbrowserextensionforwebdevelopmentusingMozillaFirefox.
ForAppleSafari,youmustfirstchoosetheShowDevelopmenuinmenubarinAdvancedPreferences.
ThenyoucanchooseShowWebInspectorfromtheDevelopmenu.
WritemessagestotheconsoleUsingthewindow.
alertmethodwhendebuggingJavaScriptisstillacommonwaytotroubleshootcodeintheapplication.
Butnowthatallmodernbrowsersprovideeasyaccesstodebuggingtools,itisnotabestpractice,especiallywhenothersmightbeusingtheapplicationyouaredebugging.
ExtendingMicrosoftDynamicsCRM2013Page122of14011/09/2014Considerwritingyourmessagestotheconsoleinstead.
Thefollowingisasmallfunctionyoucanaddtoyourlibrariesthatyoucanusetosendanymessagesyouwanttoviewtotheconsolewhenitisopen.
functionwriteToConsole(message){if(typeofconsole!
='undefined'){console.
log(message);}}Unlikeusingthealertmethod,ifyouforgettoremoveanycodethatusesthisfunction,peopleusingtheapplicationwillnotseeyourmessages.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page123of140Module7–ClientSideCodeThekeyobjectivesofthismodulearetoprovideanunderstandingofthehowclientsidecodethatcanbeusedinDynamicsCRM.
ObjectivesThekeyobjectivesofthismoduleareto:UnderstandODataandSOAPUnderstandJSONUnderstandJQueryLesson7-1DataaccessusingJavaScriptOnecommonneedfordevelopersisusingJavaScriptistoretrievedataforMicrosoftDynamicsCRMplatform.
EarlyeditionsofMicrosoftDynamicsCRMusedFetchXMLtoretrieveinformationfromtheplatformontheclientsidewhereasFetchXMLisusedfrequentlyitcanbechallengingsometimestoconstructandtestthesequeries.
TherearetwowebservicesyoucanusewithintheapplicationtoaccessdatabyusingJavaScript.
OData(REST)endpointPreviouslyknownasthe'RESTendpointforwebresources'.
YoucanusetheODataendpointtoexecuteHTTPrequestsbyusingawebservicethatisbasedonaUniformResourceIdentifier(URI).
"RESTful"webservicesarepopularbecausetheycanmakeprogrammingeasier.
ThecurrentimplementationoftheODataendpointislimitedtocreate,retrieve,updateanddeleteoperations.
OneoftheadvantagesoftheODataendpointisthatitimplementstheODataprotocol,whichprovidesthewaytoqueryandupdatedata.
WhenyouuseJavaScript,youusuallyretrieveobjectsinJavaScriptObjectNotation(JSON)format.
Thismakestheresultseasiertoworkwith.
TheprimarylimitationoftheODataendpointisthatyoucannotusetheIOrganizationService.
Executemethodtoexecutemessages(RequestandResponseclasses).
YouusetheSOAPendpointforwebresourcestoexecutemessages.
SOAPendpointTheSOAPendpointletsyouexecutemessagesbecausetheRESTendpointdoesnotyetallowthis.
YoucanalsocalltheCreate,Retrieve,Update,DeleteandRetrieveMultiplemethodsofthiswebservice,butusingitisnotaseasyasusingtheRESTendpoint.
ExtendingMicrosoftDynamicsCRM2013Page124of14011/09/2014WhichendpointtouseFigure17-DataAccessArchitectureTheRESTendpointprovidesanalternativetothewindowscommunicationfoundationSOAPendpointbuttherearecurrentlysomelimitationsbeawaretheselimitationsarenotalimitationoftheODataprotocol.
ThelimitationsoftheimplementationoftheODataprotocolwithinMicrosoftDynamicsCRM.
Onlycreate,retrieve,updateanddeleteactionsmaybeperformedonentityrecordmessagesthatrequiretheexecutemessagecannotbeperformed.
Associateanddisassociateactionscanbeperformedbyusingnavigationproperties.
ThefollowingtabledescribestheappropriatewebservicetousedependingonthetaskyouneedtoperformTaskWebServiceCreate,Retrieve,UpdateandDeleterecords.
ODataendpointAssociateandDisassociaterecordsODataendpointAssignRecordsModernappSOAPendpointRetrieveMetadataModernappSOAPendpointExtendingMicrosoftDynamicsCRM201311/09/2014Page125of140ExecuteMessagesModernappSOAPendpointLesson7-2ModernappSOAPendpointModernappSOAPendpointformodernapplicationsUnliketheRESTendpointforwebresources,theSOAPendpointusestheOrganizationservice.
ThisisthesameserviceusedwhenwritingapplicationsthatexistoutsideoftheMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnlineapplication.
Thedifferencesare:RequestsaresenttoadifferentURL:/XRMServices/2011/Organization.
svc/web.
Authenticationforwebresourcesisprovidedbytheapplication.
Ifyouusethisendpointoutsidetheapplication,youmustimplementauthentication.
ThemodernappSOAPendpointprovidesaccesstoallthemessagesdefinedintheOrganizationservice.
However,onlythetypesdefinedintheWebServicesDescriptionLanguage(WSDL)willbereturned.
Thereisnostrongtypesupport.
WhilethemodernappSOAPendpointisalsocapableofperformingcreate,retrieve,updateanddeleteoperations,theODataendpointprovidesabetterdeveloperexperienceforclientapplicationextensions.
InthisreleaseofMicrosoftDynamicsCRM,themodernappSOAPendpointprovidesanalternativewaytoperformoperationsthattheODataendpointisn'tcapableof.
UsingtheSOAPendpointwithJavaScriptWithJavaScript,youwillbeusingXmlHttpRequesttoPOSTrequeststotheservice.
ThebodyoftherequestmustcontaintheXMLappropriateforthemessageyouareusing.
YoumustalsoparsetheXMLreturnedinaresponse.
WithXmlHttpRequest,itispossibletomakesynchronousrequests.
Howeveritishighlyrecommendedtoalwaysuseasynchronousrequests.
Becausemanuallyconfiguringeachrequestisverytimeconsuming,itisexpectedthatyouwillreuseexistinglibrariesorcreateyourown.
MicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnlinedoesnotprovideacomprehensivesetofJavaScriptlibraries.
ThespecificsyntaxusedwhencallingJavaScriptlibrariesdependsonhowtheyaredesigned.
TheSDKprovidesaMicrosoftVisualC#solutioncalledSoapLoggerthatletsyoucapturetheXMLsentandreceivedwhenyouperformoperationswiththeMicrosoftDynamicsCRMwebservicesbyusingVisualC#.
Withthisinformation,youcanbuildyourownJavaScriptlibraries.
MicrosoftCRMMVPJamieMileyhasreleasedaCRM2011JscriptSoapRequestFormatterprogramonCodePlexthattakesthisastepfurtherandactuallygeneratesJavaScriptlibrariesforyou.
ExtendingMicrosoftDynamicsCRM2013Page126of14011/09/2014Lesson7-3ODATAWhatIsODataTheODataendpointusestheOpenDataprotocol.
Thisprotocolimplementsa'RESTful'designpattern.
RESTrepresentsRepresentationalStateTransfer.
RESTisanarchitecturalstyleinwhicheveryresourceisaddressedbyusingauniqueURI.
InMicrosoftDynamicsCRM,aresourcecanbeanentitycollectionorarecord.
MicrosoftDynamicsCRM2013usestheWindowsCommunicationFoundation,orWCF,dataservicesframeworktoprovideanopendataprotocolendpointthatisaREST-baseddataservice.
Thisendpointiscalledtheorganizationdataservice.
InCRM2013ODataendpointhasbeenextendedtosupportexternalauthenticationwhichisaparticularimporttoexternalclients.
RESTRESTrepresentsRepresentationalStateTransfer.
RESTisanarchitecturalstyleinwhicheveryresourceisaddressedbyusingauniqueURI.
InMicrosoftDynamicsCRM,aresourcecanbeanentitycollectionorarecord.
RESTworksthewaytheInternetworks.
YouinteractwithresourcesbyusingHTTPverbssuchasGET,POST,MERGE,andDELETE.
VariouslibrariescanbeusedtoprocesstheHTTPrequestsandresponses.
RESTprovidesastandardinterfacethatyoucanusewithanyprogramminglanguage.
RESTallowsforeithersynchronousorasynchronousprocessingofoperations.
ThecapabilitytoperformasynchronousoperationsmakesRESTwellsuitedforwebresourcesandscriptsusedinMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnline.
MicrosoftDynamicsCRMImplementationofODataMicrosoftDynamicsCRM2013usestheWindowsCommunicationFoundation(WCF)DataServicesframeworktoprovideanOpenDataProtocol(OData)endpointthatisaREST-baseddataservice.
ThisendpointiscalledtheOrganizationDataService.
InMicrosoftDynamicsCRM,theservicerootURIis:[YourOrganizationRootURL]/xrmservices/2011/organizationdata.
svcThisXMLdocumentusesconceptualschemadefinitionlanguage(CSDL)todescribetheavailabledata.
YouwilldownloadthisdocumentanduseittogeneratetypedclasseswhenyouusemanagedcodeorasareferenceforavailableobjectswhenyouuseJavaScript.
LimitationsTheODataendpointprovidesanalternativetotheSOAPendpoint,buttherearecurrentlysomelimitations.
OnlyCreate,Retrieve,Update,andDeleteactionscanbeperformedonentityrecords.
MessagesthatrequiretheExecutemethodcannotbeperformed.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page127of140Associateanddisassociateactionscanbeperformedbyusingnavigationproperties.
TheODataprotocolisnotfullyimplemented.
Somesystemqueryoptionsarenotavailable.
Youcannotuselatebindingwithmanagedcodeagainstcustomentities,attributes,orrelationshipsthatdidnotexistwhenthecodewaswritten.
YouwilltypicallyuseWCFDataServicesClientDataServiceclasseswhileprogrammingbyusingmanagedcode.
Theseclassesallowforearlybindingsothatyougetstronglytypedclassesatdesigntime.
Theonlyentitiesavailabletoyouarethosedefinedinthesystemwhentheclassesweregenerated.
Thismeansthatyoucannotuselatebindingtoworkwithcustomentities,attributes,orrelationshipsthatwerenotincludedintheWCFDataServicesClientDataServiceclasseswhentheyweregeneratedODataEntityDataModel(EDM)ToprovideaconsistentsetofURIsthatcorrespondstotheentitiesusedinMicrosoftDynamicsCRM,anEntityDataModel(EDM)organizesthedataintheformofrecordsof"entitytypes"andtheassociationsbetweenthem.
TheMicrosoftDynamicsCRMEDMisdescribedinanODataServiceMetadatadocumentavailableatthefollowingpath:[YourOrganizationRootURL]/xrmservices/2011/organizationdata.
svc/$metadataThisXMLdocumentusesconceptualschemadefinitionlanguage(CSDL)todescribetheavailabledata.
YouwilldownloadthisdocumentanduseittogeneratetypedclasseswhenyouusemanagedcodeorasareferenceforavailableobjectswhenyouuseJavaScript.
AJAXAJAX(AsynchronousJavaScriptandXML)isawebdevelopmenttechniqueusedtocreateinteractivewebapplications.
ServerrequestsaremadefromthebrowserinthebackgroundusinganXmlHttpRequestobject.
Whileyoucansendsynchronousrequests,therecommendedpracticeistosendasynchronousrequests.
AsynchronousrequestsrequiretwoJScriptfunctions,onetosendtherequestandasecond"callback"functiontoprocessaresponse.
WhenusingRESTinthecontextofAJAX,thereareahandfuloftopicstounderstand,JSON,XmlHttpRequest,andJQuery.
SDK.
REST.
jsTheSample:Create,retrieve,update,anddeleteusingtheODataendpointwithJavaScriptincludesanSDK.
REST.
jslibrarythatprovidesanexampleofareusablelibrarythatcanfurthersimplifyusingtheODataendpoint.
AccessingMicrosoftDynamicsCRMEntityDataEachMicrosoftDynamicsCRMentityisrepresentedintheconceptualschemadefinitionlanguage(CSDL)asacollectionusingtheelement.
ThenameofeachcollectionfollowsthenamingExtendingMicrosoftDynamicsCRM2013Page128of14011/09/2014conventionof[EntitySchemaName]+Set.
ThisnameisusedintheURLtoaccessacollectionofentityrecords.
AlistofallthecollectionsavailableislistedwhenyouviewtheservicerootURI.
Tocreateaqueryyouappendyourcriteriatotheresourcepath.
Forexample,inyourbrowseryoucanviewtheATOMAccountentityrecords(called"entries")usingthepathinthefollowingexample[YourOrganizationRootURL]/XRMServices/2011/OrganizationData.
svc/AccountSetAfteryouviewthelistofaccountrecords,youcanseehoweachofthemcanbereferencedindividuallyusingtheURLsyntaxinthefollowingexample[YourOrganizationRootURL]/XRMServices/2011/OrganizationData.
svc/AccountSet(guid'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')ODataQueryoptionsYoucanrefinetheresultsofyourquerybyusingsystemqueryoptions.
ThefollowingtableliststhequerystringoptionsdefinedintheODataprotocolthatareimplementedintheODataendpointforMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnline.
OptionDescription$expandDirectsthatrelatedrecordsshouldberetrievedintherecordorcollectionbeingretrieved.
ifyouwanttoretrieverelatedrecords,locatethenameoftheentityrelationshipthatdefinesthisrelationship,youmighthavetoviewtheentityrelationshipinformationintheapplicationtocorrectlyidentifytherelationshiportheCDSL,theorganizationdataservice.
$filterSpecifiesanexpressionorfunctionthatmustevaluateto'true'forarecordtobereturnedinthecollection.
$orderbyDetermineswhatvaluesareusedtoorderacollectionofrecords.
Bydefaulttheorderisascending.
UseDASCtoreversetheorderandASCtoexplicitlysetthedefault$selectspecifiesasubsetofpropertiestoreturnandintheorderinwhichthecolumnsofdatashouldbeorganized.
Thisdefaultreturnallcolumnsisexpressedasselectequalsstar$skipSetsthenumberofrecordstoskipbeforeitretrievesrecordsinacollection.
$topDeterminesthemaximumnumberofrecordstoreturn.
MicrosoftDynamicsCRMdoesnotsupportusingthefollowingquerysystemoptions:Inlinecount,count,orformat.
Additionally,dateandarithmeticfunctionsarenotavailabletoMicrosoftDynamicsCRM2013.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page129of140Lesson7-4JSONWhatisJSONJavaScriptObjectNotation(JSON)formatisusedforserializingandtransmittingstructureddatamuchinthesamewaythatXMListypicallyused.
LikeXML,itistextbasedanddesignedtobereadablebyhumans.
ToconvertregularJScriptobjectsintotheJSONformatyouusetheJSON.
stringifymethod.
BecausethetextinJSONdefinesJScriptobjects,thetextcouldbeconvertedtoJScriptobjectsbyusingtheevalmethod.
However,thispracticecreatessecurityvulnerabilities.
YoushouldusetheJSON.
parsemethodinstead.
TouseJSONinMicrosoftDynamicsCRM,customizersordevelopersshouldcreateaJScriptwebresourcethatcontainstheminifiedcontentsofjson2.
js.
Thislibraryisavailableathttp://www.
json.
org/json2.
js.
HowisJSONUsedinMicrosoftDynamicsCRMMicrosoftDynamicsCRM2011usestheWindowsCommunicationFoundationDataServiceFrameworktoprovideanOpenDataProtocol(OData)endpointthatisaREST-baseddataservice.
ODatasendsandreceivesaction,databyusingATOMorJavaScriptobjectnotation,JSON.
ATOMisanXML-basedformatusuallyusedforRSSfeeds.
JSONisatextformatthatallowsforserializationofJavaScriptobjects.
IfusingJSONtouseODatainMicrosoftDynamicsCRM,customizersordevelopersshouldcreateaJScriptWebresourcethatcontainstheminifiedcontentsofjson2.
js.
IfJSONisbeingusedontheformlevel,addthejson2webresourcetotheJScriptlibraryontheform.
IfusingitwithinthecontextofawebresourcesuchasanHTML(WebPage)webresource,itwillneedtobeaddedasaJScriptwebresourceandreferredtousingtherelativepath.
XmlHttpRequestWithinthecontextofMicrosoftDynamicsCRM2013,theXMLHttpRequestisusedwhenusingODatatoperformoperationsagainstapplicationdata.
AnXmlHttpRequestprovidesinstructionstotheserverabouttheformatofanydatatobeincludedintheresponse.
BecausetheRESTendpointsupportsbothATOMandJSONformatsyouhavetheoptiontorequestdatatobereturnedintheXMLATOMformat.
However,withJScriptcodetheexpectedtypicalrequestwilluseJSONbecauseitiseasilyconsumableusingJScript.
ExampleThefollowingsampleusesJSONandXmlHttpRequesttocreateanewaccountrecord:varaccount={};account.
Name="SampleAccount";varjsonAccount=JSON.
stringify(account);ExtendingMicrosoftDynamicsCRM2013Page130of14011/09/2014varcreateAccountReq=newXMLHttpRequest();createAccountReq.
open("POST",Xrm.
Page.
context.
getClientUrl()+"/XRMServices/2011/OrganizationData.
svc/AccountSet",true);createAccountReq.
setRequestHeader("Accept","application/json");createAccountReq.
setRequestHeader("Content-Type","application/json;charset=utf-8");createAccountReq.
onreadystatechange=function(){createAccountReqCallBack(this);};createAccountReq.
send(jsonAccount);functioncreateAccountReqCallBack(createAccountReq){if(createAccountReq.
readyState==4/*complete*/){createAccountReq.
onreadystatechange=null;//avoidsmemoryleaksif(createAccountReq.
status==201){//SuccessvarnewAccount=JSON.
parse(createAccountReq.
responseText).
d;}else{//FailureerrorHandler(createAccountReq);}}};Lesson7-5JQUERYUseofjQueryUsejQuerywithHTMLwebresourcesWerecommendthatyouusejQuerytogetherwithHTMLwebresourcestoprovideuserinterfacesbecauseitisanexcellentcross-browserlibrary.
WithHTMLwebresources,youcontrolthelibrariesthatarepresentandthereisnorestrictionagainstmanipulatingtheDOM.
FeelfreetousejQuerywithinyourHTMLWebresources.
AvoidusingjQuerywithformscriptsorribboncommandsWedonotrecommendusingjQueryinformscriptsandribboncommands.
WhentouseJQueryMostofthebenefitprovidedbyjQueryisthatitallowsforeasycross-browsermanipulationoftheDOM.
Thisisexplicitlyunsupportedwithinformscriptsandribboncommands.
RestrictyourscriptstousetheXrm.
PageandXrm.
Utilitylibrariesavailableinformscriptsandribboncommands.
IfyoudecidetousetheremainingcapabilitiesofjQuerythatareusefulwithMicrosoftDynamicsCRMandincludetheabilitytouse$.
ajax,considerthefollowing:Forbestperformance,don'tloadjQueryinthepageifyoudonotneeditExtendingMicrosoftDynamicsCRM201311/09/2014Page131of140Using$.
ajaxtoperformrequestsagainsttheODataandModernAppsSOAPendpointissupported,buttherearealternatives.
Thealternativetousing$.
ajaxistousethebrowsersXMLHttpRequestobjectdirectly.
ThejQuery$.
ajaxmethodisjustawrapperforthisobject.
IfyouusethenativeXMLHttpRequestobjectdirectly,youdonotneedtoloadjQuery.
ConsiderusingSDK.
REST.
jsEachversionofjQuerythatisloadedinapagecanbeadifferentversion.
DifferentversionsofjQueryhavedifferentbehavioursandthesecancauseproblemswhenmultipleversionsofjQueryareloadedonthesamepage.
UseJQuerywithinMicrosoftDynamicsCRMTouseJQuerywithinMicrosoftDynamicsCRM2011forms,thedashboard,orthroughwebresourcesthatareusedfromotherpartsoftheapplication,youwillneedtomakeareferencetojQuery1.
5.
1.
js.
Todothis,createaJScriptwebresourceanduploadthescriptfilethatcomeswiththeMicrosoftDynamicsCRMSDK.
ThejQuery.
1.
5.
1.
jsisapopularJScriptlibrarythatincludescapabilitiestoperformasynchronousdataoperationsusingthe$.
ajaxobject.
OnceaddedasawebresourcethescriptscanbeaddedtotheformJScriptLibrary(ifusingJQueryontheformlevel)orwithinthecontextofanHTML(WebPage)resource.
WhenusingbothJQueryandJSONwithinaformJScriptLibraryoronanHTML(WebPage)webresource,itisimportanttoreferencethejQuery.
1.
5.
1.
jsbeforethejson2.
js.
ExampleThefollowingsampleusesJQUERYtocreateanewaccountrecord:varaccount={};account.
Name="SampleAccount";varjsonAccount=window.
JSON.
stringify(account);$.
ajax({type:"POST",contentType:"application/json;charset=utf-8",datatype:"json",url:Xrm.
Page.
context.
getClientUrl()+"/XRMServices/2011/OrganizationData.
svc/AccountSet",data:jsonAccount,beforeSend:function(XMLHttpRequest){//SpecifyingthisheaderensuresthattheresultswillbereturnedasJSON.
XMLHttpRequest.
setRequestHeader("Accept","application/json");},success:function(data,textStatus,XmlHttpRequest){account=data.
d;},error:function(XMLHttpRequest,textStatus,errorThrown){errorHandler(XMLHttpRequest,textStatus,errorThrown);}});ExtendingMicrosoftDynamicsCRM2013Page132of14011/09/2014Module8–UserInterfaceThismoduleexplainshowtoaddcustombutton,menuitemsandnavigationareassothatcustomsolutionsareincludedinMicrosoftDynamicsCRM.
ThismodulealsoexplainshowtomodifytheApplicationNavigationareainMicrosoftDynamicsCRM.
Thenavigationcanbereorganized,andareascanbeaddedsothatuserscannavigateintheapplication.
ObjectivesThekeyobjectivesofthismoduleareto:UnderstandhowtocustomisetheSiteMapUnderstandhowtocustomisetheCommandBarLesson8-1UserInterfaceChangesforCRM2013MicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnlinehasanupdateduserexperienceandoneofthemajorchangesisinthewaythatcommandsarepresented.
Inmostplacesinthewebapplicationyouwillseeacommandbarinsteadofaribbon.
CRMfortabletsalsousesdatadefinedasribbonstocontrolwhatcommandsareavailableusingacommandbarthatisoptimizedfortouch.
Thecommandbarprovidesanewwayofdisplayingcommandsandprovidesbetterperformance.
Lesson8-2SiteMapApplicationnavigationTheSiteMapprovidesthestructurefornavigationinMicrosoftDynamicsCRM.
Itisevaluatedtogetherwithyoursecurityprivilegestodisplaynavigationoptionsintheapplication.
IfyoursecurityprivilegesdonotprovidereadaccesstoanentityspecifiedintheSiteMap,thatnavigationoptionwillnotbedisplayedtoyou.
WebapplicationnavigationbarThefollowingimageshowsthewebapplicationnavigationbar,showingtheavailableareas.
ThedefaultareasareSFA(SALES),CS(SERVICE),MA(MARKETING),Settings(SETTINGS),andHLP(HELP).
Figure18-WebapplicationnavigationbarExtendingMicrosoftDynamicsCRM201311/09/2014Page133of140Selectableareasappearatthebottomofthenavigationbar.
Whenanareaisselectedtheareadisplaysastheselectedarea.
Themostrecentlyusedsubareaforthatareaisautomaticallyshown.
Whentheselectedareaisclickedortapped,theavailablegroupsandsubareasaredisplayedasshowninthefollowingimage.
Figure19-GroupsandSub-AreasInthisimagetheSFAareaisselectedandthegroupsMyWork(MyWork),Customers(Customers),andSFA(Sales)arevisible.
Toviewtheremaininggroupsandsubareasusersmustscrolltotheright.
Eachgroupcontainsanumberofsubareas.
Whenasubareaisselected,thecontentdefinedinthesitemapforthatsubareaisdisplayedbelowthenavigationMicrosoftDynamicsCRMforOutlooknavigationThefollowingdiagramshowstheCRMforOutlooknavigation.
MicrosoftOutlookpresentseachnavigationareainalphabeticalorderinatreeviewinsteadofusingtheorderspecifiedintheSiteMap.
Eachpersoncanchoosetopositionthereadingpaneatthebottomasshownorontheside.
Theycanalsochoosenottoshowit.
Eachentitycanbeconfiguredtodeterminewhetheritwilldisplaythereadingpane.
Figure20-CRMforOutlookNavigationExtendingMicrosoftDynamicsCRM2013Page134of14011/09/2014ConfigurationoptionsavailablewiththeSiteMapCommonlyperformedcustomisationsthatyoucanperformbyusingtheSiteMapare:EditlabelsAddorchangeiconsAddorremoveelementsGrouplinkswithinareasAddnewpagestoanareaSiteMapSchemaThefollowingXMLoutlinedescribesthehighlevelstructureoftheSiteMap.
EachelementintheSiteMaphasattributesthatcontrolthebehaviourandappearanceoftheelements.
SiteMapEditorsUsingathird-partysitemapeditorcanfacilitateeditingthesitemap.
ApopularoneisincludedintheToolboxforDynamicsCRM2011releasedbyMicrosoftCRMMVPTanguyTouzardonCodeplex.
ToolsthatworkedwithCRM2011willworkwithCRM2013.
ExtendingMicrosoftDynamicsCRM201311/09/2014Page135of140Lesson8-3CommandBarCommandBarandRibbonDiffXMLTheribbonisstilldisplayedinthewebapplicationforcertainentityformsanditisstillusedforlistviewsinMicrosoftDynamicsCRM2013forMicrosoftOfficeOutlook.
BoththecommandbarandtheribbonusethesameunderlyingRibbonDiffXMLdatatodefinewhatcommandstodisplay,whenthecommandsareenabled,andwhatthecommandsdo.
Fordevelopers,theRibboncommandsprovideflexibilityandadditionalfunctionalityincluding:AbilitytoAdd,Remove,Override,orDisablecontrolsRibbonEditorsTheSDKdescribestheprocessofeditingtheribbonbyeditingthecustomization.
xmlfiledirectly.
Severalpeoplehavecreatedribboneditorsthatprovideauserinterfacetomakeeditingtheribboneasier.
TheRibbonWorkbenchforDynamicsCRM2013byDevelop1isrecommended.
RibbonDiffXMLSchemaFigure21-RibbonDiffXMLSchemaThechangedefinitionsthatyouspecifyareappliedatruntimewhentheribbonisdisplayedintheapplication.
Allofyourchangeswillbeintheorelements.
TheseelementsareappliedoverthedefaultribbondefinitionsprovidedbyMicrosoftDynamicsCRM2013andMicrosoftDynamicsCRMOnline.
ExtendingMicrosoftDynamicsCRM2013Page136of14011/09/2014RibbonsAvailableEntityribbonsAllentitiesuseacommonribbondefinitioncalledtheEntityRibbonTemplate.
Whenyoucreateacustomentity,theribbonyouseeisthedefaultribbondefinedbytheentityribbontemplate.
Eachsystementityhasaseparatedefinitionthatbuildsupontheentityribbontemplatedefinition.
GridribbonsTheentitygridribbonisacollectionoftabsthathaveanIdattributevaluebeginningwithMscrm.
HomepageGrid.
.
Forexample,thetabwiththetext"Accounts"onanaccountentitygridisMscrm.
HomepageGrid.
account.
MainTab.
SubgridribbonsTheentitysubgridribbonisacontextualgroupwithacollectionoftabsthathaveanIdattributevaluebeginningwithMscrm.
SubGrid.
.
Forexample,thetabwiththetext"Accounts"onaccountentitysubgridisMscrm.
SubGrid.
account.
MainTab.
FormribbonsEachentitycanhavemultipleforms.
Youcandefinechangestotheformribbonforallformsforthatentitybyaddingyourdefinitionattheentitylevel.
BasichometabThebasichometabisdisplayedonthemainapplicationribbonwheneveranalternativetabisnotdefinedbecauseofentitycontextoradisplayrulethatsuppressesitforspecificpages.
Forexample,thistabisdisplayedwhenyouviewtheMicrosoftDynamicsCRMHelp.
TheIdofthebasichometabisMscrm.
BasicHomeTab.
MicrosoftDynamicsCRMforMicrosoftOfficeOutlookribbonsMicrosoftOfficeOutlook2007donotdisplayaribbon.
MicrosoftOfficeOutlook2010usestheribbon.
YoucanuseMicrosoftDynamicsCRMribbondefinitionstoaddcontrolstoallofthem.
MicrosoftOfficeOutlook2007TheMicrosoftDynamicsCRMforMicrosoftOfficeOutlookcontrolstosupportolderversionsofMicrosoftOfficeOutlooktoolbarsandmenusaredefinedastabswiththeIdvaluesofMscrm.
LegacyOfficeToolbarandMscrm.
LegacyOfficeMenubar,respectively.
MicrosoftOfficeOutlook2010ExtendingMicrosoftDynamicsCRM201311/09/2014Page137of140TheMicrosoftDynamicsCRMforMicrosoftOfficeOutlookcontrolstosupportMicrosoftOfficeOutlook2010toolbarsandmenusaredefinedastabswiththeIdvaluesofMscrm.
Outlook14GlobalToolbarandMscrm.
Outlook14GlobalMenubar,respectively.
OtherribbonsSeveralotherspecialpurposeribbontabsandacontextualgrouparedefinedbyMicrosoftDynamicsCRM.
Eachtabisassociatedwithaspecificthatcontrolswhentheywilldisplay.
Thefollowingtableliststhesetabs.
TabRootIdDescriptionWebResourceEditpagetab.
Mscrm.
WebResourceEditTabDisplayswheneditingWebresourceswithinasolution.
FormEditortabMscrm.
FormEditorTabProvidesSave,Edit,Select,andViewgroupsofactionsforentityforms.
FormEditorInserttabMscrm.
FormEditorInsertTabProvidesbuttonstoinsertSections,Tabs,andControlsinentityforms.
DashboardHomepagetabMscrm.
DashboardTabDisplaysintheWorkplacearea.
VisualizationToolsContextualGroupMscrm.
VisualizationToolsDisplayswhentheNewChartbuttonisclickedontheChartstabdisplayedintheentitygridribbon.
AptbookTabHomepagetabMscrm.
AptbookTabDisplayswhenviewingtheServiceCalendarintheServicearea.
AdvancedFindtabMscrm.
AdvancedFindDisplaysintheAdvancedFindwindow.
DashboardEditortabMscrm.
DashboardEditorTabDisplayswheneditingadashboard.
DocumentstabMscrm.
DocumentsTabDisplaysifSharePointintegrationhasbeenenabledfortheorganization.
ChartEditortabMscrm.
VisualizationDesignerTabDisplayswheneditingachartfromthesolutionswindow.
SearchToolsContextualGroupMscrm.
ArticleSearchDisplayswhenviewingtheKBarticleentity.
ExtendingMicrosoftDynamicsCRM2013Page138of14011/09/2014CustomActionsThedefault,anapplicationcommandbarorribbonisdefinedbyMicrosoftDynamicsCRMmetadata.
Thisdefaultdatacannotbechanged,butyoucanincludedefinitionsofspecificactionsthatwilloverridethedefaultribbonTypesofCustomActionsTherearetwotypesofcustomactionsforribbons:Definesanactiontoaddorreplaceitemsintheribbon.
RemovesanexistingribbonelementfrombeingprocessedfortheribbonCustomActionsAcustomactionisastatementofhowyouwanttochangethedefaultribbondefinition.
Itisevaluatedandappliedtotheribbonatruntime.
Tosetthecontextforacustomaction,youmustincludeinformationaboutthelocationoftheitemsthatyouwanttochange.
UsetheLocationattributetospecifywhereyourchangeapplies.
Whenyouaddanewribbonelement,yourefertothecontainingelement,forexample,anexistingtaborgroup.
AcustomactionmustincludeaCommandDefinition.
HideCustomActionsAisastatementthatyouusewhenyouwanttoremoveanexistingribbonelementsothatitisnotrendered.
Thisdoesnothidetheribbonelement,itactuallyremovestheribbonelementatruntimesothatitdoesnotexistintheribbonCommandDefinitionAribboncommanddefinesthreethings:EnableRules:Specifieswhenaspecificribboncontrolisenabled.
DisplayRules:Specifieswhenaspecificribbonelementisvisible.
Actions:Specifieswhatcodeexecuteswhenaribboncontrolisused.
RuleDefinitions:EnableRulesWhenconfiguringRibbonelementsyoucandefinespecificrulestocontrolwhentheribbonelementsareenabled.
Theelementisusedasfollows:ExtendingMicrosoftDynamicsCRM201311/09/2014Page139of140Usethe/RuleDefinitions/EnableRules/EnableRuleelementtodefinerulescontrollingwhentheribbonelementshouldbeenabled.
Usethe/CommandDefinitions/CommandDefinition/EnableRules/EnableRuleelementtoassociatespecificenablerulestoacommanddefinition.
WhatdoesenabledmeanWiththecommandbar,commandsthataredisabledarehidden.
Withtheribbon,commandsthataredisabledarevisiblebutdonotrespondtoeventsControlwhenribbonelementsareenabledEnablerulesareintendedtobere-used.
Bydefiningthemwithruledefinitions,youcanusethesameenableruleformanycommanddefinitions.
Whenmorethanoneenableruleisdefinedforacommanddefinition,alloftheenablerulesmustevaluateastruefortheribbonelementtobeenabled.
AllEnablerulesprovideanoptionalattributetospecifywhetherthedefaultvalueoftheruleistrueorfalseandanoptionalInvertResultattributetoallowforreturninganegativeresultwhentheitembeingtestedreturnstrue.
RuleDefinitions:DisplayRulesWhenconfiguringribbonelements,youcandefinespecificrulestocontrolwhentheribbonelementswilldisplay.
Usethe/RuleDefinitions/DisplayRules/elementtodefinerulescontrollingwhentheribbonelementshouldbedisplayed.
Usethe/CommandDefinitions/CommandDefinition/DisplayRules/elementtoassociatespecificdisplayrulestoacommanddefinition.
ControlwhenribbonelementsaredisplayedBydefiningdisplayrulesinruledefinitions,youcanusethesamedisplayruleformanycommanddefinitions.
Whenmorethanonedisplayruleisdefinedforacommanddefinition,allofthedisplayrulesmustevaluateastruefortheribbonelementtobedisplayed.
AlldisplayrulesprovideanoptionalattributetospecifywhetherthedefaultvalueoftheruleistrueorfalseandanoptionalInvertResultattributetoenablereturninganegativeresultwhentheitembeingtestedreturnstrue.
RuleDefinitions:ActionsDefinetheactionstobeperformedbyacommandbarorribboncontrolinaelementtogetherwithrulesthatcontrolwhetherthecontrolisenabledorvisibleintheribbon.
ExtendingMicrosoftDynamicsCRM2013Page140of14011/09/2014ARibboncontrolcanperformtwotypesofactionandmayincludemultipleactions:JavaScriptFunctions:AelementreferencesafunctiondefinedinaJScriptWebresource.
OpenaURL:TheribbonopensaURLusingthevaluefromanAddressattributeintheelement.
Additionalparameterscanpassinformationabouthowwhatquerystringparametersarepassedandthemodeinwhichthewindowopens.
IMIDC发布了6.18大促销活动,针对香港、台湾、日本和莫斯科独立服务器提供特别优惠价格最低月付30美元起。IMIDC名为彩虹数据(Rainbow Cloud),是一家香港本土运营商,全线产品自营,自有IP网络资源等,提供的产品包括VPS主机、独立服务器、站群独立服务器等,数据中心区域包括香港、日本、台湾、美国和南非等地机房,CN2网络直连到中国大陆。香港服务器 $39/...
Megalayer 商家在开始看到有提供香港服务器、香港站群服务器的时候有介绍过,后来就一直没有怎么关注。但是前几天有看到网友使用到他们家的美国独立服务器问其如何的,但是我没有使用过就不好评论,这不前几天也有介绍到Megalayer美国独立服务器。以及我们也有看到商家有提供美国站群服务器和美国大带宽服务器产品,可选30M不限制流量CN2优化线路,以及100M不限制流量国际带宽线路。新年元旦后,Me...
老鹰主机HawkHost是个人比较喜欢的海外主机商,如果没有记错的话,大约2012年左右的时候算是比较早提供支付宝付款的主机商。当然这个主机商成立时间更早一些的,由于早期提供支付宝付款后,所以受众用户比较青睐,要知道我们早期购买海外主机是比较麻烦的,信用卡和PAYPAL还没有普及,大家可能只有银联和支付宝,很多人选择海外主机还需要代购。虽然如今很多人建站少了,而且大部分人都用云服务器。但是老鹰主机...
plugin-container.exe为你推荐
电子行业动态跟踪报告版本itunes空调iphone支持ipad支持ipad支持ipad地址163重庆网通重庆联通宽带eacceleratorW3S是什么意思photoshop技术什么是ps技术
域名注册申请 免费com域名申请 免费ftp空间 外国域名 圣诞节促销 网通代理服务器 网盘申请 网站挂马检测工具 个人空间申请 qq数据库下载 免空 idc查询 如何登陆阿里云邮箱 windowsserver2008r2 web服务器 发证机构 qq空间登录首页 ibm服务器机柜 电脑主机嗡嗡响 灵动鬼影实录1 更多