we create a customization button that change line property of all lines on PO then create or update accounting distribution but not working if PO credit line
which method should I call to fix this ?
fix that accounting distribution doesn't update if we click on this button in credit note case
when we click on this button will change line property so what's missing to work all logic of accounting distribution
select forupdate _PurchLine where _PurchLine.PurchId == PurchTable.PurchId; if (_PurchLine) { _PurchLine.ProjLinePropertyId = 'Noncharge'; purchLineType = _PurchLine.type(); _PurchLine.update(); }
The way I see it and without investigating this in the system, is the accounting distribution is following the setup/configuration to determine which main/ledger account to use.
You will have to check the code of the accounting distribution to see how it's choosing the ledger/main accounts.
when line property changing account distribution created , I need to know why account distribution created 3 lines with the same main account
In your code, I see the line property of all order lines being changed to 'Noncharge'. What do you expect to happen? What are the requirements?
public static void main(Args args) { if (args) { PurchTable PurchTable, _PurchTable; PurchLine PurchLine, _PurchLine ,_purchLineOrig; AllowCustomerInvoice AllowCustomerInvoice; FormRun PurchForm = args.caller(); FormDataSource PurchLine_DS; DialogButton diagBut; purchLineType purchLineType; str strMessage = "Are you sure you want to allow customer invoice?"; str strTitle = "Allow Customer Invoice"; diagBut = Box::yesNo(strMessage, DialogButton::Yes, strTitle); if(diagBut == DialogButton::No) { //your own code when user click on No button return; } else if(diagBut == DialogButton::Yes) { //your own code when user click on Yes button select * from PurchTable where PurchTable.RecId == args.record().RecId; while select PurchLine where PurchLine.PurchId == PurchTable.PurchId && PurchLine.PurchStatus != PurchStatus::Invoiced && PurchLine.PurchStatus != PurchStatus::Canceled { ttsbegin; select forupdate AllowCustomerInvoice where AllowCustomerInvoice.PurchLine == PurchLine.RecId; if(AllowCustomerInvoice) { AllowCustomerInvoice.AllowInvoice = NoYes::Yes; AllowCustomerInvoice.update(); } else { AllowCustomerInvoice.PurchLine = PurchLine.RecId; AllowCustomerInvoice.AllowInvoice = NoYes::Yes; AllowCustomerInvoice.insert(); } ttscommit; ttsBegin; if(PurchTable.DocumentState ==VersioningDocumentState::Draft) { while select forupdate _PurchLine where _PurchLine.PurchId == PurchTable.PurchId { _PurchLine.ProjLinePropertyId = 'Noncharge'; purchLineType = _PurchLine.type(); _PurchLine.update(); } } else { select forupdate _PurchTable where _PurchTable.PurchId == PurchTable.PurchId; _PurchTable.DocumentState = VersioningDocumentState::Draft; _PurchTable.doUpdate(); while select forupdate _PurchLine where _PurchLine.PurchId == PurchTable.PurchId { _PurchLine.ProjLinePropertyId = 'Noncharge'; purchLineType = _PurchLine.type(); _PurchLine.update(); _PurchTable.DocumentState = PurchTable.DocumentState; _PurchTable.doUpdate(); } ttsCommit; // } } Info("Done"); } }
By updating the lines to non billable, those lines will not get invoiced. The way I see it and without investigating this in the system, is the accounting distribution is following the setup/configuration to determine which main/ledger account to use. Perhaps if you share more of your code we can help you better.
I change code to while select but still I have the same issue , accounting distribution create 2 lines with the same main account so that's wrong , why update of tables doesn't work well , the main code in these two lines we update this if button of allow customer invoice check we update line property to noncharge if we click on dis allow customer we change line property to line property of category (get the main line of category) and we called update in two cases
The first question: from what I can see from your code, your code selects a single line from the order and only updates the line property of that line only. So it's not updating all lines in the order. To update all lines, you have to use a "while select" statement to select all lines from the order.
As for the rest of your questions, you will have to share the code here so that we can try to see what's wrong.
By the way, I recommend you use different variables for updating the table(s) in question. You are updating the _purchLine table buffer variable passed to your method. This could lead to unwanted behaviour if you are passing a table buffer from a form datasource for example. Also, do not use hard coded values in the code, instead use a parameter table for that.
PurchLine purchLine; while select forUpdate purchLine where purchLine.PurchId == _purchTable.PurchId { //do something here }
André Arnaud de Cal...
292,074
Super User 2025 Season 1
Martin Dráb
230,900
Most Valuable Professional
nmaenpaa
101,156