Codeunit 18122350 EOS JSON Import Helper
Obsolete
Pending: This codeunit is no longer supported. (22.0)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
GuidThe GUID of the app for which the imported data is intended.
ImportJson
procedure ImportJson(ImportId: Guid; Force: Boolean)
Parameters / Return Value
ImportId
GuidForce
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
GuidThe GUID of the app for which the imported data is intended.
zipStream
InStreamA stream containing a
.zipthat is imported.force
Booleanif 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
GuidThe GUID of the app for which the imported data is intended.
zipStream
InStreamA stream containing a
.zipthat 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
GuidThe GUID of the app to check for.
Returns
Booleantrueif at least one import entry exists,falseotherwise.
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
IntegerThe 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
Booleantrueif a record has been read,falseif 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
IntegerThe index of the record.
Returns
Booleantrueif the pointer has successfully changed.falseif 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
RecordRefThe 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
RecordRefThe 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
BooleanSpecifies 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
IntegerThe 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
IntegerThe ID of the field to read.
defValue
DecimalA default value that is used, should the field not exist or if the conversion fails.
Returns
DecimalThe 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
IntegerThe ID of the field to read.
Returns
DecimalThe 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
FieldRefThe 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
IntegerThe ID of the field to read
recID
RecordIdThe 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
IntegerThe ID of the field to read.
Returns
IntegerThe 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
IntegerThe ID of the field to read.
defValue
IntegerA default value that is used, should the field not exist or if the conversion fails.
Returns
IntegerThe 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
IntegerThe ID of the field to read.
defValue
BigIntegerA default value that is used, should the field not exist or if the conversion fails.
Returns
BigIntegerThe 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
IntegerThe ID of the field to read.
Returns
BigIntegerThe 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
FieldRefThe 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
IntegerThe ID of the field to read.
Formula
DateFormulaThe 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
IntegerThe ID of the field to read.
defValue
GuidA default value that is used, should the field not exist or if the conversion fails.
Returns
GuidThe 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
IntegerThe ID of the field to read.
Returns
GuidThe 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
IntegerThe ID of the field to read.
defValue
BooleanA default value that is used, should the field not exist or if the conversion fails.
Returns
BooleanThe 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
IntegerThe ID of the field to read.
Returns
BooleanThe 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
IntegerThe ID of the field to read.
defValue
DateA default value that is used, should the field not exist or if the conversion fails.
Returns
DateThe 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
IntegerThe ID of the field to read.
Returns
DateThe 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
IntegerThe ID of the field to read.
defValue
DateTimeA default value that is used, should the field not exist or if the conversion fails.
Returns
DateTimeThe 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
IntegerThe ID of the field to read.
Returns
DateTimeThe 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
IntegerThe ID of the field to read.
defValue
TimeA default value that is used, should the field not exist or if the conversion fails.
Returns
TimeThe 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
IntegerThe ID of the field to read.
Returns
TimeThe 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
IntegerThe ID of the field to read.
TempBlob
Codeunit "Temp Blob"An instance of
TempBlobthat will contain the BLOB data.
InsertData
procedure InsertData(RecRef: RecordRef; Overwrite: Boolean; runtrigger: Boolean)
Perform an insert into a recordRef
Parameters / Return Value
RecRef
RecordRefThe recordRef that need to perform insert
Overwrite
Booleanif true, existing record (same key) will be overwritten. Only modified fields
runtrigger
BooleanIf 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
IntegerThe filed ID that needs to be checked
Returns
BooleanExists 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
RecordRefThe recordref to which assign the value
oldID
IntegerOld Field ID where get the value
newID
IntegerThe 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
Booleanthe condition, if true will insert data
RecRef
RecordRefThe recordref to which assign the value
oldID
IntegerOld Field ID where get the value
newID
IntegerThe 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
BooleanSet this to
trueto signal that the operation was successful. Set this tofalseto indicate that some kind of error occurred.ErrorMessage
Text[]If
Successis set tofalse, 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
Keyand anything you like asValue. It is, however, a good idea to use your app’s name asValue.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.