'Katalon : groovy.lang.MissingPropertyException : Using custom keyword in custom keyword

In Katalon, if I want to use CustomKeyword inside another CustomKeyword. I getting MissingPropertyException

Dialog Keywords

public class Dialog {

    @Keyword
    def clickCancel() {
      WebUI.click(findTestObject('Common/Components/Dialog/btn_Cancel'))
    }

    ...
}

Root Navigation Keywords

public class RootNavigations {

    @Keyword
    def checkDialogWorking() {
      WebUI.click(findTestObject('App/Page_Home/btn_OpenComparisons_Dialog_Home'))
      CustomKeywords.'com.app.Dialog.clickCancel'()
    }

    ...
}

Exception

Test Cases/Smoke Test/Application/Check Dialog 
FAILED because (of) (Stack trace: groovy.lang.MissingPropertyException: 
No such property: CustomKeywords for class: com.app.RootNavigations


Solution 1:[1]

import class into another Keyword class and declare its object to use that Keyword.

Root Navigation Keywords

public class RootNavigations {

    final dialog = new Dialog() // ******* imp step

    @Keyword
    def checkDialogWorking() {
      WebUI.click(findTestObject('App/Page_Home/btn_OpenComparisons_Dialog_Home'))
      this.dialog.clickCancel() // ******* imp step
    }

    ...
}

Solution 2:[2]

to call custom keyword from another one you can call it also this way:

(new com.app.Dialog()).clickCancel()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sumit Ramteke
Solution 2 Andrej