how do I resolve Row updated and row inserted getting called multiple times which executions logic twice
Answer
Row updated and row inserted gets called twice
Best answer by sweta68
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
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
