Advanced Technical Example : How to extend or replace links supplied to Shop Floor Insight

Skip to main content

Advanced Technical Example : How to extend or replace links supplied to Shop Floor Insight

You are here:

This is an advanced technical article intended for developers who are tasked with replacing or extending links functionality in Shop Floor Insight’s barcode scanning interface. This is not a standard configuration article. This example is for an AL developer creating a Business Central extension.

Shop Floor Insight’s barcode scanning interface retrieves document links through the Business Central web service named TCMLinks, normally published against codeunit 23044205 “SFI Links”.

To customize this behavior, publish your own codeunit under the same service name. Your codeunit can call the existing Shop Floor Insight methods and then append additional links. This approach keeps the existing scanning interface unchanged.  After replacing the web service in Business Central you must restart the Shop Floor Insight windows service.

Methods to preserve

Implement these public methods with the exact names and parameter signatures shown in the example:

Method Purpose
GetProdOrderLinksODATA Service-enabled entry point for production order links.
GetJobLinksODATA Service-enabled entry point for project/job task links.
GetFixedAssetLinksODATA Service-enabled entry point for fixed asset work. Preserve the parameter name pcodProdOrderNo.
GetProdOrderLinks Builds production order link output using a BigText parameter.
GetJobLinks Builds project/job task link output using a BigText parameter.
GetFixedAssetLinks Builds fixed asset link output using a BigText parameter.
performFileToHTTPMapping Applies the existing file-path-to-HTTP mapping behavior.

Keep the three ODATA methods first in the codeunit, matching the arrangement in the standard code.

Example replacement codeunit

Use an object ID from your extension’s assigned range. Add a dependency on Shop Floor Insight and grant the connecting Business Central identity permission to execute your codeunit and read any additional data.

codeunit 50100 "Custom SFI Links"
{
    [ServiceEnabled]
    procedure GetProdOrderLinksODATA(
        pcodProdOrderNo: Code[20];
        pcodProdItemNo: Code[20]) pstrOutput: Text
    var
        LinkOutput: BigText;
    begin
        GetProdOrderLinks(
            pcodProdOrderNo, pcodProdItemNo, LinkOutput);
        LinkOutput.GetSubText(pstrOutput, 1);
    end;

    [ServiceEnabled]
    procedure GetJobLinksODATA(
        pcodJobNo: Code[20];
        pcodJobTaskNo: Code[20]) pstrOutput: Text
    var
        LinkOutput: BigText;
    begin
        GetJobLinks(pcodJobNo, pcodJobTaskNo, LinkOutput);
        LinkOutput.GetSubText(pstrOutput, 1);
    end;

    [ServiceEnabled]
    procedure GetFixedAssetLinksODATA(
        pcodProdOrderNo: Code[20]) pstrOutput: Text
    var
        LinkOutput: BigText;
    begin
        GetFixedAssetLinks(pcodProdOrderNo, LinkOutput);
        LinkOutput.GetSubText(pstrOutput, 1);
    end;

    procedure GetProdOrderLinks(
        pcodProdOrderNo: Code[20];
        pcodProdItemNo: Code[20];
        var pstrOutput: BigText)
    begin
        StandardLinks.GetProdOrderLinks(
            pcodProdOrderNo, pcodProdItemNo, pstrOutput);

        // TODO: Resolve additional records and append their links.
        // Example:
        // AppendLink(pstrOutput, 'Order drawing',
        //     'https://example.com/drawing.pdf');
    end;

    procedure GetJobLinks(
        pcodJobNo: Code[20];
        pcodJobTaskNo: Code[20];
        var pstrOutput: BigText)
    begin
        StandardLinks.GetJobLinks(
            pcodJobNo, pcodJobTaskNo, pstrOutput);

        // TODO: Append additional project/job task links.
    end;

    procedure GetFixedAssetLinks(
        pcodProdOrderNo: Code[20];
        var pstrOutput: BigText)
    begin
        StandardLinks.GetFixedAssetLinks(
            pcodProdOrderNo, pstrOutput);

        // TODO: Append additional links for this work.
    end;

    procedure performFileToHTTPMapping(
        ptxtFileURI: Text) rtxtHTTPLink: Text
    begin
        exit(StandardLinks.performFileToHTTPMapping(ptxtFileURI));
    end;

    local procedure AppendLink(
        var LinkOutput: BigText;
        Description: Text;
        URL: Text)
    begin
        if LinkOutput.Length() > 0 then
            LinkOutput.AddText('||');

        LinkOutput.AddText(
            Description + '||' + performFileToHTTPMapping(URL));
    end;

    var
        StandardLinks: Codeunit "SFI Links";
}

Calling StandardLinks invokes the installed codeunit directly. Changing the published web service does not redirect those AL calls back to your replacement.

The standard production method returns links from the released production order header and the item card. The project/job method returns links from the specified job task. To replace their results completely, remove the corresponding StandardLinks call and build the output yourself.

Add your own links

The scanning interface expects alternating descriptions and URLs separated by ||:

Description 1||URL 1||Description 2||URL 2

Use AppendLink for each additional link. Do not include || within a description or URL because the client uses it as the separator. Return an empty result when there are no links.

For sales order documents, your custom logic must determine which sales order and lines belong to the selected production order. An item number alone does not identify the originating sales order.

Replace the published web service

  1. Install the extension containing your replacement codeunit.
  2. Open Web Services in the relevant Business Central company.
  3. Locate the Codeunit service named TCMLinks, normally pointing to object 23044205.
  4. Replace that publication with one pointing to your custom codeunit. If necessary, unpublish and delete the original web service entry, then create the replacement entry.

The resulting entry should be:

Field Value
Object Type Codeunit
Object ID Your custom codeunit ID, such as 50100
Service Name TCMLinks
Published Yes

Keep TCMLinks exactly as the service name. The standard scanning interface already calls this name and the three ODATA methods; no JavaScript change is required.

Restart the Shop Floor Insight Windows service and refresh the scanning interface before testing. Verify that standard links still appear and that your additional links open correctly. Test project/job and fixed asset work too if those features are used.

To restore the standard functionality, publish TCMLinks against codeunit 23044205 “SFI Links” again.

Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
Need help?

Leave A Comment

Table of Contents
Go to Top