web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Modify customized field on posted vendor invoice journal

(0) ShareShare
ReportReport
Posted on by 45

Hi guys,

I am using D365FO.

I want to make a customized field editable on the Posted vendor invoice journal.

For this, I am implementing LedgerJournalTable form's datasource Activated event handler.

And I am able to achieve the requirement up to make only one field(customized field) editable and all other non-editable for posted invoice journal records.

But getting below error on modifying,

"Journal has already been posted and, consequently, is not open."

Code for Event handler as below,


[FormDataSourceEventHandler(formDataSourceStr(LedgerJournalTable, LedgerJournalTable), FormDataSourceEventType::Activated)]
public static void LedgerJournalTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
LedgerJournalTable ledgerJournalTable;
DictTable dictTable = new DictTable(ledgerJournalTable.TableId);
int i;
int fieldNumber;
LedgerJournalTable currentLedgerJournalTable = sender.cursor();
FormRun formRun = sender.formRun();
FormDataSource LedgerJournalTable_ds = formRun.dataSource(formDataSourceStr(LedgerJournalTable,LedgerJournalTable));


if(currentLedgerJournalTable.Posted)
{
LedgerJournalTable_ds.allowEdit(true);

for(i = 1;i <= dictTable.fieldCnt();i++)
{
fieldNumber = dictTable.fieldCnt2Id(i);

if(LedgerJournalTable_ds.object(fieldNumber))// && fieldNumber != fieldNum(LedgerJournalTable,COC_Remark1))
{
LedgerJournalTable_ds.object(fieldNumber).allowEdit(false);
}

}

LedgerJournalTable_ds.object(fieldNum(LedgerJournalTable,COC_Remark1)).allowEdit(true);

}
}

I have the same question (0)
  • Martin Dráb Profile Picture
    238,791 Most Valuable Professional on at

    Please don't ask questions about D365FO in the Dynamics AX forum. I moved this thread to Dynamics 365 Finance forum.

    Also, please always use Insert > Insert Code (in the rich-formatting view) to paste source code. It'll become easier to read. I also simplified your code a bit:

    FormDataSourceEventHandler(formDataSourceStr(LedgerJournalTable, LedgerJournalTable), FormDataSourceEventType::Activated)]
    public static void LedgerJournalTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
    {
    	DictTable dictTable = new DictTable(tableNum(LedgerJournalTable));
    	LedgerJournalTable currentLedgerJournalTable = sender.cursor();
    	FormRun formRun = sender.formRun();
    	FormDataSource ledgerJournalTable_ds = formRun.dataSource(formDataSourceStr(LedgerJournalTable, LedgerJournalTable));
    
    	if (currentLedgerJournalTable.Posted)
    	{
    		ledgerJournalTable_ds.allowEdit(true);
    
    		for (int i = 1; i <= dictTable.fieldCnt(); i  )
    		{
    			int fieldNumber = dictTable.fieldCnt2Id(i);
    
    			if (ledgerJournalTable_ds.object(fieldNumber))
    			{
    				ledgerJournalTable_ds.object(fieldNumber).allowEdit(false);
    			}
    		}
    
    		ledgerJournalTable_ds.object(fieldNum(LedgerJournalTable, COC_Remark1)).allowEdit(true);
    	}
    }

    Nevertheless just making the field editable doesn't bypass validations.

    What is the field about? Have you considered putting it to a separate table linked to LedgerJournalTable?

  • WillWU Profile Picture
    22,363 on at

    Hi akkatisuresh,

    You can't edit posted journal, it is only possible to change it in SQL directly or write a job with x++ statements and use the doUpdate() command to bypass the update validation checks.

    As Martin said, please tell us your need and rethink the design.

  • CU24122009-0 Profile Picture
    45 on at

    Thanks, Martin for your reply and simplifying my code.

    I have added on one customized Remark field in LedgerJournalTable table and LedgerJournlTable form.

    The client asked for allowing to modify the Remark field for posted/Unposted vendor invoice journal.

    But due to validation on the table,  I am unable to modify the field value.

    How can I bypass the validation in the case of Remark field validation?

    Thanks in advance.

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    You can try creating a form with pattern dialog. You can refer to LedgerJournalTransDimension as an example. This form will have only the Remarks control.

    On opening the form, you can default this control with the current "Remaks" value on LedgerJournalTrans and on closing the form you can update the field in LedgerJournalTrans table using 'doUpdate' statement to bypass the validation.

  • Martin Dráb Profile Picture
    238,791 Most Valuable Professional on at

    Have you considered putting the field to a separate table linked to LedgerJournalTable? With this approach, you don't have to change (or bypass) validation logic of LedgerJournalTable, because you won't update LedgerJournalTable at all.

  • CU24122009-0 Profile Picture
    45 on at

    Thanks, Martin,

    We will look to redesign the solution for this requirement.

    Ad will try to put the Remark field in any linked table to LedgerJournalTable.

    Thank you very much for your reply.

  • CU24122009-0 Profile Picture
    45 on at

    Thanks Gunjan for your reply,

    I have asked for this alternate solution to the client.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 521 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 438

#3
Adis Profile Picture

Adis 261 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans