RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
dynamicsxrm的简单介绍

如何在Dynamic CRM 2011中使用自定义Workflow

实现步骤:

创新互联建站主营渝北网站建设的网络公司,主营网站建设方案,重庆APP开发公司,渝北h5小程序制作搭建,渝北网站营销推广欢迎渝北等地区企业咨询

创建自定义workflow activity ,实现对CRM数据更新。

创建自定义workflow,实现整个流程。

集成自定义workflow到CRM.

?

创建自定义workflow activity

启动 Microsoft Visual Studio 2010。

在"文件"菜单上,单击"新建",然后单击"项目"。

在"新建项目"对话框的"已安装的模板"窗格中,选择"Visual C#"下的"工作流",然后选择"活动库"。

指定解决方案的名称和位置,然后单击"确定"。

导航到"项目"菜单并选择"属性"。在"应用程序"选项卡上,指定".NET Framework 4"作为目标框架。

添加对 Microsoft.Xrm.Sdk.dll 和 Microsoft.Xrm.Workflow.dll 程序集的引用。

删除项目中的 Activity1.xaml 文件。

将类文件 (.cs) 添加到项目中。在解决方案资源管理器中,右键单击项目,选择"添加",然后单击"类"。在"添加新项"对话框中,键入类的名称,然后单击"添加"。

打开类文件,然后添加以下 using 指令:

using System.Activities;

using Microsoft.Xrm.Sdk;

using Microsoft.Xrm.Sdk.Workflow;

使该类继承自 CodeActivity 类:

public class SampleCustomActivity : CodeActivity

通过添加Execute方法为类添加功能:

protected override void Execute(CodeActivityContext context)

{

//Activity code

Update Data here

}

编译项目以创建程序集 (.dll)。

?

?

创建自定义workflow

若要使用在 Microsoft Dynamics CRM 之外创建或修改的 XAML 工作流,请确保:

您的用户帐户在 Microsoft Dynamics CRM 中具有 Deployment Administrator权限。

在 Microsoft Dynamics CRM 服务器上启用了声明性工作流。 PowerShell($setting.AllowDeclarativeWorkflows="True")

创建工作流项目

在 Microsoft Visual Studio 中的"文件"菜单上,选择"新建",然后单击"项目"。

在"已安装模板"下展开"Visual C#",然后单击"工作流"。

单击"活动库",选择".NET Framework 4",为项目指定名称和位置,然后单击"确定"。

在"解决方案资源管理器"中,右键单击"活动库",然后单击"添加引用"。

单击"浏览",并找到 Microsoft.Xrm.Sdk.dll 和 Microsoft.Xrm.Sdk.Workflow.dll文件。选择这些文件并将其添加到项目。

进行工作流的定制。

集成自定义workflow到CRM.

使用插件注册工具来注册自定义工作流活动程序集到CRM。

构建 Plug-in Registration 工具。您可在SDK\Tools\PluginRegistration 文件夹中找到该工具的源代码。若要构建和使用插件注册工具,您必须首先安装 Windows Identity Foundation。

用户帐户必须具有系统定制员或系统管理员角色。

导入自定义的workflow

%TrainingKit%\Labs\WorkflowVS2010\Sources\Assets\WorkflowXamlTool.

打开 WorkflowXamlTool.sln, 修改workflow name and primaryentity ,执行solution.

?

var newWF = new Entity("workflow");

newWF.Attributes.Add("name", "On test 10311");

newWF.Attributes.Add("type", new OptionSetValue(1));

newWF.Attributes.Add("scope", new OptionSetValue(4));

newWF.Attributes.Add("category", new OptionSetValue(0));

newWF.Attributes.Add("primaryentity", "abc_dummy");

newWF.Attributes.Add("xaml", content2);

newWF.Attributes.Add("ondemand", true);

?

try

{

_serviceProxy.Create(newWF);

?

MessageBox.Show("Workflow successfully imported.", "Import",MessageBoxButtons.OK, MessageBoxIcon.Information);

}

catch (FaultException ex)

{

}

选择自定义xaml 文件,导入。

dynamics crm plugin 沙盒和数据库的区别

1.给类型赋值不同

CRM4 plugin给lookup赋值为空 :

Lookup lookupnull = new Lookup();

lookupnull.IsNull = true;

lookupnull.IsNullSpecified = true;

entity.Properties["new_storeroom_areaid"] = lookupnull;

CRM2011 给 EntityReference 赋值为空:

entity["new_storeroom_areaid"] = null;

2.单表查询,返回Entity

CRM4.0 :

private DynamicEntity GetNewPrInfo(Guid NewPrID)//根据GUID查询某字段

{

ColumnSet colSet = new ColumnSet(NewPrInfo.EntityName);

colSet.AddColumn(NewPrInfo.AttributeName_Assigner);

colSet.AddColumn(NewPrInfo.AttributeName_AssignNode);

TargetRetrieveDynamic target = new TargetRetrieveDynamic();

target.EntityId = NewPrID;

target.EntityName = NewPrInfo.EntityName;

RetrieveRequest request = new RetrieveRequest();

request.ColumnSet = colSet;

request.ReturnDynamicEntities = true;

request.Target = target;

RetrieveResponse response = (RetrieveResponse)this.crmService.Execute(request);

DynamicEntity PromotionPe = (DynamicEntity)response.BusinessEntity;

return PromotionPe;

}

CRM2011:

Entity accEntity = service.Retrieve(“new_test”, new_testid, new ColumnSet("字段1", "字段2"));//根据GUID,查询实体new_test的字段1和字段2的值。

Entity accEntity = service.Retrieve(entityName, entityId, new ColumnSet(true));//根据GUID,查询实体new_test的所有字段。

3.初始化CRM组织服务

CRM4:

CrmAuthenticationToken token = new CrmAuthenticationToken();

token.AuthenticationType = 0;

token.OrganizationName = "AdventureWorksCycle";

CrmService service = new CrmService();

service.Url = "";servername:port/mscrmservices/2007/crmservice.asmx";

service.CrmAuthenticationTokenValue = token;

service.Credentials = System.Net.CredentialCache.DefaultCredentials;

CRM2011:

IFD 的服务前面的段必须是https,不分内部和外部。

Uri orgServiceUri = new Uri("");

ClientCredentials credentials = new ClientCredentials();

credentials.UserName.UserName = CRMUserName;

credentials.UserName.Password = CRMUserPassword;

OrganizationServiceProxy crmServiceProxy = new OrganizationServiceProxy(orgServiceUri, null, credentials, null);

crmService = (IOrganizationService)crmServiceProxy;

2. on-premise 内部部署(AD认证),,初始化WebService时的方式如下:

服务前面的段可以是https,也是可以http

如果没有路由映射 外网是访问不了 只能内网访问

Uri organizationUri = new Uri("");

IServiceConfigurationIOrganizationService orgConfigInfo = ServiceConfigurationFactory.CreateConfigurationIOrganizationService(organizationUri);

var Orgcreds = new ClientCredentials();

Orgcreds.Windows.ClientCredential = new System.Net.NetworkCredential("administrator", "admiN123", "DynamicCRM.com");

OrganizationServiceProxy _serviceproxy = new OrganizationServiceProxy(orgConfigInfo, Orgcreds);

return (IOrganizationService)_serviceproxy;

这样子也可以:

Uri orgServiceUri = new Uri(Config.CrmWebServiceUrl);

var credentials = new ClientCredentials();

credentials.Windows.ClientCredential = new System.Net.NetworkCredential(Config.CrmServerAccount, Config.CrmServerPSW, Config.CrmServerDomain);

OrganizationServiceProxy _serviceproxy = new OrganizationServiceProxy(orgServiceUri, null, credentials, null);

return (IOrganizationService)_serviceproxy;

4.返回多个实体

CRM4:

// Create a column set holding the names of the columns to be retrieved.

ColumnSet cols = new ColumnSet();

cols.Attributes = new string [] {"name", "accountid"};

// Create the query object.

QueryByAttribute query = new QueryByAttribute();

query.ColumnSet = cols;

query.EntityName = EntityName.account.ToString();

// The query will retrieve all accounts whose address1_city is Sammamish.

query.Attributes = new string [] {"address1_city"};

query.Values = new string [] {"Sammamish"};

// Execute the retrieval.

BusinessEntityCollection retrieved = service.RetrieveMultiple(query);

CRM2011:

方法一:

string fetchxml = @"fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' aggregate='true'

entity name='new_po_exp_detail'

attribute name='new_exp_amount' alias='new_exp_amount_sum' aggregate='sum' /

attribute name='new_submit_amout' alias='new_submit_amout_sum' aggregate='sum' /

attribute name='new_expense_category' alias='new_expense_category' groupby='true' /

filter type='and'

condition attribute='statecode' operator='eq' value='0' /

/filter

link-entity name='new_po' from='new_poid' to='new_po_exp_detail' alias='ab'

filter type='and'

condition attribute='statecode' operator='eq' value='0' /

condition attribute='new_po_status' operator='in'

value5/value

value7/value

/condition

condition attribute='new_promotion_pe' operator='eq' value='" + new_promotion_peId + @"' /

/filter

/link-entity

/entity

/fetch";

EntityCollection entitycols = service.RetrieveMultiple(new FetchExpression(fetchxml));

方法二:

QueryByAttribute query = new QueryByAttribute("new_categorytate");

query.ColumnSet = new ColumnSet("new_categorytateid");

query.AddAttributeValue("statecode", 0);

query.AddAttributeValue("new_sn", new_sn);//产品品类编号

EntityCollection encols = service.RetrieveMultiple(query);

如何在Dynamic CRM 2013中创建WebService接口供其它系统调用

新建asp.net web项目

编写代码

验证服务

生成项目,并将相关文件拷贝到CRM的指定路径

一.新建项目

右键点击资源管理器项目,并添加一个web服务,此处名称为:MSCRMWebServiceDemo

引用相关的DLL文件

二.编写代码

[csharp] view plaincopy

using Microsoft.Xrm.Sdk;

using Microsoft.Xrm.Sdk.Client;

using Microsoft.Xrm.Sdk.Query;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.ServiceModel.Description;

using System.Web;

using System.Web.Services;

namespace MSCRMWebServiceDemo

{

/// summary

/// MyMSCRMWebService 的摘要说明

/// /summary

[WebService(Namespace = "")]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

[System.ComponentModel.ToolboxItem(false)]

// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。

// [System.Web.Script.Services.ScriptService]

public class MyMSCRMWebService : System.Web.Services.WebService

{

static private IOrganizationService GetOrganisationService()

{

ClientCredentials credentials = new ClientCredentials();

credentials.Windows.ClientCredential = new NetworkCredential("crmadmin", "password01!", "test");

OrganizationServiceProxy proxy = new OrganizationServiceProxy(new Uri(""), null, credentials, null);

return proxy as IOrganizationService;

}

[WebMethod]

public string HelloWorld()

{

IOrganizationService service = GetOrganisationService();

//用FETCHXML的方式获取会员数据

string fetch2 = @"

fetch mapping='logical'

entity name='account'

attribute name='name' /

attribute name='address1_city' /

attribute name='primarycontactid' /

attribute name='telephone1' /

attribute name='accountid' /

order attribute='name' descending='false' /

link-entity name='contact' from='contactid' to='primarycontactid' visible='false' link-type='outer' alias='accountprimarycontactidcontactcontactid'

attribute name='emailaddress1' /

/link-entity

/entity

/fetch";

EntityCollection result = service.RetrieveMultiple(new FetchExpression(fetch2));

String name = "";

foreach (var c in result.Entities)

{

name += c.Attributes["name"];

}

return name;

}

}

}

三.点击VS的运行按钮,测试服务

四.部署相关项目至CRM指定路径

拷贝MSCRMWebServiceDemo.dll至CRM的以下路径:

X:\Program Files\Microsoft Dynamics CRM\CRMWeb\bin

拷贝MyMSCRMWebService.asmx至CRM的以下路径:

C:\Program Files\Microsoft Dynamics CRM\CRMWeb\ISV

最后验证一下webservice,打开地址,出现以下界面则部署成功

东方世通管理系统怎么连接服务端

微软Dynamics CRM无缝集成Office 365、Power BI等生产力工具强大友好,xRM架构开放灵活,私有云、公有云和混合云自由选择。微软Dynamics CRM解决方案与您一同见证企业崛起!微软Dynamics CRM无缝集成Office 365、Power BI等生产力工具强大友好,xRM架构开放灵活,私有云、公有云和混合云自由选择。微软Dynamics CRM解决方案与您一同见证企业崛起!


本文题目:dynamicsxrm的简单介绍
文章来源:http://sczitong.cn/article/doiscpe.html