Page MenuHomePhorge

modify task title from within a Herald action
Closed, ResolvedPublic

Asked by Higgs on Mar 10 2023, 12:32.

Details

I have added a Herald rule that fires whenever a task is modified.
Depending on what exactly is modified in the task i want to add some marker into the task title, like for example:

old title:

My arbitrary task title

shall be renamed to:

[xxx] My arbitrary task title

where what xxx is will be determined by a custom herald action.

This is an abbreviated version of my applyEffect method:

public function applyEffect($object, HeraldEffect $effect) {

    // works perfect:
    $adapter = $this->getAdapter();
    $task = $adapter->getTask();
    $title = $task->getTitle();

    // does not change the task title:
    if (some condition) {
            $title = '[xxx]'.$title; // of course the replacement is more complex, but that is not the point here
            $task->setTitle ( $title ); // expect the title changes
    }
}

I have verified that the herald action is called and "some condition" is true. I also verified the $task->settitle() is called. However, nothing changed and no error is thrown.

Question: What else do i need to add so that the task title eventually gets modified ?

Answers

Higgs
Updated 411 Days Ago

i think i found the answer after digging deeper into the Phorge code:

public function applyEffect($object, HeraldEffect $effect) {
    $adapter = $this->getAdapter();
    $task = $adapter->getTask();
    $title = $task->getTitle();

    if ($some_condition==true) {
            $title = '[xxx]'.$title;
            $task->setTitle ( $title ); // probably not needed

            $transaction = new ManiphestTransaction();
            $type= ManiphestTaskTitleTransaction::TRANSACTIONTYPE;
            $transaction->setTransactionType($type);
            $transaction->setNewValue($title);
            $adapter->queueTransaction($transaction);
    }
}

Further tips are welcome,
thanks

This answer has been hidden.

New Answer

Answer

This question has been marked as closed, but you can still leave a new answer.