Folder Collection Methods

In this section, we discuss the Folder collection methods. The methods are discussed in alphabetical order.

Syntax

DeleteItem(FolderName)

Description

The DeleteItem method deletes the folder object identified by FolderName from the database. If the folder contains other folders, all child folders and their contents are also deleted.

Warning! If you delete a folder, you delete all content in the folder. If you delete a folder that contains other folders, that is, a parent folder, all the child folders, and all the content references are deleted.

Note: The portal registry classes execute some methods "interactively", that is, as they happen. The item won't be marked for deletion, then actually deleted later. The item is deleted from the database as soon as the method is executed.

Parameters

Field or Control

Definition

FolderName

Specify the name of a folder existing in the folder collection.

Returns

A Boolean value: True if the folder was deleted, False otherwise.

Example

If Not &MyFolderColl.DeleteItem("MYFOLDER") Then
   /* Folder not deleted. Do error checking */
End-If;

Syntax

First()

Description

The First method returns the first Folder object in the folder collection.

Parameters

None.

Returns

Folder object.

Example

&MyFolder = &MyCollection.First();

Syntax

InsertItem(FolderName, Label)

Description

The InsertItem method inserts the folder object identified by FolderName from the Folder Collection. You must specify both a name and a label for all folders. This method returns a reference to the new folder object. You must specify a unique FolderName, or you receive an error.

Note: The portal registry classes execute some methods "interactively", that is, as they happen. The item won't be marked for insertion, then actually inserted later. The item is inserted into the database as soon as the method is executed.

Parameters

Field or Control

Definition

FolderName

Specify the name of a folder existing in the folder collection. This parameter takes a string value.

Label

Specify a label for the new folder. This parameter takes a string value.

Returns

A reference to the new Folder object if the method executed successfully, null otherwise.

Example

&DeptHPFldr = &MyPortal.Folders.InsertItem("PORT0145", "HR Folder for Department 0145");

Syntax

ItemByName(Name)

Description

The ItemByName method returns the Folder object with the name Name.

Parameters

Field or Control

Definition

Name

Specify the name of an existing folder within the folder collection. If you specify an invalid name, the object is NULL. You must specify a name, not a label.

Returns

A folder object if successful, NULL otherwise.

Example

&DeptFldr = &MyPortal.RootFolder.Folders.ItemByName(&Dept_Name);

Syntax

Next()

Description

The Next method returns the next Folder object in the Folder collection. You can use this method only after you have used the First method: otherwise the system doesn’t know where to start.

Parameters

None.

Returns

A folder object.

Example

Local ApiObject &MySession, &Root, &Folders, &MyFolder;

&MySession = %Session;
&MyPortal = &MySession.GetPortalRegistry("ADMIN");

&Root = &MyPortal.GetRoot();
&Folders = &Root.Folders;

&MyFolder = &Folders.First();

For &I = 1 to &Folders.Count
   /* Do processing on folders */ 
   If &I <> &Folders.Count
      &MyFolder = &Folders.Next();
   End-If;
End-For;