UIXv2: MFiles.GetWebLink always fails with exception

I am trying to call MFiles.GetWebLink

https://developer.m-files.com/Frameworks/User-Interface-Extensibility-Framework/Reference/UIExt2/Interfaces/ICommonFunctions/GetWebLink/

from within a UIX dashboard to get a link to an M-Files object - goal is to open a new browser tab with the URL so user can work on that particular object.

But I always get a rejected Promise with

TypeError: Cannot read properties of undefined (reading 'itemType')

This is puzzling, as there is no property called itemType in any of the UIX structures / objects.

Call parameters:

MFiles.GetWebLink(

{
  "obj_id": {
    "type": 0,
    "item_id": {
      "internal_id": 71,
      "external_repository_id": {
        "connection": "",
        "item": ""
      }
    }
  },
  "version": {
    "type": 4,
    "internal_version": 12,
    "external_repository_version": "",
    "external_repository_sort_key": 0
  }
},

"B1F89286-0DCE-4090-9408-101FFAF82256", undefined, undefined, true, 12 ).then(url => { /* ... */ });

I have alternatively tried to pass the GUID with curly braces and omit some of the last 4 arguments.

Parents
  • Oops, I noticed that above I passed the wrong type of object as first parameter, should be obj_id not obj_ver. However, if if I pass the obj_id it still results in the same TypeError.

    MFiles.GetWebLink(
     {
        "type": 0,
        "item_id": {
          "internal_id": 71,
          "external_repository_id": {
            "connection": "",
            "item": ""
          }
        }
    },

    "B1F89286-0DCE-4090-9408-101FFAF82256", undefined, undefined, true, 12 ).then(url => { /* ... */ });

    Then I remember, that I had actually reported this issue a few months ago by email - and also found a workaround to prevent the error: Pass an (undocumented) additional parameter with a member itemType:

    { itemType: "" }

    However the resulting URL does not work. The result is

    In M-Files vNext desktop client: a mostly empty page with the lone message:

    Cannot GET link/FA79DB3A-B747-47BE-BD84-A8E596B7CE04/show?object=3C112D5F-8C73-49CF-8013-C5E1FDE88C38&objid=0-248&version=15
    Continue

    In M-Files vNext web client:

    a) Using the URL in a regular <A href> tag will result replacing the dashboard page with a page with broken image links - see screenshot

    screenshot of M-Files vnext web client showing the error described

    b) Using the URL in a <A href target=_blank> tag will do noting visible, but the browser console will show an error:

    index.html:1 Blocked opening 'localhost/.../show in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.

    c) Calling OpenExternalWebLink with the URL returned by GetWebLink will indeed open a new browser tab but the page will be the same as in case a - broken images

    Screenshot of M-Files web vnext with bad page in new browser tab and and dev tools open

    I made a GitHub repository demonstrating the issue: https://github.com/mlisowsk/UIX2.DashboardLinks

    Here is the line of code that calls GetWebLink (with the workaround): https://github.com/mlisowsk/UIX2.DashboardLinks/blob/1651349ee0bf2f99737ba5a28c44908ddcb2ec56/UIX2.Dashboard/app/dashboard.js#L14

    If someone finds a solution to create an URL that will open an M-Files client window with a given M-Files object in focus that would be very appreciated.

Reply
  • Oops, I noticed that above I passed the wrong type of object as first parameter, should be obj_id not obj_ver. However, if if I pass the obj_id it still results in the same TypeError.

    MFiles.GetWebLink(
     {
        "type": 0,
        "item_id": {
          "internal_id": 71,
          "external_repository_id": {
            "connection": "",
            "item": ""
          }
        }
    },

    "B1F89286-0DCE-4090-9408-101FFAF82256", undefined, undefined, true, 12 ).then(url => { /* ... */ });

    Then I remember, that I had actually reported this issue a few months ago by email - and also found a workaround to prevent the error: Pass an (undocumented) additional parameter with a member itemType:

    { itemType: "" }

    However the resulting URL does not work. The result is

    In M-Files vNext desktop client: a mostly empty page with the lone message:

    Cannot GET link/FA79DB3A-B747-47BE-BD84-A8E596B7CE04/show?object=3C112D5F-8C73-49CF-8013-C5E1FDE88C38&objid=0-248&version=15
    Continue

    In M-Files vNext web client:

    a) Using the URL in a regular <A href> tag will result replacing the dashboard page with a page with broken image links - see screenshot

    screenshot of M-Files vnext web client showing the error described

    b) Using the URL in a <A href target=_blank> tag will do noting visible, but the browser console will show an error:

    index.html:1 Blocked opening 'localhost/.../show in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.

    c) Calling OpenExternalWebLink with the URL returned by GetWebLink will indeed open a new browser tab but the page will be the same as in case a - broken images

    Screenshot of M-Files web vnext with bad page in new browser tab and and dev tools open

    I made a GitHub repository demonstrating the issue: https://github.com/mlisowsk/UIX2.DashboardLinks

    Here is the line of code that calls GetWebLink (with the workaround): https://github.com/mlisowsk/UIX2.DashboardLinks/blob/1651349ee0bf2f99737ba5a28c44908ddcb2ec56/UIX2.Dashboard/app/dashboard.js#L14

    If someone finds a solution to create an URL that will open an M-Files client window with a given M-Files object in focus that would be very appreciated.

Children
No Data