Call to a member function getInfolist() on null

I'm trying to create a custom Infolist action, but I'm getting the following error

Call to a member function getInfolist() on null

This is the action I've created


class CustomLinkAction extends Action
{
    // use CanCustomizeProcess; // I added this because I thought it was needed but it didn't help

    public static function getDefaultName(): ?string
    {
        return 'customLink';
    }

    protected function setUp(): void
    {
        parent::setUp();

        // The following line throws the error. But anything that uses `$this` seems to throw the same error
        $this->url($this->getRecord()->getCustomUrl());
    }
}
Solution
closure maybe
$this->url(function ($record) {
    //...
});
Was this page helpful?