how do I resolve Row updated and row inserted getting called multiple times which executions logic twice
Please share your code so that people can have a look. Other than RowSelected event which is called multiple times, the rest of the Events are called only one. See the below event model for your reference.
class ClassMaint : PXGraph<ClassMaint, FRClass>
{
public PXSelect<FRClass> Class;
pPXCopyPasteHiddenView()]
public PXSelect<FRClassTeacher,
Where<FRClassTeacher.ClassNbr, Equal<Current<FRClass.ClassNbr>>>> ClassTeachers;
protected void _(Events.RowUpdated<CTRMCollateralFinFacility> e)
{
var row = e.Row; //break point here
//other operations
}
protected void _(Events.RowInserted<CTRMCollateralFinFacility> e)
{
var row = e.Row; //break point here
//other operations
}
}
so I have a form grid with FRClass as the form data member and ClassTeachers as the grid ... when I add a new grid the RowUpdated and RowInserted get triggered twice
The provided context is a mishmash and doesn’t say much. Please provide
CTRMCollateralFinFacility View
CTRMCollateralFinFacility DAC Key fields
CTRMCollateralFinFacility Grid Properties and it’s parent-child relationship definitions.
Also what triggers the events either entering from UI or calling from code like View.insert …
Hi
Hi
I am unsure why it is executing twice, but the below code snippet can handle multiple executions.
class ClassMaint : PXGraph<ClassMaint, FRClass>
{
public PXSelect<FRClass> Class;
public PXSelect<FRClassTeacher,
Where<FRClassTeacher.ClassNbr, Equal<Current<FRClass.ClassNbr>>>> ClassTeachers;
protected bool IsUpdating = false;
protected bool IsInserting = false;
protected void _(Events.RowUpdated<FRClass> e)
{
if (!IsUpdating)
{
IsUpdating = true;
var row = e.Row; // breakpoint here
// Perform your logic for RowUpdated event
IsUpdating = false;
}
}
protected void _(Events.RowInserted<FRClass> e)
{
if (!IsInserting)
{
IsInserting = true;
var row = e.Row; // breakpoint here
// Perform your logic for RowInserted event
IsInserting = false;
}
}
}
IsUpdating
and IsInserting
, are added to track whether the events are already being processed. By using these flags, you can ensure that the logic inside the events is executed only once.
Hope it helps!
Regards,
Sweta
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.