I have two UDF’s in the CRCase table. Those UDF’s are derived from fields in a custom maintenance table. The UDFs are ServiceTypeCD and RecordTypeCD and they come from the custom maintenance table.
When a user tries to delete a record from the maintenance table, I want to make sure that the record isn’t in use in the CRCase table (no references in CRCase to the record in the custom table).
This is the event I am using to trap this.
This is a BQL select statement that I would use if I was just pulling data from the CRCase table if I was not looking for a UDF in that table. Just to make sure it compiles, I put CRCase.caseCD in the Where clause (twice). These *should* be the UDF fields. I don’t know how to reference the UDF’s in a BQL select for a standard Acumatica table.
Any advice would be greatly appreciated.
protected void _(Events.RowDeleting<SSGCRServiceTypes> e)
{
SSGCRServiceTypes row = (SSGCRServiceTypes)e.Row;
if (row == null) return;
CRCase finditem = SelectFrom<CRCase>.
Where<CRCase.caseCD.IsEqual<@P.AsString>.
And<CRCase.caseCD.IsEqual<@P.AsString>>>.
View.Select(this, row.RecordTypeCD, row.ServiceTypeCD).TopFirst;
if (finditem != null && MasterView.Current != null && MasterView.Cache.GetStatus(MasterView.Current) != PXEntryStatus.Deleted)
{
e.Cancel = true;
throw new PXException(Helper.Messages.ServiceSupportInUse);
}
}