Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: amosbatto

#813546
Hello, whenever i try to use the REST API to generate an output document, i get the following error.

{"error":{"code":400,"message":"Bad Request: The user with \"00000000000000000000000000000001\" not have permissions to perform this action."}}

This REST function only seems to work for the user user account in which the the output document was originally generated. Is this the default behavior or is there some way to allow the Administrator or Supervisor to generate an output document through the REST API. Thanks.

Im using Processmaker 3.2 Community.
#813547
If you want to allow Process Supervisors to generate Output Documents, edit the file workflow/engine/src/ProcessMaker/Services/Api/Cases/OutputDocument.php and change the doPostOutputDocument() function so it has the following code:
Code: Select all
    /**
     * @url POST /:app_uid/:del_index/output-document/:out_doc_uid
     *
     * @param string $app_uid     {@min 32}{@max 32}
     * @param int    $del_index   {@min 1}
     * @param string $out_doc_uid {@min 32}{@max 32}
     */
    public function doPostOutputDocument($app_uid, $del_index, $out_doc_uid)
    {
        try {
            $userUid = $this->getUserId();

            $case = new \ProcessMaker\BusinessModel\Cases();
            $outputDocument = new \ProcessMaker\BusinessModel\Cases\OutputDocument();
            
            //allow user to create output document if a process supervisor or is assigned to case:
            $aCaseInfo = $case->getApplicationRecordByPk($app_uid, [], false);
            $supervisor = new \ProcessMaker\BusinessModel\ProcessSupervisor();
            
            if ($supervisor->isUserProcessSupervisor($aCaseInfo['PRO_UID'], $userUid) === false) {
                $outputDocument->throwExceptionIfCaseNotIsInInbox($app_uid, $del_index, $userUid);
            }
            
            $outputDocument->throwExceptionIfOuputDocumentNotExistsInSteps($app_uid, $del_index, $out_doc_uid);
            $response = $outputDocument->addCasesOutputDocument($app_uid, $out_doc_uid, $userUid);

            //Return
            return $response;
        } catch (\Exception $e) {
            throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
        }
    } 

hi all, i am using on a process which is a suppor[…]

Great! It was very helpful! Now I´m looking […]

This solution only works if I have 2 tasks in whic[…]

timing control

I can't reproduce the problem in version 3.2.0 C[…]