OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
686 stars 95 forks source link

🐛 Cannot install functions if a repeating matrix argument is marked as required #2732

Closed wh1t3cAt1k closed 7 months ago

wh1t3cAt1k commented 2 years ago

Message from office-js bot: We’re closing this issue because it has been inactive for a long time. We’re doing this to keep the issues list manageable and useful for everyone. If this issue is still relevant for you, please create a new issue. Thank you for your understanding and continued feedback.

If an argument is simultaneously repeating, matrix and optional: false, add-in fails to install the custom functions.

Your Environment

Expected behavior

CONTOSO.ANSWER(Argument1, [Argument2], [Argument3], ...)

Current behavior

Add-in fails to install the custom functions altogether. There is no reasonable troubleshooting message for developer

(BTW, the latter is a related general problem for us, could we also ask to direct those errors into the console so we could understand what was the offending function? It takes a lot of trial-and-error to understand what caused the functions to suddenly top loading)

Steps to reproduce

  1. Use https://github.com/VelixoSolutions/optional-repeating-matrix-with-address-bug
  2. build the project
  3. Start the dev server
  4. In the dist/functions.json, add an explicit optional: false to the argument definition.
  5. I want to emphasize that this is a valid configuration according to the documentation: I just found no way to do it with autogeneration of metadata. We use manual metadata assembly in our project due to localization needs.
  6. Open Excel online and sideload the manifest.

Context

Cannot achieve consistency with our legacy COM-based add-in, migration to the modern framework hampered by this issue.

JHJ-MS commented 2 years ago

Hi @wh1t3cAt1k , if the argument is simultaneously repeating, number, and optional: false, will the custom functions fail to install? If it will, I think this may cause by repeating parameters by default is optional and cannot change to not optional. Otherwise, we don't know how many repetitions are appropriate.

If it won't, It should be a bug.

wh1t3cAt1k commented 2 years ago

@JHJ-MS it's quite clear in my view, that the behaviour should be the same as we have in the COM-based add-in: Excel would check that at least the first of the repeating arguments is specified (and display it as non-optional in Intellisense), and the rest of repetitions are displayed as optional.

Argument1, [Argument2], ...

I can check the number case later today

ghost commented 2 years ago

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

wh1t3cAt1k commented 2 years ago

Still relevant

wh1t3cAt1k commented 2 years ago

@JinghuiMS @JHJ-MS the bug reproduces even for non-matrix arguments, so I will reformulate the bug title.

{
    "functions": [
        {
            "description": "Returns 42",
            "id": "ANSWER",
            "name": "ANSWER",
            "options": {
                "requiresAddress": true
            },
            "parameters": [
                {
                    "description": "Repeating argument.",
                    "name": "Argument",
                    "repeating": true,
                    "type": "number",
                    "optional": false
                }
            ],
            "result": {
                "type": "number"
            }
        }
    ]
}

Result:

image

Expected result:

The behaviour should be the same as we have in the COM-based add-in: Excel would check that at least the first of the repeating arguments is specified (and display it as non-optional in Intellisense), and the rest of repetitions are displayed as optional.

Argument1, [Argument2], ...

JHJ-MS commented 2 years ago

Hi @wh1t3cAt1k, the non-optional repeating parameter is not supported for Custom Functions now. To achieve your goal, you can append an additional non-optional argument. Besides, you can go to Microsoft 365 Developer Platform Ideas Forum to request a new feature. Thanks for your reporting again.

ghost commented 2 years ago

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

ghost commented 2 years ago

This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue.

wh1t3cAt1k commented 2 years ago

@JHJ-MS @JinghuiMS @RuizhiSunMS @Wenjun-Gong please reopen this. The workaround proposed (adding another argument) is not working for us because we need to maintain 100% function-level compatibility with our legacy XLL add-in.