Menu

Cancel waiting for approval UserRequest

2023-12-28
2023-12-29
  • Edreach james Luzon

    hello want to seek some help on you guys i created an extension to cancel the request and update the approvalScheme below is my method. basically if user want to cancel their request i want to update also the approvalscheme table to avoid apearing in list of approval but the status is closed

            public function cancelot()
    

    {

    $otCancelValue = $this->Get('ot_cancel');

    $sOQL = "SELECT ApprovalScheme WHERE obj_key = :id";
    $oApprovalRequestCancel = new DBObjectSet(
    DBObjectSearch::FromOQL($sOQL),
    array('id' => $this->Get('id'))
    );

    while ($oRequest = $oApprovalRequestCancel->Fetch()) {
    if ($otCancelValue === 'yes') {

        $this->Set('parent_request_id', null);
        $this->Set('status', "closed");
        $this->Set('close_date', time());
        $this->Set('public_log', "Cancelled");
    
        $oRequest->Set('current_step', "1");
        $oRequest->Set('status', "rejected");
        $oRequest->Set('abort_comment', "Cancelled by user");
        $oRequest->DBUpdate();
    }
    

    }
    }

    got an ERROR:

           2023-12-28 15:44:29 | Error   | 71    | Wrong direction in ORDER BY spec, found '59' and expecting a boolean value | CoreException |||
    

    array (
    'exception class' => 'CoreException',
    'file' => 'C:\xampp\htdocs\test\core\dbsearch.class.php',
    'line' => 1017,
    'origin' => 'Combodo\iTop\Portal\Form\ObjectFormManager::Combodo\iTop\Portal\Form\ObjectFormManager::OnSubmit',
    'obj_class' => 'UserRequest',
    'obj_key' => '59',

    hoping you guys can help me

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2023-12-28

    Just a guess: I think your DBObjectSearch is missing a parameter. Any chance the id is 59? Second parameter is likely the order (default: asc). You might need to specify an empty array as second argument; then the one with the ID placeholder becomes the third argument.

     
  • Edreach james Luzon

    oh so thats what i'm missing thank you very much here is the part that i updated

    $oApprovalRequestCancel = new DBObjectSet(
    DBObjectSearch::FromOQL($sOQL),
    array(),
    array('id' => $this->Get('id'))
    );

     
    👍
    1

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.