Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Vendor Invoice Journal...
Finance forum

Vendor Invoice Journal (Creation Via X++)-Is non Editable in Form on front end

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello Everyone

I am trying to create vendor invoice journal through code as shown in the below.The journal is created as shown the second screenshot but it is opening in non editable mode on the front end .Kindly provide your valuable suggestions.

4403.Capture_5F00_1.PNG

Code:-

class OA
{
	public static void main (Args _args)
	{
		OATPChargesPost OATPChargesPost;
		FormDataSource tpCharges_DS;
		OATPCharges tpCharges, tpChargesIns, tpChargesRow;
		Dialog dialog;
		LedgerJournalCheckPost jourCheckPost;
		LedgerJournalTable jourTable;
		LedgerJournalTrans jourTrans;
		container offsetDim;
		DimensionAttributeValueConsolidation davc, davcOffset;
		MarkupTable markupTable;
		MCRLedgerJournal journalTable;
		LedgerJournalTable ledgerJournalTable;
		Counter recordsInserted = 0;
		MarkupTrans markupTrans;

		OATPChargesPost = OATPChargesPost::construct();

		if(_args.record().TableId == tableNum(OATPCharges))
		{
			tpCharges = _args.record();
			tpCharges_DS = tpCharges.dataSource();

			dialog = new Dialog("@OA:OA1");
			dialog.addText("@OA:OA2");

			if (dialog.run())
			{
				if (tpCharges_DS.anyMarked())
				{
					tpChargesRow = tpCharges_DS.getFirst( 1, false);

					ttsBegin;

					journalTable = new MCRLedgerJournal_VendInvoiceRegister(LedgerJournalType::VendInvoiceRegister, "APInvoice");
					ledgerJournalTable = journalTable.createLedgerJournalTable("APInvoice");

					journalTable.parmLedgerJournalTable(ledgerJournalTable);
					journalTable.parmMCRCCGeneralLedgerId();
					journalTable.parmLedgerAccountType(LedgerJournalACType::Vend);
					journalTable.parmAccountNum(tpChargesRow.OATPVendAccount);
					journalTable.parmLedgerOffsetAccountType(LedgerJournalACType::Ledger);
					journalTable.parmLineNum(recordsInserted + 1);
					journalTable.parmApprover(HcmWorker::findByPersonnelNumber("000001").RecId);
					journalTable.parmExchRate(100);
					journalTable.parmCurrencyCode('USD');
					journalTable.parmTransTxt("Test");

					markuptable = MarkupTable::find(tpChargesRow.ModuleType, tpChargesRow.MarkupCode);

					journalTable.parmledgerOffsetAccount(markupTable.VendorLedgerDimension);
					journalTable.parmTransDate(DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone()));
					journalTable.parmPostingProfile("Gen");
					journalTable.parmPaymTermId("Net30");
					journalTable.parmPaymMode("Check");
					journalTable.parmDueDate(mkDate(12,12,2018));

					while (tpChargesRow)
					{
						jourTrans = journalTable.createLedgerJournalTrans(tpChargesRow.Value,0,LedgerJournalACType::Vend);

						if(jourTrans)
						{
							ttsbegin;
							jourTrans.selectForUpdate(true);
							jourTrans.OAMarkupTrans = tpChargesRow.MarkupTrans;
							jourTrans.update();
							ttscommit;
							recordsInserted++;
						}

						tpChargesRow = tpCharges_DS.getNext();
					}
					ttsCommit;
				}
			}
		}
	}

	public static OATPChargesPost construct()
	{
		OATPChargesPost OATPChargesPost;
		OATPChargesPost = new OATPChargesPost();
		return OATPChargesPost;
	}

}
  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Vendor Invoice Journal (Creation Via X++)-Is non Editable in Form on front end

    Thank you for your valuable suggestion.

    When we create journal through MCRLedgerJournal_VendInvoiceRegister class as shown in above code the Approver field is set to current worker by default on ledgerJournalTable.

    Whereas when we create the journal manually the Approver field is set to blank.Therefore setting the Approver field to blank using x++ code helped me to open form in editable mode.

  • Suggested answer
    Sukrut Parab Profile Picture
    Sukrut Parab 71,671 Moderator on at
    RE: D365F&O-Vendor Invoice Journal (Creation Via X++)-Is non Editable in Form on front end

    If the journal is editable when you create it manually then you can compare that Journal with your journal created via code and see what is missing . Also use <> button from rich formatting to paste your code.

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: D365F&O-Vendor Invoice Journal (Creation Via X++)-Is non Editable in Form on front end

    I suggest you create a similar journal in the user interface, and compare in table browser / SQL Server what is different in the data that you create in x++. Assuming it works differently when creating from x++ vs UI.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,759 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,468 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans