HI,
I develop a custom smart panel for my custom screen. I need to add the purchase order lines data into my screen details section.
The issue is When I select one row and click the ADD button, all the polines related with the same PO number added to the details table.
Below I have added screen shots for your reference.
This is my graph extension code and InsertSelectedLines action is the Add purchase order action.
namespace GRIProformaInvoice.Extension
{
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class APProformaEntry_Extension : PXGraphExtension<APProformaEntry>
{
public SelectFrom<POOrder>.InnerJoin<POLine>.
On<POLine.orderNbr.IsEqual<POOrder.orderNbr>>.View POrdersView;
public PXAction<APProforma> MyAction;
[PXUIField(DisplayName = "Add Purchase", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXButton(CommitChanges = true)]
public virtual IEnumerable myAction(PXAdapter adapter)
{
if (POrdersView.AskExt() == WebDialogResult.OK)
{
return InsertSelectedLines(adapter);
}
return adapter.Get();
}
public virtual IEnumerable InsertSelectedLines(PXAdapter adapter)
{
if (POrdersView != null)
{
int lineNbr = Base.APProformaItems.Select().Count + 1;
foreach (PXResult<POOrder, POLine> result in POrdersView.Select())
{
POOrder order = result;
POLine line = result;
if (order.Selected == false) continue;
{
APProformaItemList toBeInserted = new APProformaItemList();
toBeInserted.Ponbr = “aa”;
toBeInserted.LineNbr = lineNbr++;
toBeInserted.POLineNbr = line.LineNbr;
toBeInserted.POrderQty = 30;
toBeInserted.Itemid = 25;
toBeInserted = Base.APProformaItems.Insert(toBeInserted);
Base.APProformaItems.Update(toBeInserted);
}
}
}
return adapter.Get();
}
}