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

Moderators: ArturoRobles, ArturoRobles

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#793722
I want to create a trigger in PHP that will create a client folder when the project is created.

I have this error: error: **Changes to APP_FOLDER are forbidden. Please contact system administrator for more information.** after doing this query:
$sql = "INSERT INTO APP_FOLDER(FOLDER_PARENT_UID,FOLDER_NAME,FOLDER_CREATE_DATE,FOLDER_UPDATE_DATE) VALUES('$FOLDER_PARENT_UID','$FOLDER_NAME','$FOLDER_CREATE_DATE','$FOLDER_UPDATE_DATE')";

Is there a better way to do this? My problem is that there are some cases where there isn't any document to upload once the project is created but I need to transfer documents uploaded BEFORE the project was created in a path from /no_project_number/clients/documents to /clients/project_number/documents

The only way I saw it was to create an empty folder and then using a php plugin to sync the documents (this plugin works but doesn't when there is no folder to sync to)
#793728
AppFolder::createFolder() creates or updates a folder found under Home > Documents.
array AppFolder::createFolder($folderName, $folderParent = "/", $action = "createifnotexists")
Parameters:
* $folderName: name of the new folder.
* $folderParent: The unique ID of the parent folder or "/" if the new folder will be placed in the root directory
* $action: Set to "new", "createifnotexists" or "update".
Return Value:
If a folder was created, an associative array like the following is returned:
Code: Select all
array ( 
  "success" => 1,
  "message" => "Folder successfully created. <br /> Complaints", 
  "folderUID" => 958863346595ed6d9af9ff5099891587
) 
If there was a failure, then an associative array like the following is returned:
Code: Select all
array ( 
   "success" => "",
   "error" => "Can't create folder <br/> A folder with same name already exist.<br/>Complaints",
   "message" => "Can't create folder <br/> A folder with same name already exist.<br/>Complaints",
   "folderUID" => "958863346595ed6d9af9ff5099891587"
) 
You can use this code in a trigger or a plugin to create a new folder:
Code: Select all
if (isset(@@newFolderName) and !empty(@@newFolderName)) {
  require_once('classes/model/AppDocument.php');
  require_once('classes/model/AppFolder.php');
  $oFolder = new AppFolder();
  @=aResponse = $oFolder->createFolder(@@newFolderName, "/", "new");
  if (@=aResponse['success'] != 1) {
	  $err = str_replace("<br/>", " ", @=aResponse['error']);
	  $g = new G();
      $g->SendMessageText($err, "WARNING");
  }
}	
Where "newFolderName" is a variable associated with a text box in a prior DynaForm where the user can enter a new folder name.

The AppFolder class is defined in workflow/engine/classes/model/AppFolder.php and there are examples of using this class in workflow/engine/methods/appFolder/appFolderAjax.php.
#793738
amosbatto wrote:AppFolder::createFolder() creates or updates a folder found under Home > Documents.
array AppFolder::createFolder($folderName, $folderParent = "/", $action = "createifnotexists")
Parameters:
* $folderName: name of the new folder.
* $folderParent: The unique ID of the parent folder or "/" if the new folder will be placed in the root directory
* $action: Set to "new", "createifnotexists" or "update".
Return Value:
If a folder was created, an associative array like the following is returned:
Code: Select all
array ( 
  "success" => 1,
  "message" => "Folder successfully created. <br /> Complaints", 
  "folderUID" => 958863346595ed6d9af9ff5099891587
) 
If there was a failure, then an associative array like the following is returned:
Code: Select all
array ( 
   "success" => "",
   "error" => "Can't create folder <br/> A folder with same name already exist.<br/>Complaints",
   "message" => "Can't create folder <br/> A folder with same name already exist.<br/>Complaints",
   "folderUID" => "958863346595ed6d9af9ff5099891587"
) 
You can use this code in a trigger or a plugin to create a new folder:
Code: Select all
if (isset(@@newFolderName) and !empty(@@newFolderName)) {
  require_once('classes/model/AppDocument.php');
  require_once('classes/model/AppFolder.php');
  $oFolder = new AppFolder();
  @=aResponse = $oFolder->createFolder(@@newFolderName, "/", "new");
  if (@=aResponse['success'] != 1) {
	  $err = str_replace("<br/>", " ", @=aResponse['error']);
	  $g = new G();
      $g->SendMessageText($err, "WARNING");
  }
}	
Where "newFolderName" is a variable associated with a text box in a prior DynaForm where the user can enter a new folder name.

The AppFolder class is defined in workflow/engine/classes/model/AppFolder.php and there are examples of using this class in workflow/engine/methods/appFolder/appFolderAjax.php.
Exactly what I was looking for, thanks a lot for helping !

The 500 Internal Server Error is the general catch[…]

Really very nice blog information for this one and[…]

This is a long, lengthy and cumbersome process. T[…]

Great read for when on the road. The book provides[…]