Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

This content has been archived and is no longer being updated.

Links may not function; however, this content may be relevant to outdated versions of the product.

Listing cases and their details with the Connect SDK on iOS

Updated on July 18, 2018

This tutorial demonstrates how to configure and integrate the Connect SDK features with a new iOS application that was created in the Xcode development environment by using the Swift language. The tutorial explains how to use the Connect SDK Cases API to obtain a list of cases for a user and display the case details.

The tutorial contains the following sections:

This walkthrough takes approximately 30 minutes to complete.

Prerequisites

Before you start this tutorial, do the following tasks:

  • Read Tutorial: Creating a Hello World iOS app with the Connect SDK, which demonstrates how to set up the Connect SDK in the Xcode environment, initialize it in the application, and use it to authenticate.
  • Download the ZIP file, which contains the sample Swift code and other Xcode project files for the iOS app that is described in this tutorial.

You can connect to any Pega® Platform instance to test the sample iOS app. Make sure that it already includes some cases and assignments.

Obtaining a list of cases

You can use the Cases API to obtain a list of cases for the Pega Platform application.

  1. In the Xcode environment, click New>File> Cocoa Touch Class and create a subclass of UITableViewController.
  2. Name the subclass CasesVC. This subclass is where all the logic that is related to obtaining a list of cases for a Pega 7 Platform application is placed. It is also linked to a new scene for your application's user interface. This scene should be based on a template or be inherited from another class.
  3. Declare a cases property to represent the obtained cases within this new class:
    var cases = [PMCaseInfo]()
  4. Create the getCases() method for the CasesVC class. Make a call to the getAll() method of the casesService Connect SDK object to obtain a list of available cases. This method returns an array of cases denoted by the cases completion block parameter. The returned contents are then referenced by the local cases property that was declared earlier for the CasesVC class:
    func getCases() {
        PegaApi.shared.casesService.getAll { cases, error in
            if let error = error {
                self.showAlert(with: error)
            } else if let cases = cases {
                self.cases = cases.sorted {
                    $0.lastUpdateTime! > $1.lastUpdateTime!
                }
                DispatchQueue.main.async {
                    self.tableView.reloadData()
                }
            }
        }
    ​}
  5. Override the viewWillAppear() method for the class and call the getCases() method so that the getCases() method is called when the CasesVC view is about to appear. Override important methods inherited from UITableViewController: tableView(_:numberOfRowsInSection:), tableView(_:cellForRowAt:), tableView(_:didSelectRowAt:), prepare(for segue:sender:) so that the fetched cases are presented in the CasesVC table view cells. For a preview of the implementation, see the demo project.

    List of cases - Cases API

    List of cases - Cases API

Obtaining case details

After you receive a list of cases, you can add code that obtains the details for a particular case based on its identifier.

  1. In the Xcode environment, click New> File> Cocoa Touch Class and create a subclass of UIViewController.
  2. Name the subclass CaseDetailsVC. This subclass is where all the logic that is related to obtaining case details is placed. It is also linked to a separate scene of your application's user interface. This scene should be based on a template or be inherited from the given class.
  3. Declare a caseID property, which is where the case identifier is passed from the segue from the CasesVC class:
    var caseID: String?
  4. Add the getCase() method to the class where you call the getCase() method for the casesService Connect SDK object. This method contains one parameter that specifies the identifier of the case for which to obtain details. The identifier was passed from the CasesVC segue. It returns a caseItem variable that contains the case details. Notice that the local properties for this new class include the returned case details. These local properties are needed so that later you can show the case content screen of your application with the case details.
    func getCase(for id: String) {
        PegaApi.shared.casesService.getCase(byID: id) { caseItem, error in
            if let error = error {
                self.showAlert(with: error)
            } else if let caseItem = caseItem {
                DispatchQueue.main.async {
                    self.caseContent = caseItem.content
                    self.currentCase = caseItem
                    self.idLbl.text = caseItem.ID
                    self.nameLbl.text = caseItem.name
                    self.statusLbl.text = caseItem.status
                    self.urgencyLbl.text = caseItem.urgency
                }
            }
        }
    ​}
    
  5. Override the viewDidLoad() method for this new class so that the getCase() method is always initially called displaying the given case details on the screen. Create an action connection for a View all case content button in this scene and the showCaseContent() method. This method references the CaseContentVC class that displays the details for a case in another scene of the application. In addition, override the prepare(for segue:sender:) method so that the case content to be displayed is passed to the CaseContentVC object.

    Case details - Cases API

    Case details - Cases API

Related articles

Connect SDKCreating a Hello World iOS app with the Connect SDKListing case types and creating cases with the Connect SDK on iOSListing assignments and their details with the Connect SDK on iOSObtaining data page contents and metadata with the Connect SDK on iOS

Tags

Pega Platform 7.3.1 Pega Mobile Mashup Mobile Pega Express Communications and Media Consumer Services Financial Services Government Healthcare and Life Sciences Insurance Healthcare and Life Sciences Manufacturing Consumer Services Consumer Services

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us