{"title":"RecordRef.Init() Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/recordref/recordref-init-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/recordref/recordref-init-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/recordref/recordref-init-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Initializes a record in a table.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":93,"chars":38},{"level":2,"title":"Parameters","slug":"parameters","at":131,"chars":100},{"level":2,"title":"Remarks","slug":"remarks","at":231,"chars":1208},{"level":2,"title":"Example","slug":"example","at":1439,"chars":1165},{"level":2,"title":"Related information","slug":"related-information","at":2604,"chars":137}],"text":"> Version: _Available or changed with runtime version 1.0._\nInitializes a record in a table.\n## Syntax\n```al\n RecordRef.Init()\n```\n## Parameters\nRecordRef\nType: recordref-data-type\nAn instance of the recordref-data-type data type.\n## Remarks\nThis method assigns default values to each field in the record, including the SystemId field. The values that are assigned in the record correspond to those defined when the table was created. If no value was assigned when the table was created, the values are assigned based on the data type, as shown in the following table.\nData type|Default value\nBigInteger|0\nBigText|\\<Empty>\nBLOB|\\<Empty>\nBoolean|No\nCode|'' \\(empty string\\)\nDate|0d \\(Undefined date\\)\nDateFormula|'' \\(empty string\\)\nDateTime|0DT \\(Undefined datetime\\)\nDecimal|0.0\nDuration|0\nGUID|00000000-0000-0000-0000-000000000000\nInteger|0\nOption|0\nRecordID|\\<Empty>\nTableFilter|\\<Empty>\nText|'' \\(empty string\\)\nTime|0T \\(Undefined time\\)\n> NOTE\n> Primary key and timestamp fields are not initialized.\nAfter the method runs, you can change the values in any or all of the fields before you call the recordref-insert--method to enter the record in the table. Be sure that the fields that make up the primary key contain values that make the total primary key unique. If the primary key is not unique (such as the record already exists), then the record is rejected.\nThe method works in the same way as the ../record/record-init-method.\n## Example\nThe following example opens a table 18 (Customer) with a RecordRef variable that is named CustomerRecref. The recordref-field-method creates a FieldRef variable that is named MyFieldRef for the field. The Init method initializes the values in the fields by using default values and then uses the recordref-insert--method to insert a new record. The new record is 1120. This is the primary key for the new record.\n> NOTE\n> In this example, the Init method is called before the primary key is assigned a value. The Init method does not initialize primary key fields. Therefore calling the Init method before or after you assign values to the primary key field does not make any difference.\n```al\nvar\n    CustomerRecref: RecordRef;\n    MyFieldRef: FieldRef;\n    Text000: Label 'The value of the field before initialization is %1.';\n    Text001: Label 'The value of the field after you insert the record is %1.';\nbegin\n    CustomerRecref.Open(18);\n    MyFieldRef := CustomerRecref.Field(1);\n    CustomerRecref.Init;\n    Message(‘%1’, MyFieldRef.Value);\n    MyFieldRef.Value := '1120';\n    CustomerRecref.Insert;\n    Message(‘%1’, MyFieldRef.Value);\nend;\n```\n## Related information\nrecordref-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}