如何找到 "Local Identifier" 以使用 gooddata-js 执行 AFM 功能

How to find the "Local Identifier" to execute AFM function using gooddata-js

我在我的项目中使用 gooddata-js 并且我正在尝试使用函数 execution.executeAfm,但是出现关于 "Local identifier no found in AFM" 的错误。

我遵循了 documentation 关于原子力显微镜和结果规范的内容,但我不知道在哪里可以找到“本地标识符”以放入 itemIdentifiers。我试过输入 ['measureGroup'] 但没用!

execution: {
                afm: {
                    measures: [
                        // Type: IMeasure
                        {
                            localIdentifier: '740953a40a01490c8aaeba66a21cac53',
                            // Type: MeasureDefinition
                            definition: {
                                measure: {
                                    // Type: ObjQualifier
                                    item: {
                                        uri: '/gdc/md/PROJECT_ID/obj/245828'   
                                    },
                                    filters: [
                                        // Type: IAbsoluteDateFilter
                                        {
                                            relativeDateFilter: {
                                                dataSet: {
                                                    uri: '/gdc/md/PROJECT_ID/obj/3603'
                                                },
                                                from : 0,
                                                granularity : 'GDC.time.month',
                                                to : 0
                                            }
                                        },
                                    ],
                                    computeRatio: false
                                }
                            },            
                        }
                    ]
                },
                resultSpec:
                {
                    dimensions: [
                        {
                            itemIdentifiers: ['gdc.visualization.table']
                        }
                    ]
                }
            }

我期待 AFM 功能的结果,但显示以下错误!

error: {errorClass: "com.gooddata.webapp.service.executeafm.exception.LocalIdentifierNotFoundException",…}
component: "Webapp"
errorClass: "com.gooddata.webapp.service.executeafm.exception.LocalIdentifierNotFoundException"
errorCode: "gdc111"
errorId: "fe33be5e-cf0f-4195-b8eb-f28acafd8890"
message: "Local identifier=%s of type=%s not found in AFM."
parameters: ["gdc.visualization.table", "AttributeItem"]
0: "gdc.visualization.table"
1: "AttributeItem"
trace: ""

您正在寻找 resultSpec 的文档,此处提供:

https://sdk.gooddata.com/gooddata-ui/docs/result_specification.html

根据您的代码片段,我只能猜测有效的 resultSpec 可能如下所示:

{
  "dimensions": [
    {
      "itemIdentifiers": [
        "measureGroup"
      ]
    },
    {
      "itemIdentifiers": []
    }
  ],
  "sorts": []
}