gpt-3.5-turbo-0613· OpenAI WildChat-4.8M (AI2)
x++ patch financial dimension to journal voucher
- User
x++ patch financial dimension to journal voucher
- Assistant
The x++ code below demonstrates how to patch the financial dimension to a journal voucher in Dynamics 365 Finance and Operations:
// Get the Journal Voucher record JournalVoucher journalVoucher; select firstOnly journalVoucher where journalVoucher.JournalNum == "<journal_voucher_number>"; // Get the Financial dimension record DimensionFinancialTag dimensionFinancialTag; select firstOnly dimensionFinancialTag where dimensionFinancialTag.FinancialTag == "<financial_dimension_value>"; // Create a new Journal Voucher Ledger Dimension record JournalVoucherLedgerDimension journalVoucherLedgerDimension; journalVoucherLedgerDimension.initValue(); journalVoucherLedgerDimension.JournalNum = journalVoucher.JournalNum; journalVoucherLedgerDimension.Voucher = journalVoucher.Voucher; journalVoucherLedgerDimension.AmountCurCredit = journalVoucher.AmountCurCredit; journalVoucherLedgerDimension.AmountCurDebit = journalVoucher.AmountCurDebit; // Set the Financial dimension journalVoucherLedgerDimension.LedgerDimension = dimensionFinancialTag.DefaultDimension; // Update the record journalVoucherLedgerDimension.update();Replace
<journal_voucher_number>with the specific journal voucher number to patch, and<financial_dimension_value>with the desired financial dimension value. This code retrieves the journal voucher and financial dimension records, then creates a new JournalVoucherLedgerDimension record with the desired dimension. Finally, it updates the record to patch the financial dimension to the journal voucher.