Hi,
When SalesOrder header changed to canceled order, lines should be disabled.
I added coding in SalesTable active method like this:
if(salesTable.SalesStatus ==SalesStatus::Canceled)
{
SalesLine_ds.allowCreate(false);
SalesLine_ds.allowDelete(false);
SalesLine_ds.allowEdit(false);
SalesLine_ds.refresh();
}
But when i try this for old canceled orders, its allowing me to create,edit or delete the lines.
What should I do now?
thanks
I tried the same coding in Salesline active method…
You need to write it on the saleLine.active() method and you don’t need refresh as well.
SalesLine_ds.allowCreate(salesTable.SalesStatus !=SalesStatus::Canceled);
Have you checked if there is any other standard code that is enabling the create/delete/edit?
There will be standard code that enables the create/delete/edit on the sales order lines, you need to align your code with the standard code so that none of the standard conditions will be violated.
int active()
{
int ret;
boolean returnItem = salesTable.returnItem();
;
ret = super();
buttonLineSetup. enabled(true);
buttonHeaderFunction. enabled(!returnItem);
buttonHeaderTradeAgreements. enabled(!returnItem);
buttonLineFunction. enabled(!returnItem && salesTable.RecId);
buttonLineInquiry. enabled(!returnItem);
buttonLinePriceCalc. enabled(!returnItem);
configuration. enabled(!returnItem);
buttonLineExplosion. enabled(true);
bomConsistOfTree. enabled(true);
buttonLineProduction. enabled(true);
buttonAttachedSalesLines. enabled(salesTable.type().canHaveAttachedOrders());
inventTransPick. enabled(true);
wmsOrderAllowCreate. enabled(true);
salesLine_ds.object(fieldnum(SalesLine, SalesUnit)).allowEdit(salesLine.SalesQty == salesLine.RemainSalesPhysical);
salesLine_ds.object(fieldnum(SalesLine, SalesDeliverNow)).allowEdit(salesLine.DeliveryType != TradeLineDlvType::DropShip);
element.setCaptionText();
if (salesLine.RecId)
{
element.setEditItemAllowed(false);
}
else
{
element.setEditItemAllowed(true);
}
salesLine_ds.allowCreate(element.createLineAllowed());
salesLine_ds.allowEdit (salesTableForm.editLineAllowed());
salesLine_ds.allowDelete(salesTableForm.deleteLineAllowed(salesLine));
element.checkCreditNoteLine();
element.updateDesign(InventDimFormDesignUpdate::Active);
element.updateRFIDTagging();
if (headerError)
{
salesTable.Touched = NoYes::Yes;
headerError = false;
}
// PBA begin
element.pbAsetEnabled();
// PBA end
buttonLineInterCompany.enabled(salesTableForm.interCompanyShowButtonLine());
salesTableForm.interCompanySetLineAccess(salesLine,address,lineAddress);
if (salesLine.ProjId)
{
lineInquiry_CostControlCommittedCost.enabled(true);
}
else
{
lineInquiry_CostControlCommittedCost.enabled(false);
}
allowSetFocusOnItemId = true;
// Start modified
//Brahma 28/02/2012
if(SalesLine_SalesDeliverNow1.valueStr())
{
COC_Standalone2.visible(true);
COC_Standalone2.setFocus();
SalesLine_SalesDeliverNow1.setFocus();
}
else
{
COC_Standalone2.visible(false);
}
// Ended
//added by sri
if(salesTable.SalesStatus ==SalesStatus::Canceled)
{
SalesLine_ds.allowCreate(false);
SalesLine_ds.allowDelete(false);
SalesLine_ds.allowEdit(false);
SalesLine_ds.refresh();
}
//end by sri
return ret;
}
This is the active method of salesline…
Other than this there is no method to call create/delete/edit, Kranthi
You already have the below standard code and you are overwriting them by a simple check on sales status.
salesLine_ds.allowCreate(element.createLineAllowed());
salesLine_ds.allowEdit (salesTableForm.editLineAllowed());
salesLine_ds.allowDelete(salesTableForm.deleteLineAllowed(salesLine));
Change the above code to,
salesLine_ds.allowCreate(element.createLineAllowed() && SalesTable.SalesStatus != SalesStatus::Canceled);
And don’t call the SalesLine_ds.refresh();
Like this shall I do for edit and delete?
kranthi
January 22, 2018, 8:11am
10
Yes you can.
Or you may modify the actual method itself, Example - salesTableForm.editLineAllowed(). But it will impact all the areas where the method is used.
salesLine_ds.allowCreate(element.createLineAllowed() && SalesTable.SalesStatus != SalesStatus::Canceled);
salesLine_ds.allowEdit (salesTableForm.editLineAllowed()&& SalesTable.SalesStatus != SalesStatus::Canceled);
salesLine_ds.allowDelete(salesTableForm.deleteLineAllowed(salesLine)&& SalesTable.SalesStatus != SalesStatus::Canceled);
Is this fine, Kranthi?
It’ll not affect the standard right?