> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating an activity

> Configure the UploadFileToCase activity in Pega that loads a JSON request, retrieves the case by ID, and attaches an exported file to the work object.

To create a new activity:

1. In the POST request of the service, type a name for your new activity (e.g. *UploadFileToCase*) in the **Activity name** field.
2. Click **Create and open** to configure the new activity.
3. On the **Security** tab, add the following classes that will be accessed by the method and the activity: *Pega-API-CaseManagement* and *Work-*.
4. On the **Pages & Classes** tab, declare the classes that will be used by the activity:
   * *AttachmentPage* of type *Data-WorkAttach-File*
   * *pyWorkPage* of type *Work-*

<Note>
  In Pega, a ***page*** corresponds to a class object.
</Note>

5. On the **Parameters** tab, add the parameters that will be used by the activity.
   * Parameters:
     * FileStream of type *String* – This parameter will contain the contents of the file in Base64.
   * Local variables:
     * IsConverted of type *Boolean* – The logical variable that will contain the result of executing the method that converts the JSON object in the POST request into global variables of *myStepPage*.
6. On the **Steps** tab, create new steps for methods that will load objects and link the case to its file.
   * To load the JSON object from the POST request into the activity parameters:
     * In the **Method** field type this method name: *Property-Set*
     * In the **Step page** field, type *.createCaseRequest*
     * Convert the result of the *@(Pega-RULES:Page).pxConvertStringToPage(tools, myStepPage, Param.Request,"json")* method to the *Local.IsConverted* variable. The value is *true* if the JSON object from the POST request is successfully converted to the *myStepPage* object. Otherwise, the value is *false*.
     * Once the *myStepPage* object has been populated, populate the activity variables: *Param.FileStream = .FileStream*. To add new properties to *myStepPage*, click the target icon on the right and then click **Create and open** on the **Create Property** form.
   * To get the object containing the case by its ID:
     * In the **Method** field, type *pxGetCase: Call pxGetCase* to call the activity.
     * In the **Step page** field, type the name of the object that will store the *pyWorkPage* result. In the **WorkObjectId** parameter, type *Param.CaseId* (i.e. the case ID).
   * To create a new empty object named *AttachmentPage* that was declared on the **Pages & Classes** tab:
     * In the **Method** field, type *Page-New*.
     * In the **Step page** field, type *AttachmentPage*.
     * Leave the method parameters empty.
   * For the parameters of the *AttachmentPage* object:
     * The *.pxAttachName* parameter must be populated with the value from *Param.FileName*, the *.pxAttachStream* parameter must be populated with the value from *Param.FileStream*, the *.pxAttachKey* parameter must be populated with the value from *@getCurrentTimeStampUnique()*, and the *.pxRefObjectKey* parameter must be populated with the value from *pyWorkPage.pzInsKey*.
     * In the **Method** field, type *Property-Set*.
     * In the **Step page** field type *AttachmentPage*.
   * Use the *Odj-Save* method to save the *AttachmenetPage* object.
   * Use the *Link-Objects* method to link the *pyWorkPage* object (i.e. the case that we got by using *pxGetCase: Call pxGetCase*) to the *AttachmentPage* object. In the *LinkToPage* parameter, type *AttachmentPage;* in the *LinkClass* parameter, type *Link-Attachment;* and in the *LinkMemo* parameter, type *Param.FileName*.
   * Use the *Commit* method to commit the changes to the database.
   * If necessary, write to *Param.Response* the *pyWorkPage – @(Pega-RULES:Page).pxConvertPageToString(tools, pyWorkPage, "json")* object received in the response from the service.
