I have added custom fields to the cases screen.
When you select a record type, the Service Type field should be cleared so the user has to select a new value. The Service Type selector is filled with data based on the selected Record Type.
When you select a new value in the Record Type field, the Service Type should be set to null.
Strangely, it works, but ONLY if it is the FIRST time you update the Record Type after bringing up the case.
Any changes in that field other than the first one, the Service type is not being cleared.
I used the RowSelected handler for CRCase to try to null the field.
protected virtual void _(Events.RowSelected<CRCase> e)
{
CRCase row = (CRCase)e.Row;
if (row == null) return;
CRCaseExt itemExt = PXCache<CRCase>.GetExtension<CRCaseExt>(row);
if (itemExt == null) return;
if (itemExt.UsrServiceTypeID != null)
{
SSGCRServTypeRecTypeLinks link = SelectFrom<SSGCRServTypeRecTypeLinks>.Where<SSGCRServTypeRecTypeLinks.serviceTypeID.IsEqual<@P.AsInt>
.And<SSGCRServTypeRecTypeLinks.recordTypeID.IsEqual<@P.AsInt>>>.View.Select(Base, itemExt.UsrServiceTypeID, itemExt.UsrRecordTypeID);
if (link == null) itemExt.UsrServiceTypeID = null;
}
}
If the “link” is null, then the value in the Service Type is not linked to the Record Type and the Service Type field should be nulled.
In debug, I verified that the last time the rowselected fires, the value in itemExt.UsrServiceTypeID is set to null. However, on the screen, I get this:
Fortunately you cannot save the record, but it looks ugly to the user.
The custom code “works” but I’d like to make it not look buggy.
Note, I tried nulling the Service Type field in the FieldUpdated handler for the RecordType field, but it did not do anything.
protected void CRCase_UsrRecordTypeID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
CRCase row = (CRCase)e.Row;
if (row == null) return;
CRCaseExt itemExt = PXCache<CRCase>.GetExtension<CRCaseExt>(row);
if (itemExt == null) return;
itemExt.UsrServiceTypeID = null;
}
Any thoughts?
Best answer by Naveen Boga
View original