//改文章参考   
Entity entity = (Entity)context.InputParameters["Target"]; //使用该方式,只有改变了属性值才可以获取
//获得前期事件和后期实体映像
    Entity preEntity = (Entity)context.PreEntityImages["Accountname"]; //操作之前
    Entity postEntity = (Entity)context.PostEntityImages["Accountstage"];//操作之后
使用该方式的话就不用在插件里面,再取一次实体的其它属性了,会将属性值传入插件
注意的是,在创建,删除中不可使用。
可参考该篇文章 https://www.bbsmax.com/A/1O5Eook3z7/ 
//例子:当前客户共享团队 客户就是指定共享的实体 而团队就是要求共享的实体
共享调用:
 EntityReference Record = new EntityReference { Id = entity.Id, LogicalName = entity.LogicalName };
 Grant(adminService, (EntityReference)entity["tm_centralize"], Record);
共享方法 
//service:服务
//teamOrSystem,:要求共享的实体
//Record:指定共享的实体
 private static void Grant_Read(IOrganizationService service, EntityReference teamOrSystem, EntityReference Record)
  {
   GrantAccessRequest grantAccessRequest = new GrantAccessRequest
   {
    PrincipalAccess = new PrincipalAccess
    {
     Principal = teamOrSystem,
     AccessMask = AccessRights.ReadAccess | AccessRights.WriteAccess  //赋予的权限
    },
    Target = Record,
   };
service.Execute(grantAccessRequest);
}
//取消共享
 Entity Pusers = service.Retrieve("Account", users.GetAttributeValue<EntityReference>("Accountid").Id, new ColumnSet("tm_centralize"));
 RevokeUser(service, entPre.GetAttributeValue<EntityReference>("tm_centralize"), new EntityReference(entPre.LogicalName, entPre.Id));
private void RevokeUser(IOrganizationService service, EntityReference teamOrSystem, EntityReference Record)
  {
   RevokeAccessRequest revokeAccessRequest = new RevokeAccessRequest
   {
    Revokee = teamOrSystem,
    Target = Record,
   };
service.Execute(revokeAccessRequest);
}
//查询单条
EntityReference entity = (EntityReference)context.InputParameters["Target"];
Entity aaccountTargetEntity = adminService.Retrieve("tm_purchaseamount", entity.Id, new ColumnSet(new string[] { "tm_year", "tm_account" }));
plugin中查询
      string mFetch      <fetch version='1.0' output-format='       <entity name='tm_purchaseamount'>
       <attribute name='tm_purchaseamountid' />
       <attribute name='tm_name' />
       <attribute name='createdon' />
       <order attribute='tm_name' descending='false' />
       <filter type='and'>
        <condition attribute='tm_year' operator='eq' value='{0}' />
        <condition attribute='tm_account' operator='eq' uiname='=C=' uitype='account' value='{1}' />
        <condition attribute='statecode' operator='eq' value='0' />
       </filter>
       </entity>
      </fetch>
      ", ((OptionSetValue)entity["tm_year"]).Value.ToString(), ((EntityReference)entity["tm_account"]).Id.ToString());
      EntityCollection accountEntites = adminService.RetrieveMultiple(new FetchExpression(mFetch      if (accountEntites.Entities.Count > 0)
      {
       throw new InvalidPluginExecutionException( ((OptionSetValue)entity["tm_year"]).Value.ToString() + " Year already exists!");
      }
原文转载:http://www.shaoqun.com/a/478714.html
跨境通电子商务平台:https://www.ikjzd.com/w/1329.html
雨果网:https://www.ikjzd.com/w/1307
邮乐网购:https://www.ikjzd.com/w/1776
//改文章参考Entityentity=(Entity)context.InputParameters["Target"];//使用该方式,只有改变了属性值才可以获取//获得前期事件和后期实体映像EntitypreEntity=(Entity)context.PreEntityImages["Accountname"];//操作之前EntitypostEnt
yeepay:https://www.ikjzd.com/w/2574
友家快递:https://www.ikjzd.com/w/1341
跨境电商自建站是什么?自身优势有哪些?:https://www.ikjzd.com/home/113309
分享一个最近看到的用python写的亚马逊美国站前十页标题关键词词频分析工具:https://www.ikjzd.com/home/18159
亚马逊旺季备货的注意事项!:https://www.ikjzd.com/home/104428
没有评论:
发表评论