如何使用gooddata-js查找“本地标识符”以执行AFM功能

时间:2019-07-25 12:36:23

标签: gooddata

我在项目中使用gooddata-js,并且尝试使用功能execute.executeAfm,但出现有关“在AFM中找不到本地标识符”的错误。

我遵循了documentation关于AFM和结果规范的信息,但是我不知道在哪里可以找到要放入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: ""

1 个答案:

答案 0 :(得分:1)

您正在寻找resultSpec的文档,网址为:

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

从您的代码段中,我只能猜测一个有效的resultSpec可能看起来像这样:

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