Workflow email link does not link to the correct draft but only to the live version of the entry
Describe the bug
Workflow email link does not link to the correct draft but only to the live version of the entry.
Steps to reproduce
- Editor edits a page and submits thier draft for approval as usual
- Publisher receives an email with the link to approve the entry submitted
- The email link is linking to the live version of that entry and not the correct draft , therefore , no button to approve anything and the publisher has to manually go to workflow and approve the entry. The link in the email does not have any draftId in it.
Craft CMS version
4.7.0
Plugin version
2.0.8
Multi-site?
No
Additional context
This happens both in local and production.
Quick clarification here - is the editor creating a brand new entry, or a draft on an already existing entry? The two processes can work slightly differently, so it's worth noting the difference one way or the other.
The submission.ownerCpUrl that's used in emails should resolve to the last review's owner cpEditUrl. In this case, the owner should be the draft entry you've submitted.
Hello and thanks for coming back to this.If the editor is creating a brand new entry, the email link is correct. But if the editor is creating a draft on an existing entry,this process does not create the correct email link. This is the issue we hope to get a fix for as it is a problem for our clients. Thanks.
Hi there. Is there any response or thoughts available on this matter. This is important for us. Appreciate it. Cheers
Hi there,this issue is important for our clients and I would appreciate if it is being looked into and responded. Thanks
Haven't forgotten about this, just struggling to reproduce this one on our end. Are you able to send through the email template for the submission notification? These can be found in Utilities > System Messages.
Actually, just after sending this I was able to replicate this one. Should be fixed for the next release. To get this early, run composer require verbb/workflow:"dev-craft-4 as 2.0.8".
Thank you so very much. Tested it and the issue is now resolved. Cheers.
Updated in 2.0.9
Hi, we are seeing this issue happen again for us, after updating to Craft 5.6.5.1 and Workflow 3.0.6.
In the email notification from the editor to the publisher, the {{ submission.ownerCpUrl }} variable is set to the current live version of the entry rather than the actual draft, the "?draftId=xxxxxx" is omitted.
I'm not able to replicate this sorry. Can you locate the review in the workflow_reviews database table, and ensure that the draftId value is actually set?
In this particular case, the draftId was not set in the table. But after further testing it seems to be fine for yet-to-be published entries. It seems to occur when the editor submits an additional draft to an already published listing that they want to update. The draftId for the new draft was set in the table but not displayed in the email notification, very strange.
That was my next question, whether this was a brand-new entry, or a new draft on an entry. Technically in either case they should both be drafts, but just wanted to confirm regardless.
So just to confirm, you're making a submission on an already published entry (so a new draft is being made), and the draftId value is there - it's just in the email notification it's not linking to that draft?
Yes, that's it exactly
I think I've narrowed things down. Should be fixed for the next release. To get this early, run composer require verbb/workflow:"dev-craft-5 as 3.0.6".
That seems to have done the trick, thanks!
Updated in 3.0.8.