async getVisualByName()

in src/page.ts [318:334]


  async getVisualByName(visualName: string): Promise<VisualDescriptor> {
    if (isRDLEmbed(this.report.config.embedUrl)) {
      return Promise.reject(APINotSupportedForRDLError);
    }

    try {
      const response = await this.report.service.hpm.get<IVisual[]>(`/report/pages/${this.name}/visuals`, { uid: this.report.config.uniqueId }, this.report.iframe.contentWindow);
      const visual = response.body.find((v: IVisual) => v.name === visualName);
      if (!visual) {
        return Promise.reject(CommonErrorCodes.NotFound);
      }

      return new VisualDescriptor(this, visual.name, visual.title, visual.type, visual.layout);
    } catch (response) {
      throw response.body;
    }
  }