1

In my content item, I have a field called "MyField." Additionally, the workflow comment has its own field called "MyField." I am wondering if it is feasible to automatically populate the field values in the workflow comment template based on the field value of the content item.

MyWorkflow
Draft
 -Move to Pre Publish(has comment template)
Pre Publish
 -Move to Publish(has comment template)
Publish

Now, when a user clicks on "Move to Pre Publish," I want to prefill the value of "MyField" with the corresponding value from the content item's field.

Is it possible to achieve this? Is there any pipeline I need to patch for this to work?

Thanks

1 Answer 1

1

You could try creating a custom action

I am not 100% sure if it would run before or after the comments dialog pops up... Validation actions run before, so guessing it would be fine.

I havent tested the code, but in theory it might do the job (or at least give you something to start with).

public class UpdateCommentAction
{
    public void Process(WorkflowPipelineArgs args)
    {
        Assert.ArgumentNotNull(args, "args");
        ProcessorItem processorItem = args.ProcessorItem;
        if (processorItem == null)
        {
            return;
        }
        // Stage Item
        Item innerItem = processorItem.InnerItem;
        
        // GET THE VALUE OF YOUR FIELD HERE
        
        // Workflow Item (Content Item)
        Item workflowItem = args.DataItem;
        
        // UPDATE THE VALUE OF WORKFLOW ITEM
    }
}

Code above is based of some examples I found here:

https://jodosc.blog/2021/09/04/how-to-send-email-between-an-editor-and-an-approver-in-sitecore-workflow/

1
  • Thank you for the reply Dean. Action trigger after the comment dialog popup. It looks like this can be done by customizing item:workflow command which sitecore uses for comment dialog –
    – Shiva
    Commented Jun 23, 2023 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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