Obj open and open by handle

Hi,

we can open a record using obj-open by passing primary key and for obj open by handle we can pass pzInsKey as parameter and open it.

For obj-open-by-handle can’t we pass pyID which is also primary key of case.

if yes then what’s the key difference between open nd open by handle

@Yasvanth Tanuku

Obj-Open is a general-purpose method for opening an object instance based on its class key/Primary key. It’s the safer and more common choice in most cases.

Obj-Open-By-Handle uses an internal, system-generated pzInsKey to open an instance. This pzInsKey is unique and permanent, unlike the class key which can be shared by multiple instances. Use Obj-Open-By-Handle only when:

  • If we know the exact pzInsKey of the specific instance you want to open.
  • Performance is critical: Obj-Open-By-Handle can be slightly faster than Obj-Open in some situations.

In summary:

  • Use Obj-Open for most cases.
  • Use Obj-Open-By-Handle only when needed for specific reasons.

Hi @Yasvanth Tanuku,

In Pega, both Obj-Open and Obj-Open-By-Handle are used to open records from the database, but they function differently:

1. Obj-Open

  • Used when you want to open a record by specifying one or more key properties.

  • Typically requires primary key fields (like pyID, pxObjClass, etc.).

  • You must specify all required key properties defined in the class’s key structure.

  • Uses keyed lookup on a single

2. Obj-Open-By-Handle

  • Uses pzInsKey (the unique system-generated key for each record).

  • pzInsKey is a combination of class name and unique identifier (e.g., ABC-XYZ-Work W-1001!01).

  • Always retrieves only one specific record.

  • More efficient because it directly fetches the record using a unique key (like a direct lookup in a database).

  • No need to specify multiple properties—just the pzInsKey.

Why can’t we use pyID in Obj-Open-By-Handle?

  • pyID (like “W-1001”) is a logical identifier but not unique on its own.

  • Multiple instances of the same case might exist (e.g., multiple versions in case history, different data instances).

  • pzInsKey ensures a specific record is retrieved, avoiding ambiguity.

@Mohd Qizer Uddin

I did not get

  • pyID (like “W-1001”) is a logical identifier but not unique on its own.

  • Multiple instances of the same case might exist (e.g., multiple versions in case history, different data instances).

Can you explain

@Yasvanth Tanuku

You can have another case type of another class where the prefix is W, so the pyID can be W-1001 too. But the combination of class and pyID wont be unique, so pzInsKey is always unique.