Monday, 24 August 2026

How to Add a Custom JumpRef through Event Handler in D365 F&O Using X++

In Dynamics 365 Finance & Operations, a JumpRef allows users to navigate directly from a field to the related record. This is especially useful when a field contains an ID that references a record on another form.

For example, I have an Agreement ID field on the Sales Table form, and I want users to click the field and navigate directly to the corresponding Sales Agreement.

The following JumpRef event handler can be used:

[FormControlEventHandler(formControlStr(SalesTable, SalesTable_AgreementId), 
FormControlEventType::JumpRef)]
public static void SalesTable_AgreementId_OnJumpRef(FormControl sender, FormControlEventArgs e) { // Cancel the default jumpRef behavior FormControlCancelableSuperEventArgs cancelArgs = e as FormControlCancelableSuperEventArgs; if (cancelArgs != null) { cancelArgs.CancelSuperCall(); } FormRun formRun = sender.formRun() as FormRun; FormDataSource salesTableDS = formRun.dataSource(formDataSourceStr(SalesTable, SalesTable)); SalesTable salesTable = salesTableDS.cursor() as SalesTable; if (salesTable != null && salesTable.AgreementId) { SalesAgreementHeader salesAgreementHeader; // Find the Sales Agreement across all companies select firstonly crossCompany salesAgreementHeader where salesAgreementHeader.SalesNumberSequence == salesTable.AgreementId; if (salesAgreementHeader.RecId != 0) { Args args = new Args(); args.name(formStr(SalesAgreement)); // Open the record in its correct company changecompany(salesAgreementHeader.dataAreaId) { SalesAgreementHeader correctRecord; select firstonly correctRecord where correctRecord.RecId == salesAgreementHeader.RecId; args.record(correctRecord); } FormRun salesAgreementForm = classfactory.formRunClass(args); salesAgreementForm.init(); salesAgreementForm.run(); salesAgreementForm.detach(); salesAgreementForm.wait(); } else { warning(strFmt( "Sales Agreement '%1' not found in any company.", salesTable.AgreementId)); } } }

How It Works

  • Cancel default JumpRef and implement custom navigation.
  • Get the current SalesTable record and Agreement ID.
  • Use crossCompany to find the related Sales Agreement.
  • Use changecompany() to open the record in its correct legal entity.
  • Pass the record through Args and open the Sales Agreement form.
  • Show a warning if the agreement is not found.

No comments:

Post a Comment

How to Add a Custom JumpRef through Event Handler in D365 F&O Using X++

In Dynamics 365 Finance & Operations, a JumpRef allows users to navigate directly from a field to the related record. This is especiall...