Hi again!
I have an UBAQ that lists some sales order (release) data (from UD02) for the user. There is a checkbox (using a custom action) that allows the user to create a new release with the information in the record.
This works well when the line exists within the order. But when I need to make a new line, I can’t figure out how to update the new release that gets automatically created. I can create the line, and create a new release on that line (which becomes the second release) and I can update that second release. But it leaves the first empty release in there on the line. I started another thread to try to delete a release, with this end in mind. How to Delete a Release Using a Custom Action.
I’d like to complete this all in one custom action. As a result things look a bit messy. I have tried looping from the newly created line back to the release update path, but it didn’t update the first release. I tried recreating the release update path separately just for new line releases. No luck. I did try to update the new line release though custom code, but I am afraid I am not that familiar with the syntax.
I will try to post the image and the code I have so far. Please let me know if there is anything else you need, or that I didn’t explain.
Thanks for your time!
Nate
Custom Code Elements:
Pull In Data: (This pulls data from ttResults, including new release data from UD02. We just populate some internal variables to use in methods later.)
IsNewLine=false;
var ttResults_xRow = (from ttResults_Row in ttResults where ttResults_Row.Calculated_NewRelease == true select ttResults_Row).FirstOrDefault();
if (ttResults_xRow != null)
{
totalrows = ttResults.Count / 2; //not sure why this is divided by 2, but it works...
if (myrow <= totalrows)
{
MyOrder = ttResults_xRow.OrderHed2_OrderNum;
if (String.IsNullOrEmpty(Convert.ToString(ttResults_xRow.OrderDtl1_OrderLine)))
{
MyLine = 0;
}
else
{
MyLine = ttResults_xRow.OrderDtl1_OrderLine;
}
MyQty = ttResults_xRow.UD02_Number01;
MyDate = ttResults_xRow.UD02_Date01;
MyPart = ttResults_xRow.UD02_ShortChar01;
MyFalse = false;
MyuomCode = "";
MyID = ttResults_xRow.SysRowID;
ttResults_xRow.Calculated_NewRelease = false;
}
}
Set My Line: (This is just to figure out what the newly create line number is.)
var OrderDtl = (from row in Db.OrderDtl where row.Company == Session.CompanyID && row.OrderNum == MyOrder orderby row.OrderLine descending select row).FirstOrDefault();
{
MyLine = OrderDtl.OrderLine;
}
IsNewLine=true;
Delete First Rel: (This just closes the first release on a newly created line. It should delete it instead.)
if (IsNewLine == true)
{
using (Erp.Contracts.SalesOrderSvcContract soSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
{
soSvc.CloseRelease(MyOrder, MyLine, 1);
soSvc.Update(ref MyVar);
}
}