Download Full Documentation here : EasyPlugins.chm


Some sample use cases :

Creation of primary contact associated to an account creation.

  • Create a new trigger and set entity to account on post create event.
  • Create a new "attribute parameter" and choose "name" attribute (after action)
  • Create a new "request parameter" and set fetchXml to :
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="contact">
    <attribute name="contactid" />
    <attribute name="fullname" />
    <filter type="and">
      <condition attribute="parentcustomerid" operator="eq" uitype="account" value="{#p0}" />
    </filter>
  </entity>
</fetch>
  • Default param is always set #p0 (accountid)
  • Add a "create action" on contact and set
- lastname: #p1
- firstname: " Contact associated "
- parentcustomerid: #p0
#p0 : accountid created
#p1 : account name


  • You can test an expression by clicking on bug button

  • Add an "update action" on account and set like below

  • Result Config :

  • Do not forget to activate trigger

  • Finally, you can import this configuration:
<?xml version="1.0" encoding="utf-16"?>
<ArrayOfXportObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <XportObject Name="UseCase 1 : Create Default Contact" Active="true" Entity="account" PreCreate="false" PostCreate="true" PreUpdate="false" PostUpdate="false" PreDelete="false" PostDelete="false" Synchronous="true">
    <Rules>&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfCrmRule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;CrmRule ParamNumber="1" Type="Attribute" AttributeState="After" ReturnCount="1" ResultType="String" LogicalName="name" FetchXml="" LineFunction="None" LineSeparator="" ColumnSeparator="" /&gt;
  &lt;CrmRule ParamNumber="2" Type="Request" AttributeState="After" AttributesReturnTypes="Guid String" ReturnCount="2" ResultType="Array" LogicalName="" FetchXml="&amp;lt;fetch version=&amp;quot;1.0&amp;quot; output-format=&amp;quot;xml-platform&amp;quot; mapping=&amp;quot;logical&amp;quot; distinct=&amp;quot;false&amp;quot;&amp;gt;&amp;#xD;  &amp;lt;entity name=&amp;quot;contact&amp;quot;&amp;gt;&amp;#xD;    &amp;lt;attribute name=&amp;quot;contactid&amp;quot; /&amp;gt;&amp;#xD;    &amp;lt;attribute name=&amp;quot;fullname&amp;quot; /&amp;gt;&amp;#xD;    &amp;lt;filter type=&amp;quot;and&amp;quot;&amp;gt;&amp;#xD;      &amp;lt;condition attribute=&amp;quot;parentcustomerid&amp;quot; operator=&amp;quot;eq&amp;quot; uitype=&amp;quot;account&amp;quot; value=&amp;quot;{#p0}&amp;quot; /&amp;gt;&amp;#xD;    &amp;lt;/filter&amp;gt;&amp;#xD;  &amp;lt;/entity&amp;gt;&amp;#xD;&amp;lt;/fetch&amp;gt;" LineFunction="First" LineSeparator="" ColumnSeparator="" /&gt;
&lt;/ArrayOfCrmRule&gt;</Rules>
    <Actions>&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfCrmAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;CrmAction Type="Create" MaxDepth="1" ForEachParamNumber="-1" EntityLogicalName="contact"&gt;
    &lt;Expressions&gt;
      &lt;FieldExpression AttributeLogicalName="firstname" Type="String" Expression="&amp;quot; Contact associated &amp;quot;" AttributeTypeCode="String" Targets="" /&gt;
      &lt;FieldExpression AttributeLogicalName="lastname" Type="String" Expression="#p1" AttributeTypeCode="String" Targets="" /&gt;
      &lt;FieldExpression AttributeLogicalName="parentcustomerid" Type="Lookup" Expression="#p0" AttributeTypeCode="Customer" Targets="account;contact" /&gt;
    &lt;/Expressions&gt;
    &lt;ExpressionId AttributeLogicalName="" Type="None" Expression="" AttributeTypeCode="Boolean" Targets="" /&gt;
    &lt;ConditionExpression AttributeLogicalName="" Type="Boolean" Expression="true" AttributeTypeCode="Boolean" Targets="" /&gt;
  &lt;/CrmAction&gt;
  &lt;CrmAction Type="Update" MaxDepth="1" ForEachParamNumber="-1" EntityLogicalName="account"&gt;
    &lt;Expressions&gt;
      &lt;FieldExpression AttributeLogicalName="primarycontactid" Type="Lookup" Expression="#p2[0]" AttributeTypeCode="Lookup" Targets="contact" /&gt;
    &lt;/Expressions&gt;
    &lt;ExpressionId AttributeLogicalName="accountid" Type="Guid" Expression="#p0" AttributeTypeCode="Uniqueidentifier" Targets="" /&gt;
    &lt;ConditionExpression AttributeLogicalName="" Type="Boolean" Expression="true" AttributeTypeCode="Boolean" Targets="" /&gt;
  &lt;/CrmAction&gt;
&lt;/ArrayOfCrmAction&gt;</Actions>
  </XportObject>
</ArrayOfXportObject>

associated contacts deletion on parent account deletion.

  • Create a new trigger and set entity to account on pre delete event.
  • Create a new "fetchXml parameter" and set it as :
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="contact">
    <attribute name="fullname" />
    <attribute name="telephone1" />
    <attribute name="contactid" />
    <order attribute="fullname" descending="false" />
    <filter type="and">
      <condition attribute="parentcustomerid" operator="eq" uitype="account" value="{#p0}" />
    </filter>
  </entity>
</fetch>

  • Add a "delete action" and set it like below :

  • Do not forget to activate trigger
  • Finally, you can import this configuration:
<?xml version="1.0" encoding="utf-16"?>
<ArrayOfXportObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <XportObject Name="UseCase 2 : Delete associated Contacts" Active="true" Entity="account" PreCreate="false" PostCreate="false" PreUpdate="false" PostUpdate="false" PreDelete="false" PostDelete="true" Synchronous="true">
    <Rules>&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfCrmRule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;CrmRule ParamNumber="1" Type="Request" AttributeState="After" AttributesReturnTypes="String String Guid" ReturnCount="3" ResultType="Array" LogicalName="" FetchXml="&amp;lt;fetch version=&amp;quot;1.0&amp;quot; output-format=&amp;quot;xml-platform&amp;quot; mapping=&amp;quot;logical&amp;quot; distinct=&amp;quot;false&amp;quot;&amp;gt;&amp;#xD;  &amp;lt;entity name=&amp;quot;contact&amp;quot;&amp;gt;&amp;#xD;    &amp;lt;attribute name=&amp;quot;fullname&amp;quot; /&amp;gt;&amp;#xD;    &amp;lt;attribute name=&amp;quot;telephone1&amp;quot; /&amp;gt;&amp;#xD;    &amp;lt;attribute name=&amp;quot;contactid&amp;quot; /&amp;gt;&amp;#xD;    &amp;lt;order attribute=&amp;quot;fullname&amp;quot; descending=&amp;quot;false&amp;quot; /&amp;gt;&amp;#xD;    &amp;lt;filter type=&amp;quot;and&amp;quot;&amp;gt;&amp;#xD;      &amp;lt;condition attribute=&amp;quot;parentcustomerid&amp;quot; operator=&amp;quot;eq&amp;quot; uitype=&amp;quot;account&amp;quot; value=&amp;quot;{#p0}&amp;quot; /&amp;gt;&amp;#xD;    &amp;lt;/filter&amp;gt;&amp;#xD;  &amp;lt;/entity&amp;gt;&amp;#xD;&amp;lt;/fetch&amp;gt;" LineFunction="ForEach" LineSeparator="" ColumnSeparator="" /&gt;
&lt;/ArrayOfCrmRule&gt;</Rules>
    <Actions>&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfCrmAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;CrmAction Type="Delete" MaxDepth="1" ForEachParamNumber="1" EntityLogicalName="contact"&gt;
    &lt;Expressions /&gt;
    &lt;ExpressionId AttributeLogicalName="contactid" Type="Guid" Expression="#p1[2]" AttributeTypeCode="Uniqueidentifier" Targets="" /&gt;
    &lt;ConditionExpression AttributeLogicalName="" Type="Boolean" Expression="true" AttributeTypeCode="Boolean" Targets="" /&gt;
  &lt;/CrmAction&gt;
&lt;/ArrayOfCrmAction&gt;</Actions>
  </XportObject>
</ArrayOfXportObject>

prevent the modification of a particular account

  • Create a new trigger and set entity to account on post update and post delete events.
  • Create a new "Attribute parameter" on name (before action)

  • Add an "abort action" and set it like below :

  • Do not forget to activate trigger
  • Result on trying to update or delete "important account" record

  • Finally, you can import this configuration:
<?xml version="1.0" encoding="utf-16"?>
<ArrayOfXportObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <XportObject Name="UseCase 3 : Prevent modification of an account" Active="true" Entity="account" PreCreate="false" PostCreate="false" PreUpdate="false" PostUpdate="true" PreDelete="false" PostDelete="true" Synchronous="true">
    <Rules>&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfCrmRule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;CrmRule ParamNumber="1" Type="Attribute" AttributeState="Before" ReturnCount="1" ResultType="String" LogicalName="name" FetchXml="" LineFunction="None" LineSeparator="" ColumnSeparator="" /&gt;
&lt;/ArrayOfCrmRule&gt;</Rules>
    <Actions>&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfCrmAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;CrmAction Type="Abort" MaxDepth="1" ForEachParamNumber="-1" EntityLogicalName=""&gt;
    &lt;Expressions /&gt;
    &lt;ExpressionId AttributeLogicalName="" Type="String" Expression="&amp;quot;You can not edit or delete this account&amp;quot;" AttributeTypeCode="String" Targets="" /&gt;
    &lt;ConditionExpression AttributeLogicalName="" Type="Boolean" Expression="#p1 != null &amp;amp;&amp;amp; #p1.ToLower() == &amp;quot;important account&amp;quot;" AttributeTypeCode="Boolean" Targets="" /&gt;
  &lt;/CrmAction&gt;
&lt;/ArrayOfCrmAction&gt;</Actions>
  </XportObject>
</ArrayOfXportObject>

Last edited May 13, 2015 at 11:06 AM by aminekouddane, version 4

Comments

BobHatcher Apr 26, 2015 at 7:44 PM 
I wrote a blog post that gives another detailed example, including some things not covered here like Option Sets: http://ow.ly/M8HkG