Hello,
Please see below for action script to create a new issue. I successfully pass over header level information (the only field I have mapped is description, everything else defaults). However, it is not populating my detail rows from the foreach loop. Any reason this might be happening?
This script is placed as an extension to the ProjectEntry class and the table that I’m selecting from is the project inventory w/ lotserial numbers. I have also confirmed that this particular ProjectID has two lines that would be created on a successful action execution.
Any help would be greatly appreciated!
#region Actions
public PXAction<PMProject> createIssue;
[PXUIField(DisplayName = "Create Issue", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXButton]
protected virtual IEnumerable CreateIssue(PXAdapter adapter)
{
INIssueEntry graph = PXGraph.CreateInstance<INIssueEntry>();
INRegister header = new INRegister();
//header.BranchID = Base.ProjectProperties.Current.DefaultBranchID;
//header.DocType = ;
//header.SiteID = ;
//header.TranDate = ;
//header.FinPeriodID = ;
//header.OrigModule = ;
header.TranDesc = Base.ProjectProperties.Current.Description;
if (graph.issue.Insert(header) == null)
{
return adapter.Get();
};
foreach (PXResult<PMLotSerialStatus> res in PXSelect<PMLotSerialStatus, Where<PMLotSerialStatus.projectID, Equal<Current<PMProject.contractID>>, And<PMLotSerialStatus.qtyAvail, NotEqual<decimal0>>>>.Select(graph))
{
PMLotSerialStatus LSS = res;
INTran newline = new INTran();
newline.BranchID = Base.ProjectProperties.Current.DefaultBranchID;
newline.InventoryID = LSS.InventoryID;
newline.SiteID = LSS.SiteID;
newline.LocationID = LSS.LocationID;
newline.ProjectID = LSS.ProjectID;
newline.Qty = LSS.QtyAvail;
newline.LotSerialNbr = LSS.LotSerialNbr;
if (graph.transactions.Insert(newline) == null)
{
return adapter.Get();
};
};
PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.Popup);
return adapter.Get();
}
#endregion