Codeunit 30335 Shpfy Metafield Owner Variant
src/Apps/W1/Shopify/App/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerVariant.Codeunit.al54 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;codeunit 30335 "Shpfy Metafield Owner Variant" implements "Shpfy IMetafield Owner Type"{ procedure GetTableId(): Integer begin exit(Database::"Shpfy Variant"); end; procedure RetrieveMetafieldIdsFromShopify(OwnerId: BigInteger) MetafieldIds: Dictionary of [BigInteger, DateTime] var CommunicationMgt: Codeunit "Shpfy Communication Mgt."; JsonHelper: Codeunit "Shpfy Json Helper"; Parameters: Dictionary of [Text, Text]; GraphQLType: Enum "Shpfy GraphQL Type"; JResponse: JsonToken; JMetafields: JsonArray; JNode: JsonObject; JProductVariant: JsonObject; JItem: JsonToken; Id: BigInteger; UpdatedAt: DateTime; begin Parameters.Add('VariantId', Format(OwnerId)); GraphQLType := GraphQLType::Metafields_VariantMetafieldIds; JResponse := CommunicationMgt.ExecuteGraphQL(GraphQLType, Parameters); if JsonHelper.GetJsonObject(JResponse, JProductVariant, 'data.productVariant') then if JsonHelper.GetJsonArray(JResponse, JMetafields, 'data.productVariant.metafields.edges') then foreach JItem in JMetafields do if JsonHelper.GetJsonObject(JItem.AsObject(), JNode, 'node') then begin Id := CommunicationMgt.GetIdOfGId(JsonHelper.GetValueAsText(JNode, 'legacyResourceId')); UpdatedAt := JsonHelper.GetValueAsDateTime(JNode, 'updatedAt'); MetafieldIds.Add(Id, UpdatedAt); end; end; procedure GetShopCode(OwnerId: BigInteger): Code[20] var Variant: Record "Shpfy Variant"; begin Variant.Get(OwnerId); exit(Variant."Shop Code"); end; procedure CanEditMetafields(Shop: Record "Shpfy Shop"): Boolean begin exit((Shop."Sync Item" = Shop."Sync Item"::"To Shopify") and (Shop."Can Update Shopify Products")); end;}