Page extension 30120 Shpfy Item List

Shopify Connector, Microsoft.Integration.Shopify

src/Apps/W1/Shopify/App/src/Products/Page Extensions/ShpfyItemList.PageExt.al79 lines, Copyright (c) Microsoft Corporation. MIT

// ------------------------------------------------------------------------------------------------// Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the MIT License. See License.txt in the project root for license information.// ------------------------------------------------------------------------------------------------namespace Microsoft.Integration.Shopify;using Microsoft.Inventory.Item;pageextension 30120 "Shpfy Item List" extends "Item List"{    actions    {        addlast(navigation)        {            group(Shopify)            {                Visible = ShopifyEnabled;                action("Show product in Shopify")                {                    ApplicationArea = All;                    ToolTip = 'Opens the product in Shopify.';                    Image = CoupledItem;                    Enabled = IsProductMapped;                    trigger OnAction()                    var                        ShopifyVariant: Record "Shpfy Variant";                        SyncProducts: Codeunit "Shpfy Sync Products";                    begin                        ShopifyVariant.SetRange("Item SystemId", Rec.SystemId);                        if ShopifyVariant.Count = 1 then                            HyperLink(SyncProducts.GetProductUrl(ShopifyVariant))                        else                            SyncProducts.GetProductsOverview(ShopifyVariant);                    end;                }            }        }    }    trigger OnOpenPage()    var        ShopMgt: Codeunit "Shpfy Shop Mgt.";    begin        if GuiAllowed() then            ShopifyEnabled := ShopMgt.IsEnabled();    end;    trigger OnAfterGetCurrRecord()    begin        if GuiAllowed() then            if ShopifyEnabled then                SetIsProductMapped();    end;    var        ShopifyEnabled: Boolean;        IsProductMapped: Boolean;    local procedure SetIsProductMapped()    var        Shop: Record "Shpfy Shop";        ShopifyVariant: Record "Shpfy Variant";    begin        IsProductMapped := false;        ShopifyVariant.SetLoadFields("Item SystemId", "Shop Code");        ShopifyVariant.SetRange("Item SystemId", Rec.SystemId);        if ShopifyVariant.FindSet() then            repeat                if Shop.Get(ShopifyVariant."Shop Code") then                    if Shop.Enabled then begin                        IsProductMapped := true;                        exit;                    end;            until ShopifyVariant.Next() = 0;    end;}