code: public Task getTask()
      {
          if (this.getScreenField() instanceof BasePanel)
              return ((BasePanel)this.getScreenField()).getTask();
          else
              return this.getScreenField().getParentScreen().getTask();
      }
docs: Get the environment to use for this record owner.
  @return Record owner's environment, or null to use the default enviroment.