/scriptcs-dynamicscrm

Dynamics CRM scriptcs Script Pack

Primary LanguageC#OtherNOASSERTION

Dynamics CRM 2011 Script Pack

What is it?

A ScriptCs script pack for communication with Dynamics CRM 2011 / 2013 / 2015 OrganizationService. Only tested on-premise so far, but should work for online as well.

Read more on ScriptCs: http://scriptcs.net/

You can also get more info about Dynamics CRM Script Pack in this blogpost.

Usage

  1. Follow the instructions on http://scriptcs.net/ to install ScriptCs.
  2. Navigate to your script folder.
  3. Install the DynamicsCrm script pack using nuget to get the latest version.
scriptcs -install ScriptCs.DynamicsCrm
  1. Write your scriptfile

  2. Run your scriptfile

scriptcs scriptname.csx

Example script

Retrieves a specific account with current user:

var crm = Require<DynamicsCrm>();
var orgService = crm.GetOrganizationService("http://crm/XrmServices/2011/Discovery.svc", "organization unique name");
var account = orgService.Retrieve("account", new Guid("B39030B8-F736-E111-9E16-0800277C14DD"), new ColumnSet(true));
Console.WriteLine(account["name"]);

To specify the user:

var orgService = crm.GetOrganizationService("http://crm/XrmServices/2011/Discovery.svc", "organization unique name", "user", "password", "domain");

Online should also work by not setting the domain parameter.

To get discovery service address and organization unique name, Sign in to your CRM org and click Settings, Customization, Developer Resources. On Developer Resource page, find the discovery service address under Service Endpoints and organization unique name under Your Organization Information.