0

I would like to incorporate copying a document into another document library as part of a task process in a SharePoint workflow. After I copy that document, I need to be able to reference the document as it is an important part of the overall workflow.

For example, if the original document is deleted or the workflow is cancelled, I would like to delete that copy as well. How can I find the ID or any other identifying information for that created document?

enter image description here

1

Because you copy a document into another document library, the created document should have the same name as the original document.You could use name field to identify that created document.

enter image description here

| improve this answer | |
  • In the lookup for string dialog, I'm not given an option for using the "Name" of the Source Document. I instead have "Title". Is that okay? – Josh Sharkey Jun 30 at 20:18
  • If the source document and the destinate document have the same "Title" value, then yes you could use the "Title" field. – Michael Han_MSFT Jul 1 at 6:25
1

You can't, but you can do the reverse. Using the Copy item action does not give you any useful return value to be able to reference the copied item. But, what you can do is add a number field (maybe called OriginalItemID? And maybe make it hidden so that user's can't edit the value?) to the library where you are making the copies. Then, right after you have initially copied the document, set the copy's OriginalItemID field to be the ID of the current item.

Then when the workflow runs again, you can find the copy based on the OriginalItemID value matching the current item ID.


Sorry, my bad, my original answer is incomplete. (It had been a while since I did this, so I didn't remember all the steps.)

  • First, on the list/library where you have the originals, you need two number fields: OriginalItemID and CopyItemID, both should default to zero.
  • On the list/library where you have the copies, you need to add the OriginalItemID field, and be sure it's named exactly the same as the field in the originals list.
  • When the workflow starts, check the value of the CopyItemID field on the original item. If it's zero, you know it's a new item and you need to make a copy.
  • Before making the copy, set the OriginalItemID field on the original item to be it's own (i.e. "Current Item") ID.
  • Copy the item. The OriginalItemID on the copy should now refer back to the original item's ID.
  • Now look up the copied item based on the value of the OriginalItemID field.
  • Get the ID of the copied item and store it in the CopyItemID field on the original item.
  • The next time the workflow runs, again, first check the value of the CopyItemID field. If it is not zero, you know you have a copy, and you know it's ID.
| improve this answer | |
  • Could you go into more detail about how I would update fields on the copied item? – Josh Sharkey Jun 30 at 13:37
  • @JoshSharkey updated my answer. – Dylan Cristy Jun 30 at 14:03
  • That is an interesting method! I will give it a try. After the workflow finished, I probably would copy the draft and overwrite the general, reset all of these fields, and delete the draft so I have a clean slate. Do you see any issues with the above mentioned steps? – Josh Sharkey Jun 30 at 20:12
  • No, I don't see any issues with that. If you reset those fields to zero then you are setting yourself up to be able to make another copy when the workflow runs again on the same item. I'm not really familiar with your overall business process, but if that is something that would make sense in your case, then yes it is certainly possible. – Dylan Cristy Jun 30 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.