Upload Email Attachments To share point and Delete from Dynamics CRM Through Power Automate Flow - Power Automate

 Upload Email Attachments To share point and Delete from dynamics CRM Through Power Automate













Set Flow Triger Point and store share point site Url in variable


List Cases having attachments in Emails

<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
  <entity name='incident'>
    <attribute name='title' />
    <attribute name='ticketnumber' />
    <attribute name='createdon' />
    <attribute name='incidentid' />
    <attribute name='caseorigincode' />
    <order attribute='title' descending='false' />
    <link-entity name='activitypointer' from='regardingobjectid' to='incidentid' link-type='inner' alias='aa'>
      <link-entity name='activitymimeattachment' from='objectid' to='activityid' link-type='inner' alias='ab' />
    </link-entity>
  </entity>
</fetch>


























List Activities Related to case



<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
  <entity name='activitypointer'>
    <attribute name='activitytypecode' />
    <attribute name='subject' />
    <attribute name='statecode' />
    <attribute name='prioritycode' />
    <attribute name='modifiedon' />
    <attribute name='activityid' />
    <attribute name='instancetypecode' />
    <attribute name='community' />
    <order attribute='modifiedon' descending='false' />
    <link-entity name='incident' from='incidentid' to='regardingobjectid' link-type='inner' alias='ad'>
      <filter type='and'>
        <condition attribute='incidentid' operator='eq' value='Here pass Guid of the record'/>
      </filter>
    </link-entity>
  </entity>
</fetch>


























List Attachment Related to Activities


<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
  <entity name='activitymimeattachment'>    
    <order attribute='modifiedon' descending='false' />    
      <link-entity name='activitypointer' from='activityid' to='objectid' link-type='inner' alias='af'>
        <filter type='and'>
          <condition attribute='activityid' operator='eq' value='Here pass Guid od the record'/>
        </filter>
      </link-entity>
    </link-entity>
  </entity>
</fetch>


















Site Address: pass share point url
Folder Path : give folder path (i have created separate blog for this)
File Name : provide file name from dynamically from attachment
File Content : provide Body Content from attachment and covert it int base 64 to binary (base64ToBinary(items('Apply_to_each_4')?['body']))

Upload attachment to share point in respective folder




























Delete attachments form dynamics







Note : I have used fetch Xml But you can use other tool for retrieve and create Power Automate Query. 























































Over All Flow Structure






Comments

Popular posts from this blog

Top Interview Questions and Answers for Dynamics 365 Development and Customization

Create folder on share point Microsoft dynamics CRM with document Location By Power Automate