How to get an object by Key

To get any object by key, we need to use the primary key of the object and the findbyKey web service


In this example, we are going to get the PM Template object by key. The key we need to use for PM Template object is the “template_id”. If we are to get an object by key, the object has to exist in the system.

  • Go to AiM and find a sample object which you are going to get by key.


Now, go to the PMTemplate class and create a find function which returns an XML Object. We need to do the following steps to create the find function.

  • Setup the authentication details in the PMTmp class
  • Create a service stub for the FindAeRPmiEByKey web service and pass the ENDPOINT URL of the web service
  • Pass the authentication through the serviceStub using Options
  • Create a “FindAeRPmiEByKeyDocument” document
  • Create AeRPmiEKeyType object and pass the primary key to find the object
  • Now, use the service stub to call the findAeRPmiEByKey web service and store the result in a AeRPmiEDocument
  • Return the Document found using the key which is same object we needed to find


Go back to Development with web services – Training