{"title":"FieldRef.Relation() Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/fieldref/fieldref-relation-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/fieldref/fieldref-relation-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/fieldref/fieldref-relation-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":"Finds the table relationship of a given field.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":107,"chars":123},{"level":2,"title":"Parameters","slug":"parameters","at":230,"chars":97},{"level":2,"title":"Return Value","slug":"return-value","at":327,"chars":63},{"level":2,"title":"Remarks","slug":"remarks","at":390,"chars":213},{"level":2,"title":"Example","slug":"example","at":603,"chars":765},{"level":2,"title":"Related information","slug":"related-information","at":1368,"chars":136}],"text":"> Version: _Available or changed with runtime version 1.0._\nFinds the table relationship of a given field.\n## Syntax\n```al\nTableNumber :=   FieldRef.Relation()\n```\n> NOTE\n> This method can be invoked using property access syntax.\n## Parameters\nFieldRef\nType: fieldref-data-type\nAn instance of the fieldref-data-type data type.\n## Return Value\nTableNumber\nType: ../integer/integer-data-type\n## Remarks\nYou can use this method for several purposes such as to determine lookups or to check to see if you have permission to read from a table.\nThis method is similar to the ../record/record-relation-method.\n## Example\nThe following example opens table 37, the Sales Line table, as a RecordRef variable and creates a reference to field 2 \\(Sell-to Customer No.\\). The fieldref-data-type of field 2 is stored in the MyFieldRef variable. The RELATION method retrieves the number of the table that has a relation with the Sell-To-Customer field \\(field 2\\). The table number is stored the varRelation variable and displayed in the message box.\n```al\nvar\n    MyFieldRef: FieldRef;\n    SaleRecref: RecordRef;\n    varRelation: Integer;\n    Text000: Label 'Field 2 in the Sales Line (37) table has a relation with table %1.';\nbegin\n    SaleRecref.Open(37);\n    MyFieldRef := SaleRecref.Field(2);\n    varRelation := MyFieldRef.Relation;\n    Message(Text000, varRelation);\nend;\n```\n## Related information\nfieldref-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}