admin 管理员组文章数量: 887021
1、组织服务方法
添加N:N关系
service.Associate("实体1名称", 实体1ID,
new Relationship("实体1实体2中间表"),
new EntityReferenceCollection(new EntityReference("实体2", 实体2ID)));
删除N:N关系
service.Disassociate("实体1名称", 实体1ID,
new Relationship("实体1实体2中间表"),
new EntityReferenceCollection(new EntityReference("实体2", 实体2ID)));
例如
//团队添加用户
Service.Associate("team", teamId,
new Relationship("teammembership_association"),
new EntityReferenceCollection() { new EntityReference("systemuser", systemuser) });
//移除团队用户
Service.Disassociate("team", teamId,
new Relationship("teammembership_association"),
new EntityReferenceCollection() { new EntityReference("systemuser", systemuser) });
2、Request
添加N:N关系
// Create the request object and set the monikers with the
// teamprofiles_association relationship.
AssociateRequest teamToProfile = new AssociateRequest
{
Target = new EntityReference(FieldSecurityProfile.EntityLogicalName, _profileId),
RelatedEntities = new EntityReferenceCollection
{
new EntityReference(Team.EntityLogicalName, _teamId)
},
Relationship = new Relationship("teamprofiles_association")
};
// Execute the request.
svc.Execute(teamToProfile);
删除N:N关系
// Create the request object and set the monikers with the
// teamprofiles_association relationship.
DisassociateRequest teamToProfile = new DisassociateRequest
{
Target = new EntityReference(FieldSecurityProfile.EntityLogicalName, _profileId),
RelatedEntities = new EntityReferenceCollection
{
new EntityReference(Team.EntityLogicalName, _teamId)
},
Relationship = new Relationship("teamprofiles_association")
};
// Execute the request.
svc.Execute(teamToProfile);
3、JavaScript
添加N:N关系
POST [Organization URI]/api/data/v9.0/accounts(00000000-0000-0000-0000-000000000002)/opportunity_customer_accounts/$ref HTTP/1.1
Content-Type: application/json
Accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
{
"@odata.id":"[Organization URI]/api/data/v9.0/opportunities(00000000-0000-0000-0000-000000000001)"
}
删除N:N关系
DELETE [Organization URI]/api/data/v9.0/accounts(00000000-0000-0000-0000-000000000002)/opportunity_customer_accounts(00000000-0000-0000-0000-000000000001)/$ref HTTP/1.1
Accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
附:
下表列出了默认实体之间的“N:N”关系中所使用的相交实体。
IntersectEntity | MtoM_SchemaName | MtoM_Entity1 | MtoM_Entity2 |
---|---|---|---|
accountleads | accountleads_association | account | lead |
campaignactivityitem | campaignactivitylist_association | campaignactivity | list |
campaignactivityitem | campaignactivitysalesliterature_association | campaignactivity | salesliterature |
campaignitem | campaigncampaign_association | campaign | campaign |
campaignitem | campaignlist_association | campaign | list |
campaignitem | campaignproduct_association | campaign | product |
campaignitem | campaignsalesliterature_association | campaign | salesliterature |
competitorproduct | competitorproduct_association | competitor | product |
competitorsalesliterature | competitorsalesliterature_association | salesliterature | competitor |
connectionroleassociation | connectionroleassociation_association | connectionrole | connectionrole |
contactinvoices | contactinvoices_association | invoice | contact |
contactleads | contactleads_association | contact | lead |
contactorders | contactorders_association | salesorder | contact |
contactquotes | contactquotes_association | quote | contact |
entitlementcontacts | entitlementcontacts_association | contact | entitlement |
entitlementproducts | product_entitlement_association | product | entitlement |
entitlementtemplateproducts | product_entitlementtemplate_association | product | entitlementtemplate |
leadcompetitors | leadcompetitors_association | lead | competitor |
leadproduct | leadproduct_association | lead | product |
listmember | listaccount_association | list | account |
listmember | listcontact_association | list | contact |
listmember | listlead_association | list | lead |
opportunitycompetitors | opportunitycompetitors_association | opportunity | competitor |
productassociation | productassociation_association | product | product |
productsalesliterature | productsalesliterature_association | product | salesliterature |
productsubstitute | productsubstitute_association | product | product |
queuemembership | queuemembership_association | queue | systemuser |
roleprivileges | roleprivileges_association | privilege | role |
roletemplateprivileges | roletemplateprivileges_association | roletemplate | privilege |
servicecontractcontacts | servicecontractcontacts_association | contact | contract |
subscriptionmanuallytrackedobject | contact_subscription_association | subscription | contact |
subscriptionmanuallytrackedobject | task_subscription_association | subscription | task |
systemuserprofiles | systemuserprofiles_association | systemuser | fieldsecurityprofile |
systemuserroles | systemuserroles_association | systemuser | role |
teammembership | teammembership_association | team | systemuser |
teamprofiles | teamprofiles_association | team | fieldsecurityprofile |
teamroles | teamroles_association | team | role |
版权声明:本文标题:Dynamics CRM 代码处理N:N关系 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1725942937h896517.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论