Hi,
I’m new to acumatica. I have a customized screen. There is a button with an action which opens a pop-up window. In this pop-up window I have loaded data from both POOrder DAC and POLine DAC. To load data , I created a view using SelectFrom attribute .But when I try to add data from the pop-up window to the grid of my customized form, I’m getting below error.
'Unable to cast object of type 'PX.Objects.PO.POOrder' to type 'PX.Data.PXResult`2[PX.Objects.PO.POOrder,PX.Objects.PO.POLine]'.
Can someone help me to solve this issue please?
Thank you.
see the below code for reference.
namespace GRIProformaInvoice.Extension
{
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 && POrdersView.Cache.Cached != null)
{
int lineNbr = Base.APProformaItems.Select().Count + 1;
foreach (PXResult<POOrder, POLine> result in POrdersView.Cache.Cached)
{
POOrder order = result.GetItem<POOrder>();
POLine line = result.GetItem<POLine>();
APProformaItemList toBeInserted = new APProformaItemList();
toBeInserted.Ponbr = "aa";
toBeInserted.LineNbr = lineNbr++;
toBeInserted.POrderQty = 30;
toBeInserted.Itemid = 25;
toBeInserted.Description = line.TranDesc;
toBeInserted = Base.APProformaItems.Insert(toBeInserted);
Base.APProformaItems.Update(toBeInserted);
}
}
return adapter.Get();
}
}
Best answer by oshadarodrigo64
View original