{"title":"RecordRef.Insert() Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/recordref/recordref-insert--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-insert--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-insert--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":"Inserts a record into a table without executing the code in the OnInsert trigger.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":142,"chars":49},{"level":2,"title":"Parameters","slug":"parameters","at":191,"chars":100},{"level":2,"title":"Return Value","slug":"return-value","at":291,"chars":238},{"level":2,"title":"Remarks","slug":"remarks","at":529,"chars":937},{"level":2,"title":"Example","slug":"example","at":1466,"chars":1062},{"level":2,"title":"Related information","slug":"related-information","at":2528,"chars":137}],"text":"> Version: _Available or changed with runtime version 1.0._\nInserts a record into a table without executing the code in the OnInsert trigger.\n## Syntax\n```al\n[Ok := ]  RecordRef.Insert()\n```\n## Parameters\nRecordRef\nType: recordref-data-type\nAn instance of the recordref-data-type data type.\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\ntrue if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.\n## Remarks\nRecords are uniquely identified by the values in primary key fields. The Database Management System \\(DBMS\\) checks the primary key for the table before it inserts a new record.\nIf the table contains an auto-increment field, the auto-increment feature is used if the record contains a zero value in that field. The auto-increment feature enters the new value into the field as part of the insert.\nIf the auto-increment field contains a non-zero value, that value is inserted into the table and the auto-increment feature is not used. If the value in the auto-increment field is greater than the last auto-increment value in the table, the next auto-increment value that is entered into the table will be greater than the value in the field that you just inserted. If the value in the auto-increment field already exists in the table, a run-time error occurs.\nThis method works the same as the ../record/record-insert--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 recordref-init-method initializes the values in the fields by using default values and then the Insert method inserts 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 recordref-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 after you insert the record is %1.';\nbegin\n    CustomerRecref.Open(18);\n    MyFieldRef := CustomerRecref.Field(1);\n    CustomerRecref.Init();\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>"}