Forum Discussion

HardCoder's avatar
HardCoder
Ideator I
7 years ago

How to get comment from LifeCycle promotion in Pre server method?

Hi all,

I want to obtain user comment from Lifecycle promotion when user promotes item to next state. Idea is that Pre method on LifeCycle captures comment and if comment is empty, method prevents promotion. I would appriciate it if someone knows the answer.

Thank you.

Rok

3 Replies

  • To obtain user comment from Lifecycle promotion in Pre server method, you can use the following code:

    public override void Pre(LifeCyclePromotionPreEventContext context)
    {
    string comment = context.Command.CommandComment;

    if (string.IsNullOrEmpty(comment))
    {
    context.Cancel = true;
    context.Result.Message = "Please provide a comment before promoting.";
    }
    }

    Here, the CommandComment property of the context.Command object contains the comment entered by the user during the promotion. If the comment is empty or null, the method cancels the promotion and sets a message in the context.Result.Message property.

    Try this once. 

  • Hi community,

    this is an old topic. But I have this question too. Does anyone know more?

    Best regards

    Angela