Get Column Value from Row

You can retrieve a specific column’s value in a row in a Data Store table. That is, if you require the value of the column ‘Employee ID’ alone for in a row, you can retrieve it using this operation.

You can execute this operation in three ways, as shown below.

The <ROW_INSTANCE> used in all the code sections below is the instance defined in the Row Instance page.

If you know the data type of the column:

copy
let data : <T> = try <ROW_INSTANCE>.getValue(forKey: "<columnName>")

Parameters:

  • T: Datatype of the expected value
  • columnName: Name of the column for that needs to be fetched

A sample code snippet is shown below:

copy
ZCatalystApp.shared.getDataStoreInstance().getTableInstance(id: 1096000000002071).getRow(id: 1096000000002845) {( result ) in
//Replace this with your Table ID and ROWID
switch result{
  case .success ( let row) :
   do{
    let data : String =  try row.getValue(forKey: "EmpID") as! String
    print(data)
   }
  catch{
   print("Error occured")
  }
 case .error( let error ) :
  print( "Error occurred >>> \( error )" )
 }
}

If you don’t know the data type of the column:

copy
let data : <T>? = <ROW_INSTANCE>.getValue(forKey: "<columnName>")

Parameters:

  • T: Datatype of the expected value
  • columnName: Name of the column for that needs to be fetched

A sample code snippet is shown below:

copy
ZCatalystApp.shared.getDataStoreInstance().getTableInstance(id: 1096000000002071).getRow(id: 1096000000002845) {( result ) in
//Replace this with your Table ID and Row ID
switch result{
  case .success ( let row) :
   let data :String? = row.getValue(forKey: "EmpID")
   print(data)
  case .error( let error ) :
   print( "Error occurred >>> \( error )" )
 }
}

Without using getValue():

copy
let data : <T>? = <ROW_INSTANCE>[ "<columnName>" ]

Parameters:

  • T: Datatype of the expected value
  • columnName: Name of the column for that needs to be fetched
copy
ZCatalystApp.shared.getDataStoreInstance().getTableInstance(id: 1096000000002071).getRow(id: 1096000000002845) {( result ) in
//Replace this with your Table ID and Row ID
switch result{
  case .success ( let row) :
   let data :String? = row[ "EmpID" ]
   print(data)
  case .error( let error ) :
   print( "Error occurred >>> \( error )" )
 }
}

Last Updated 2025-08-28 12:01:44 +0530 IST