Codeunit 18122350 EOS JSON Import Helper

Codeunit 18122350 EOS JSON Import Helper

Methods

GetAvailableImportHandlers

procedure GetAvailableImportHandlers(var Buffer: Record "Name/Value Buffer")

Creates and returns a list of all available import handlers on the current tenant.

Parameters / Return Value

  • Buffer Record "Name/Value Buffer"

    A temporary buffer that will contain a list of all registered import handlers.


ImportJson

procedure ImportJson(ImportId: Guid)

Imports a .zip file containing one or more JSON files for importing data to a specific app. The user must provide a ZIP-file to be imported that is then uploaded to the server.

Parameters / Return Value

  • ImportId Guid

    The GUID of the app for which the imported data is intended.


ImportJson

procedure ImportJson(ImportId: Guid; Force: Boolean)

Parameters / Return Value

  • ImportId Guid

  • Force Boolean


ImportJson

procedure ImportJson(ImportId: Guid; zipStream: InStream; force: Boolean; var TmpImportBuffer: Record "EOS JSON Import Buffer")

Imports a .zip file containing one or more JSON files for importing data to a specific app.

Parameters / Return Value

  • ImportId Guid

    The GUID of the app for which the imported data is intended.

  • zipStream InStream

    A stream containing a .zip that is imported.

  • force Boolean

    if true will delete all record with same key

  • TmpImportBuffer Record "EOS JSON Import Buffer"

    A temporary buffer that will contain a copy of all the import entries that have been created. Please note that this is just a copy. The effective import entries are immediately saved to the database.


ImportJson

procedure ImportJson(ImportId: Guid; zipStream: InStream; var TmpImportBuffer: Record "EOS JSON Import Buffer")

Imports a .zip file containing one or more JSON files for importing data to a specific app.

Parameters / Return Value

  • ImportId Guid

    The GUID of the app for which the imported data is intended.

  • zipStream InStream

    A stream containing a .zip that is imported.

  • TmpImportBuffer Record "EOS JSON Import Buffer"

    A temporary buffer that will contain a copy of all the import entries that have been created. Please note that this is just a copy. The effective import entries are immediately saved to the database.


RunImportAll

procedure RunImportAll(var Buffer: Record "EOS JSON Import Buffer")

Starts the import operation for the given import entries. All records in the provided set will be processed.

Parameters / Return Value

  • Buffer Record "EOS JSON Import Buffer"

    A set of records of import entries to be processed. Every record in this dataset will be processed.


ImportExists

procedure ImportExists(importId: Guid): Boolean

Indicates whether at least one import entry exists for a given app.

Parameters / Return Value

  • importId Guid

    The GUID of the app to check for.

  • Returns Boolean

    true if at least one import entry exists, false otherwise.


StartProgress

procedure StartProgress(Buffer: Record "EOS JSON Import Buffer")

Initializes a generic progress window for a single import entry, providing table name, record count and a percentage bar.

Parameters / Return Value

  • Buffer Record "EOS JSON Import Buffer"

    The import entry for which to open the progress window.


StartProgress

procedure StartProgress(EntryNo: Integer)

Initializes a generic progress window for a single import entry, providing table name, record count and a percentage bar.

Parameters / Return Value

  • EntryNo Integer

    The import entry for which to open the progress window.


StopProgress

procedure StopProgress()

Closes an open progress window that has been created via StartProgress.


ReadNext

procedure ReadNext(): Boolean

Reads the next record from the JSON dataset currently loaded in memory and moves the current record pointer to it.

Parameters / Return Value

  • Returns Boolean

    true if a record has been read, false if there are no more records to be read.


SetRecordNo

procedure SetRecordNo(NewRecordNo: Integer): Boolean

Sets the record pointer to a specific record.

Parameters / Return Value

  • NewRecordNo Integer

    The index of the record.

  • Returns Boolean

    true if the pointer has successfully changed. false if no record with this index exists.


FillTable

procedure FillTable(var RecRef: RecordRef)

Fills a given RecRef with all values in the record to which the current record pointer points.

Parameters / Return Value

  • RecRef RecordRef

    The target RecRef on which to set values.


FillTable

procedure FillTable(var RecRef: RecordRef; var ErrorMsgBuffer: Record "Error Message" temporary; ThrowOnFirstError: Boolean)

Fills a given RecRef with all values in the record to which the current record pointer points.

Parameters / Return Value

  • RecRef RecordRef

    The target RecRef on which to set values.

  • ErrorMsgBuffer Record "Error Message"

    A temporary error message buffer that will receive any errors that happen during the operation.

  • ThrowOnFirstError Boolean

    Specifies whether the first error causes the entire operation to fail. If you set this to false, no errors will be generated and it is up to you to handle any errors generated during the operation.


GetFieldValueAsText

procedure GetFieldValueAsText(fieldNo: Integer): Text

Returns the value of a given field ID on the current record as Text.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • Returns Text

    The value. If the field does not exist, an empty string is returned.


GetFieldValueAsDecimal

procedure GetFieldValueAsDecimal(fieldNo: Integer; defValue: Decimal): Decimal

Returns the value of a given field ID on the current record as Decimal.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • defValue Decimal

    A default value that is used, should the field not exist or if the conversion fails.

  • Returns Decimal

    The value. If the conversion fails, the provided default is returned.


GetFieldValueAsDecimal

procedure GetFieldValueAsDecimal(fieldNo: Integer): Decimal

Returns the value of a given field ID on the current record as Decimal.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • Returns Decimal

    The value. If the conversion fails, a runtime error occurs.


GetFieldValueasRecordID

procedure GetFieldValueasRecordID(var fld: FieldRef)

Reads the value of a given field ID on the current record as RecordId.

Parameters / Return Value

  • fld FieldRef

    The field where to read the value into.


GetFieldValueasRecordID

procedure GetFieldValueasRecordID(fieldNo: Integer; var recID: RecordId)

Returns the value of a given field ID on the current record as RecordID

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read

  • recID RecordId

    The return value


GetFieldValueAsInteger

procedure GetFieldValueAsInteger(fieldNo: Integer): Integer

Returns the value of a given field ID on the current record as Integer.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • Returns Integer

    The value. If the conversion fails, the provided default is returned.


GetFieldValueAsInteger

procedure GetFieldValueAsInteger(fieldNo: Integer; defValue: Integer): Integer

Returns the value of a given field ID on the current record as Integer.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • defValue Integer

    A default value that is used, should the field not exist or if the conversion fails.

  • Returns Integer

    The value. If the conversion fails, the provided default is returned.


GetFieldValueAsBigInteger

procedure GetFieldValueAsBigInteger(fieldNo: Integer; defValue: BigInteger): BigInteger

Returns the value of a given field ID on the current record as BigInteger.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • defValue BigInteger

    A default value that is used, should the field not exist or if the conversion fails.

  • Returns BigInteger

    The value. If the conversion fails, the provided default is returned.


GetFieldValueAsBigInteger

procedure GetFieldValueAsBigInteger(fieldNo: Integer): BigInteger

Returns the value of a given field ID on the current record as BigInteger.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • Returns BigInteger

    The value. If the conversion fails, the provided default is returned.


GetFieldValueAsDateFormula

procedure GetFieldValueAsDateFormula(var fld: FieldRef)

Reads the value of a given field ID on the current record as DateFormula.

Parameters / Return Value

  • fld FieldRef

    The field where to read the value into.


GetFieldValueAsDateFormula

procedure GetFieldValueAsDateFormula(fieldNo: Integer; var Formula: DateFormula)

Reads the value of a given field ID on the current record as DateFormula.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • Formula DateFormula

    The value.


GetFieldValueAsGuid

procedure GetFieldValueAsGuid(fieldNo: Integer; defValue: Guid): Guid

Returns the value of a given field ID on the current record as Guid.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • defValue Guid

    A default value that is used, should the field not exist or if the conversion fails.

  • Returns Guid

    The value. If the conversion fails, the provided default is returned.


GetFieldValueAsGuid

procedure GetFieldValueAsGuid(fieldNo: Integer): Guid

Returns the value of a given field ID on the current record as Guid.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • Returns Guid

    The value. If the conversion fails, the provided default is returned.


GetFieldValueAsBoolean

procedure GetFieldValueAsBoolean(fieldNo: Integer; defValue: Boolean): Boolean

Returns the value of a given field ID on the current record as Boolean.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • defValue Boolean

    A default value that is used, should the field not exist or if the conversion fails.

  • Returns Boolean

    The value. If the conversion fails, the provided default is returned.


GetFieldValueAsBoolean

procedure GetFieldValueAsBoolean(fieldNo: Integer): Boolean

Returns the value of a given field ID on the current record as Boolean.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • Returns Boolean

    The value. If the conversion fails, the provided default is returned.


GetFieldValueAsDate

procedure GetFieldValueAsDate(fieldNo: Integer; defValue: Date): Date

Returns the value of a given field ID on the current record as Date.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • defValue Date

    A default value that is used, should the field not exist or if the conversion fails.

  • Returns Date

    The value. If the conversion fails, the provided default is returned.


GetFieldValueAsDate

procedure GetFieldValueAsDate(fieldNo: Integer): Date

Returns the value of a given field ID on the current record as Date.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • Returns Date

    The value. If the conversion fails, the provided default is returned.


GetFieldValueAsDateTime

procedure GetFieldValueAsDateTime(fieldNo: Integer; defValue: DateTime): DateTime

Returns the value of a given field ID on the current record as DateTime.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • defValue DateTime

    A default value that is used, should the field not exist or if the conversion fails.

  • Returns DateTime

    The value. If the conversion fails, the provided default is returned.


GetFieldValueAsDateTime

procedure GetFieldValueAsDateTime(fieldNo: Integer): DateTime

Returns the value of a given field ID on the current record as DateTime.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • Returns DateTime

    The value. If the conversion fails, the provided default is returned.


GetFieldValueAsTime

procedure GetFieldValueAsTime(fieldNo: Integer; defValue: Time): Time

Returns the value of a given field ID on the current record as Time.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • defValue Time

    A default value that is used, should the field not exist or if the conversion fails.

  • Returns Time

    The value. If the conversion fails, the provided default is returned.


GetFieldValueAsTime

procedure GetFieldValueAsTime(fieldNo: Integer): Time

Returns the value of a given field ID on the current record as Time.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • Returns Time

    The value. If the conversion fails, the provided default is returned.


GetFieldValueAsBlob

procedure GetFieldValueAsBlob(fieldNo: Integer; var TempBlob: Codeunit "Temp Blob")

Returns the value of a given field ID on the current record as a Blob.

Parameters / Return Value

  • fieldNo Integer

    The ID of the field to read.

  • TempBlob Codeunit "Temp Blob"

    An instance of TempBlob that will contain the BLOB data.


InsertData

procedure InsertData(RecRef: RecordRef; Overwrite: Boolean; runtrigger: Boolean)

Perform an insert into a recordRef

Parameters / Return Value

  • RecRef RecordRef

    The recordRef that need to perform insert

  • Overwrite Boolean

    if true, existing record (same key) will be overwritten. Only modified fields

  • runtrigger Boolean

    If true will run the trigger


FieldExist

procedure FieldExist(fieldNo: Integer): Boolean

Returns true or false according to the existence of a certain field ID in the current record

Parameters / Return Value

  • fieldNo Integer

    The filed ID that needs to be checked

  • Returns Boolean

    Exists or not (true, false)


AddValue

procedure AddValue(var RecRef: RecordRef; oldID: Integer; newID: Integer)

Assign the value to a record ref, given the new field ID and Old Field ID

Parameters / Return Value

  • RecRef RecordRef

    The recordref to which assign the value

  • oldID Integer

    Old Field ID where get the value

  • newID Integer

    The new destination field ID


AddValueIf

procedure AddValueIf(condition: Boolean; var RecRef: RecordRef; oldID: Integer; newID: Integer) ConditionResult: Boolean

Same as AddValue but insert data only if the condition is true

Parameters / Return Value

  • condition Boolean

    the condition, if true will insert data

  • RecRef RecordRef

    The recordref to which assign the value

  • oldID Integer

    Old Field ID where get the value

  • newID Integer

    The new destination field ID

  • Returns Boolean


Events

OnRunImport

local procedure OnRunImport(Buffer: Record "EOS JSON Import Buffer"; var Success: Boolean; var ErrorMessage: Text)

Subscribe to this event to execute all necessary import operations for a given import entry. Obviously: you should only react to this event, if the app ID of the entry matches your app ID. The subscriber should never, in any case, raise any runtime errors. Always use IF Codeunit.RUN() THEN or a TryFunction. If you want to comunicate a failure or error, use the two parameters Success and ErrorMessage.

Parameters / Return Value

  • Buffer Record "EOS JSON Import Buffer"

    The import entry to be processed. Do not attempt to modify this.

  • Success Boolean

    Set this to true to signal that the operation was successful. Set this to false to indicate that some kind of error occurred.

  • ErrorMessage Text

    If Success is set to false, you should provide a meaningful error message to the end user using this parameter.


OnDiscoverImportHandlers

local procedure OnDiscoverImportHandlers(var Buffer: Record "Name/Value Buffer")

Use this event to register your app as an available import handler.

Parameters / Return Value

  • Buffer Record "Name/Value Buffer"

    A key/value buffer. Your app should only created one single entry with the ID of your app as Key and anything you like as Value. It is, however, a good idea to use your app’s name as Value.



EOS Labs -