How to use plugin method inside Keywords

I am trying to use a database plugin method inside Keywords but I am getting error. Could you please tell me how to use the method inside
@devalex88 @kazurayam

The CustomKeywords class is accessible for Test Case scripts, but it is not for the Keywords. Therefore CustomKeywords is underlined in the Keyword source code as you see.

You have this now:

    actorData = CustomKeywords.'com.katalon.plugin.keyword.connection.DatabaseKeywords.executeQuery'(globalConnection, subsetId)
    def realmId = CustomKeywords.'com.katalon.plugin.keyword.connection.ResultSetKeywords.getSingleCellValue'(actorData, 1, 1)

You should refrain from CustomKeywords.

Please try modifying it as follows:

import com.katalon.plugin.keyword.connection.DatabaseKeywords
import com.katalon.plugin.keyword.connection.ResultSetKeywords
...
    actorData = DatabaseKeywords.executeQuery(globalConnection, subsetId)
    def realmId = ResultSetKeywords.getSingleCellValue(actorData, 1, 1)

and see how it goes.

… Though I am not sure if com.katalon.plugin.keyword.connection.DatabaseKeywords is successfully imported.

@kazurayam thanks!

it didn’t work. I imported the statements and modified the script. Still no luck

import com.katalon.plugin.keyword.connection.DatabaseKeywords

This import statement looks working fine. But your code fails to call the executeQuery as a static method of DatabaseKeywords.

Then, please try modifying the code as follows:

import com.katalon.plugin.keyword.connection.DatabaseKeywords
import com.katalon.plugin.keyword.connection.ResultSetKeywords
...
    def dbkwd = new DatabaseKeywords()
    actorData = dbkwd.executeQuery(globalConnection, subsetId)
    def rskwd = new ResultSetKeywords()
    def realmId = rskwd.getSingleCellValue(actorData, 1, 1)

The source code of the DatabaseKeywords class is published here:

You can read the source and will find that the executeQuery() is an instance method, not a static method. So you need to create an instance of the class first, then you call the method of the instance.

Thanks @kazurayam it worked.