AnswerService

AnswerService

Class representing the answer service provided with the custom action payload. This service could be used to run graphql queries in the context of the answer on which the custom action was triggered.

Version : SDK: 1.25.0| ThoughtSpot: 9.10.0.cl

 embed.on(EmbedEvent.CustomAction, e => {
    const underlying = await e.answerService.getUnderlyingDataForPoint([
      'col name 1'
    ]);
    const data = await underlying.fetchData(0, 100);
 })

ConstructorsπŸ”—

Should not need to be called directly.

new AnswerService(session: SessionInterface , answer: any , thoughtSpotHost: string , selectedPoints?: VizPoint[] ) : AnswerService

Should not need to be called directly.

Function Parameters

session
answer
  • answer: any

thoughtSpotHost
  • thoughtSpotHost: string

selectedPoints

Optional

Returns

MethodsπŸ”—

addColumnsπŸ”—

addColumns(columnIds: string[] ) : Promise< any >

Add columnIds and return updated answer session.

Function Parameters

columnIds
  • columnIds: string[]

Returns

Promise< any >

executeQueryπŸ”—

executeQuery(query: string , variables: any ) : Promise< any >

Execute a custom graphql query in the context of the answer.

Function Parameters

query
  • query: string

graphql query

variables
  • variables: any

graphql variables

Returns

Promise< any >

fetchCSVBlobπŸ”—

fetchCSVBlob(userLocale?: string = 'en-us', includeInfo?: boolean = false) : Promise< Response >

Fetch the data for the answer as a CSV blob. This might be quicker for larger data.

Function Parameters

userLocale
  • userLocale: string = 'en-us'

includeInfo
  • includeInfo: boolean = false

Include the CSV header in the output

Returns

Promise< Response >

fetchDataπŸ”—

fetchData(offset?: number = 0, size?: number = 1000) : Promise< {columns: any , data: any } >

Fetch data from the answer.

Function Parameters

offset
  • offset: number = 0

size
  • size: number = 1000

Returns

Promise< {columns: any , data: any } >

getFetchCSVBlobUrlπŸ”—

getFetchCSVBlobUrl(userLocale?: string = 'en-us', includeInfo?: boolean = false) : string

Just get the internal URL for this answer’s data as a CSV blob.

Function Parameters

userLocale
  • userLocale: string = 'en-us'

includeInfo
  • includeInfo: boolean = false

Returns

string

getSessionπŸ”—

getSession() : SessionInterface

Get the internal session details for the answer.

Returns

getSourceDetailπŸ”—

getSourceDetail() : Promise< any >

Get the details about the source used in the answer. This can be used to get the list of all columns in the data source for example.

Returns

Promise< any >

getUnderlyingDataForPointπŸ”—

getUnderlyingDataForPoint(outputColumnNames: string[] , selectedPoints?: UnderlyingDataPoint[] ) : Promise< AnswerService >

Get underlying data given a point and the output column names. In case of a context menu action, the selectedPoints are automatically passed.

Function Parameters

outputColumnNames
  • outputColumnNames: string[]

selectedPoints

Optional

Returns

Promise< AnswerService >

Version : SDK: 1.25.0| ThoughtSpot: 9.10.0.cl

 embed.on(EmbedEvent.CustomAction, e => {
    const underlying = await e.answerService.getUnderlyingDataForPoint([
      'col name 1' // The column should exist in the data source.
    ]);
    const data = await underlying.fetchData(0, 100);
 })

removeColumnsπŸ”—

removeColumns(columnIds: string[] ) : Promise< any >

Remove columnIds and return updated answer session.

Function Parameters

columnIds
  • columnIds: string[]

Returns

Promise< any >