Category Archives: K2 SmartObjects

ServiceObject definition does not contain method. ServiceObject:<>.Method: <>

Recently I encountered an issue while deploying a package from one environment to another. While testing the smartobject after the deployment, the following error message pop up :

Figure 1 Smartobject definition error

Reason: this error is thrown when the underlying method (tables or stored procedure in this case) cannot be found. This could be due to deletion or when the external component is not setup yet.

Steps to create the above scenario:

  1. Create a few stored procedures
  2. Refresh the Service Instance so that Stored Procedures are retrieved from the DB .
  3. Create the smartobjects from the instances.
Figure 2 SmartObjects generated from the create method

4. Now go back to the DB and delete one of the previously created Stored Procedure and add another one. Then refresh again (but do not create or generate the smartobject yet):

Figure 3 Newly retrieved Stored Procedures

As can be seen in the above image, there is a difference between the stored procedures. [dbo].[GetAnotherThing] does not exist and a new stored procedure [dbo].[GetSomethingFromTableDrop] is added. When the SmartObject GetAnotherThing is executed, the error dialog in Figure 1 will be shown.

Most of us when generating SmartObjects will use the Service tester to do so and select the Create method (Figure 4). When the Create SmartObjects method is used, smartobject with the missing method will still be there.

Figure 4 Create SmartObjects

The reason is that when this method is used, it does not delete any smartobjects since it is a smartobject creation/update method (Figure 5).

Figure 5 Creating SmartObjects Dialog box

Instead use the Generate smartobject method (Figure 6), this method will display the smartobject to be deleted as well besides the Create/Update method, BUT the drawback is that, it does not allow you to select the category to create the smartobject to:

Figure 6 Generate SmartObject dialog


Do not be mistaken and think that when external components are deleted, and doing a refresh of the service instances and executing the create smartobjects method will remove smartobjects that is to be deleted. Use the generate smartobjects method to help verify whether any smartobjects are to be deleted. Hope this helps someone!