Tigryapa
Scholar

How to carry over attachments from one stage to the next in approval workflow

Hello, I am looking for step by step help or reference to a source to address the problem below, i seem to be missing something from the solutions i have read on the forums. 

I have three step workflow that i have created using nintex workflow for sharepoint and nintex forms. 

Initiate the request for review- approver gets the request and uses the forms to provide decision and attach the document for backup- the workflow sends it to next approver who has to provide another decision on the review using the attachment document from second step. 

I CANNOT for the life of me figure out how to show the attachment from the second step on the nintex form for the last step. There are tons of suggestions regarding xml, java scripts, etc, but nothing concrete aside from downloading some custom actions and creating url links. I would really really appreciate someone walking me through the process step by step if possible at all? 

thank you!!

0 Kudos
Reply
7 Replies
rjimenez89
Scholar

Re: How to carry over attachments from one stage to the next in approval workflow

Well...buckle up for this story.  We've been fighting with different solutions for a few years trying to find the right setup that is scalable, maintainable and user friendly for years.  I think we've finally landed on the solution, but time will tell.

 

  1. We tried the link method first, but found a major flaw.  If the task or location of the linked attachment disappears, the link is useless because it points to an item that doesn't exist.  Lesson here, never assume things wont get deleted or internal list names won't get renamed.  Everything you imagine that would never happen that could could break your stuff will eventually happen and will break your stuff so plan for everything to go wrong and try to mitigate as much as possible out of the gate.  You wont get everything, but you'll have a lot less to fix later.
  2. We tried the copy method @vadim_tabakman created which required us to have the custom action installed in our environment.  The custom action works great...with a few caveats related to list naming(more on that later).  The drawback here was that the list item attachments wouldn't show up in the task forms since the attachments field in the task form is tied to the attachments in the task, not the parent item.  So...now we have task attachments moved to the parent item, but no way to show them on future tasks(your exact problem).  Which brings us to our third iteration of our setup...
  3. So our problem needed a compound solution.
    1) Move task attachments to the parent item
    2) Create a way to have an updated list of attachments in all tasks. 
    We came up with a solution that combined the link method with the attachment copy method and threw it in a UDA that was usable across all of our sites.  The only requirements for the parent lists was that there was a rich text column to put the attachment html table.  That field would be shown using a label control in all of our tasks, so as the column was updated, the tasks showed the current collection of attachments. 

So now that the journey is out of the way, here's the breakdown of the uda we created and wrote about.  I attached a copy of the UDA as well so you can mess around with it.

 

A new UDA has been created Site Wide Add Attachments.  This UDA was modeled after the Add Attachments UDA that was created by a co-worker to add task attachments to a specific list.  The Add Attachments UDA has all of the foundational pieces we needed:

  • Ability to pass in an attachment collection or have the workflow look up a task attachment collection
  • Convert the attachment url into a base64 string and add the attachment to the original item
  • If the attachment exists, append a number to the end of the new attachment name then re-attach file to the item.
  • Update the attachments HTML field so the next task will show the updated list of item attachments

In addition to updating the field when an attachment changes, the ability to just update the attachments HTML field was also included in the original UDA.

So what changed?  Using the UpdateListItems method of the Lists.asmx web service, we are able to make the update action variable instead of hardcoded into the UDA.  This Web service takes in 2 parameters, ListName and Updates.

rjimenez89_8-1628030387025.png

 

listName will be our Target List Name Parameter. 

Updates is a string of updates created using the build string action.

 Details on the UpdateListItem method can be found online,  but for our purposes we'll be using this example to update items:
<Batch OnError="Continue" ListVersion="1">

   <Method ID="1" Cmd="Update">

      <Field Name="ID">TargetItemID<Field>

      <Field Name="Field_Name">Value</Field>

   </Method>

</Batch>

Each update will be in its own Method node.  The first child field node will be the ID of the item to update.  This is our Target Item ID parameter.  The second Field node will contain the updates.  Because each form can have a different field to update, the field name is passed in as the AttachmentField parameter.  The value is the Attachment table that was created earlier in the UDA.  Because we are using web services, we encoded the attachment table so we pass in valid xml into the web service.

Configuring the UDA

The Site Wide Add Attachments UDA takes a number of parameters as inputs.  

rjimenez89_9-1628030503570.png

 

 

  1. Add – Yes or No
    1. Set to Yes if the UDA needs to add an attachment to the target item
    2. Select No if the AttachmentField is only going to be refreshed
  2. Attachment URL Collection - Collection
    1. This is a collection variable.  If the UDA will grab the URLs, pass in an empty collection
  3. AttachmentField – Line of Text
    1. The internal name of the attachment html field in the parent list(not the task list)
  4. Item ID – Line of Text
    1. The ID of the item to retrieve the attachment from
  5. List Name – Line of Text
    1. The List name to retrieve the attachment from(Caveat here, your list internal name and list display name must be the same.  Which means that if your List Name is WorkflowTasks, the internal name must be WorkflowTasks.  If it is Workflow Tasks, then your internal name must be Workflow%20Tasks.  If they don't match you must either change the display name to match the internal name or the internal name to match the display name, otherwise you'll get an error when the uda gets to Vadim's custom action.  Because of how we built some web calls, we had to adjust the internal names of some of our lists using the file explorer in windows. )
  6. Target Item ID – Line of Text
    1. The Item to move the attachment to
  7. Target List Name – Line of Text
    1. The list name to move the attachment to

If you made it this far, thanks for reading and hopefully this gets you going in the right direction.

0 Kudos
Reply
Tigryapa
Scholar

Re: How to carry over attachments from one stage to the next in approval workflow

Thank you so much for detailed explanation! i have tried downloading the file that you have attached through Manage User defined actions screen and i am getting a message that this file that you had attached is not valid and needs to have uda extension. Importing this into workflow is not allowed either. Is it possible for you to re attach this in a different format? or am i doing something wrong here again? 

0 Kudos
Reply
rjimenez89
Scholar

Re: How to carry over attachments from one stage to the next in approval workflow

Oh right, you can't import this from the UDA inventory.  You should be able to click create in the uda inventory, then import the nwf file from there.  If you havent installed Vadim's custom action, that might be the source of the error.  You can download it from here, then you'll just need to install it in your environment: http://workflowexcellence.com/nintex-workflow-get-list-item-attachment-in-base64-custom-action-happy...

0 Kudos
Reply
Tigryapa
Scholar

Re: How to carry over attachments from one stage to the next in approval workflow

Is there a way to do this without Vadim's action? my company is blocking the download and there is no way to circumvent this.
Also, maybe stupid question, but where do i get username and password for web service action? i can't seem to figure this part out. I am the admin of the site if this makes a difference. Thank you!
0 Kudos
Reply
Tigryapa
Scholar

Re: How to carry over attachments from one stage to the next in approval workflow

i found an alternative below since i am not able to download the actions from the site.
https://nicoleprestby.com/2017/12/19/add-list-item-attachments-to-task-form-using-nintex-workflow-an...
it seems to work up to a certain point but then stops. I am attaching the workflow where it seems to stop, would you happen to have any ideas what i am doing wrong here? i followed step by step instructions and my workflow seems to be bypassing for each loop
0 Kudos
Reply
Tigryapa
Scholar

Re: How to carry over attachments from one stage to the next in approval workflow

Tigryapa_0-1628190927486.png

 

0 Kudos
Reply
rjimenez89
Scholar

Re: How to carry over attachments from one stage to the next in approval workflow

In the NWF file, there's a set of actions that mirror the table creation in the link you provided. Another alternative to Vadim's action is to create a new library and use the Copy to SharePoint action to move the attachments to the library. Once it's in the library, you can use the GetItem method of the copy.asmx web service to get the base64 value of the attachment that is required in the AddAttachment method in Lists.asmx.
0 Kudos
Reply