If I upload 2 or 3 files for customer the email event only attaches the first file

  • 2 September 2015
  • 1 reply
  • 1 view

Badge +1

I created a simple email attachment workflow in K2 studio. I used two activities in first activity I filter the document by customer name, and I used “Get Document Reference” event and in second activity, I am just sending the email and used “Send Email” event, and in email attachment box of email I simply drag the document field of my SharePoint document library.

 

Problem statement ““

 

Please help me in this regard. Workflow image is attached.

 

 


13697iB3ED1831D6D9693F.png

1 reply

Userlevel 1
Badge +8

Hi Sufian

 

What you are seeing is expected behaviour. The Get Document Reference event you are using to get the Customer documents will only return the first result even if more than one document matches the criteria.

 

Given that you can't specify exactly how many documents you want to send you need to rethink your workflow design.

 

One way would be to send a separate email for each document. This might be the safest as you reduce the chances of exceeding the file attachment size limit for a single email. To do this you can use a single activity with a  Get Document Reference and Email event.

 

Configure your Activity to use "Plan per slot (no destinations)". You need to tick the advanced box to see this option. Then in the next step select the option to "Select a list field to determine how many slots should be created"  and select the "Get Documents Metadata" list method for the Library SmartObject. You can then use the Input Mappings and/or Filter to return the documents for the Customer and in the Return Property select the ID field. This will be stored in the "Instance Data" field for the Activity Instance Destination. This activity will then loop through and perform the events for each document returned in the destination rule.

 

In the Get Document Reference event specify in the ID field the "Instance Data"  (Workflow Context Browser -> Activity Destination Instance). You may need to convert it to an integer. 

 

In your email event drop the Document property from the item reference into the attachment field.

 

Finally, add a Succeeding Rule to your activity to ensure that all activity instances finish before the workflow moves on to the next activity of finishes. Set the rule to ActivityInstanceDestStatus (Workflow  Context Browser -> Activity Instance Detination - >Status)  for All Slots = Completed.

 

Please note I have not tried this myself so I cant vouch that it will work as expected. I'm not 100% sure changing the document reference for each activity instance will work properly. If it doesn't then you could try removing the Get Document Reference event, and in the Email event use the Get File From Content function and pass into the Content and File Name results from the Get Document method for the Document Library SmartObject  (passing in the Instance Data Field to the ID parameter).

Reply