Power BI 自定义连接器导航表中的功能

问题描述 投票:0回答:1

我正在为 Power BI 构建自定义数据连接器,尝试按照 官方代码示例公开具有几个函数的导航表。但是,即使我的函数不接受任何参数,当我尝试在 Power BI 中导入其数据时,我也会收到“未指定参数值”消息:

enter image description here

知道为什么吗?我的代码中是否缺少某些内容?

另外,我一直想知道是否可以通过添加 函数文档 来将自定义 UI 添加到各个函数,但这似乎也不起作用。这个功能是不是只有连接器的顶层功能才可用?

作为参考,这是我的 TestConnector 的完整实现:

// This file contains your Data Connector logic
[Version = "1.0.0"]
section TestConnector;

TestConnector = [
    Authentication = [
        Anonymous = []
    ]
];

TestConnector.Publish = [
    Beta = true,
    Category = "Other",
    ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },
    LearnMoreUrl = "https://powerbi.microsoft.com/",
    SourceImage = TestConnector.Icons,
    SourceTypeImage = TestConnector.Icons
];

TestConnector.Icons = [
    Icon16 = { Extension.Contents("TestConnector16.png"), Extension.Contents("TestConnector20.png"), Extension.Contents("TestConnector24.png"), Extension.Contents("TestConnector32.png") },
    Icon32 = { Extension.Contents("TestConnector32.png"), Extension.Contents("TestConnector40.png"), Extension.Contents("TestConnector48.png"), Extension.Contents("TestConnector64.png") }
];

[DataSource.Kind="TestConnector", Publish="TestConnector.Publish"]
shared TestConnector.Contents = () => GetNavigationTable();

GetNavigationTable = () as table =>
    let
        _table = #table(
            { "Name", "Key", "Data", "ItemKind", "ItemName", "IsLeaf" },
            {
                { "Test Function", "func1", Value.ReplaceType(TestFunction, TestFunctionType), "Function", "Function", true },
                { "Another Function", "func2", AnotherFunction.Contents, "Function", "Function", true }
            }
        )
    in
        NavigationTable.FromTable(_table, {"Key"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf");

TestFunction = (message as text) as table =>
    let
        result = #table(
            { "Column1", "Column2" },
            {{ "Test Function A", message }}
        )
    in
        result;

TestFunctionType = type function (
    message as (type text meta [
        Documentation.FieldCaption = "Message",
        Documentation.FieldDescription = "Parameter description..."
    ])
) as table meta [
    Documentation.Name = "Test Function",
    Documentation.LongDescription = "Function description..."
];

AnotherFunction.Contents = () => "Returns a static string when invoked.";

NavigationTable.FromTable = (_table as table, keyColumns as list, nameColumn as text, dataColumn as text, itemKindColumn as text, itemNameColumn as text, isLeafColumn as text) as table =>
    let
        tableType = Value.Type(_table),
        newTableType = Type.AddTableKey(tableType, keyColumns, true) meta 
        [
            NavigationTable.NameColumn = nameColumn, 
            NavigationTable.DataColumn = dataColumn,
            NavigationTable.ItemKindColumn = itemKindColumn, 
            Preview.DelayColumn = itemNameColumn, 
            NavigationTable.IsLeafColumn = isLeafColumn
        ],
        navigationTable = Value.ReplaceType(_table, newTableType)
    in
        navigationTable;

提前感谢您的任何建议!

powerbi powerquery
1个回答
0
投票

尝试

AnotherFunction.Contents = () as any => "Returns a static string when invoked.";

而不是

AnotherFunction.Contents = () => "Returns a static string when invoked.";
© www.soinside.com 2019 - 2024. All rights reserved.