I know there are enough posts about this on here but I’m experiencing an odd issue that I think is easily solvable but I’m just missing something. I’m trying to delete rows from a UD table. Using the settings in the images below, and the code below, when I change the CheckBox01 field to true, then update the table, nothing happens aside from the CheckBox01 field being set to true. However, when I then change the next row to true, and update the table, the previously changed row is deleted and the line I just changed is there and the CheckBox01 is true. I’m not able to just delete the row that I changed, only the previously changed row. I’m guessing it’s because I need to use ttResults in the code itself but admittedly I’m not sure how and I keep getting syntax errors whenever I try. I’m going to keep trying but was hoping someone might be able to easily answer it.
In that BPM since its within the Updatable BAQ remember you need to foreach on ttResults and you should prob mark both ttResults Row and your Db.UD02 row Delete
You might have to make use of
row.SetRowState(IceRowState.Deleted); // MAYBE Depending Sometimes
Also once you do Delete it, the BAQ Might not Refresh itself until you do GetList again.
Just to give you an idea of my skill level, here is my interpretation of your suggestion:
using (var txScope = IceContext.CreateDefaultTransactionScope())
{
foreach(var ttResultsUD02 in (from row in ttResults.Where(
row.Company == Session.CompanyID && row.CheckBox01 == true)
select row))
{
Db.UD02.Delete(ttResultsUD02);
ttResults.Delete(ttResultsUD02);
}
Db.Validate();
txScope.Complete();
}
I’m receiving two syntax errors for using “from row” and “select row”
Also, I’m not sure how to set the RowMod to delete. Sorry for the noob-level question here.
so the ttResults table will hold the column names that you have on your BAQ… I doubt there is a column just name CheckBox01, if you go to the Display Tab it should be something like in my example:
row.TableName_ColumnName, or maybe im wrong.
var query = (from r in ttResults
where
r.CCHdr_Company == companyID
&& r.CCHdr_Plant == plantID
&& r.CCHdr_WarehouseCode == whseID
&& r.CCHdr_CCYear == ccYear
&& r.CCHdr_CCMonth == ccMonth
&& r.Calculated_CDRMandatory == true
&& r.Calculated_EnableCDRCode == true
select r);
foreach (var row in query)
{
row.CCDtl_CDRCode = selectedReasonCode;
}
Is there a reason to not use the BO method widget instead of custom code? I don’t think you can use it for multiple rows, but isn’t it safer to use the BO instead of going direct to the database?
The setting a Custom Action in the BAQ update general properties, creating a base process in the RunCustomAction Method and linking the condition to “Invoke BO Method” did the trick. Much easier. I appreciate all the help.
Also, if you are going through the BO’s and will be utilizing deleteByID on a record, I’ve found that method was not super reliable (at least on 10.1.400) on UD tables. I would consistently get record not found when using deleteByID even with passing in all appropriate keys.
To get record deletion working smoothly I had to mark the row with “D” then call the update method to delete the record.