Created
March 5, 2022 02:17
-
-
Save TeaDrivenDev/ee4e70e8a2cbdbfa570fcfcfcfc5c71f to your computer and use it in GitHub Desktop.
A simple plugin for Dynamics CRM 2011 in F#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace FSharp | |
open System | |
open Microsoft.Xrm.Sdk | |
type TestPlugin() = | |
interface IPlugin with | |
member this.Execute serviceProvider = | |
let organizationServiceFactory = serviceProvider.GetService(typeof<IOrganizationServiceFactory>) :?> IOrganizationServiceFactory | |
let organizationService = organizationServiceFactory.CreateOrganizationService(System.Nullable()) | |
let context = serviceProvider.GetService(typeof<IPluginExecutionContext>) :?> IPluginExecutionContext | |
let account = context.PreEntityImages.["Image"] | |
let name = account.GetAttributeValue<string> "name" | |
let oldName = string name //if String.IsNullOrWhiteSpace(name) then "" else name | |
let record = new Entity("account", Id = context.PrimaryEntityId) | |
record.["name"] <- oldName + " Fsharped" | |
organizationService.Update record |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
don't worry about it! its good to know you got away from MSCRM. i think i will just stick to C# for these development task haha.