Skip to main content
Solved

Add Inserted event handler to Data Maps screen

  • February 20, 2025
  • 2 replies
  • 38 views

I'm working on a custom script to automatically update the external ID and description of an employee after the record is inserted into the Data Maps table for Type "Employees."

I created a simple Inserted event to test the trigger, but I'm encountering an error.

using System;
using PX.Objects;
using PX.Data;

namespace MYOB.AdvancedLive.People.Objects.PP
{
  public class MPTimesheetDataMapMaint_Extension : PXGraphExtension<MYOB.AdvancedLive.People.Objects.PP.MPTimesheetDataMapMaint>
  {
        protected void DataMap_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            PXTrace.WriteInformation("DataMap_RowInsertedevent triggered.");
            var datamap = e.Row;
            if (datamap == null)
                return;

     
        }
  }
}

 

Best answer by davidnavasardyan

Modify the event handler to use Events.RowInserted<T> with a proper DAC reference. Here's the corrected version:

using System;
using PX.Data;

namespace MYOB.AdvancedLive.People.Objects.PP
{
    public class MPTimesheetDataMapMaint_Extension : PXGraphExtension<MYOB.AdvancedLive.People.Objects.PP.MPTimesheetDataMapMaint>
    {
        protected virtual void _(Events.RowInserted<DataMap> e)
        {
            PXTrace.WriteInformation("DataMap_RowInserted event triggered.");

            if (e.Row is DataMap datamap)
            {
                // Add your logic to update External ID and Description here
            }
        }
    }
}

 

View original
Did this topic help you find an answer to your question?

2 replies

davidnavasardyan
Jr Varsity I
Forum|alt.badge.img+2

Modify the event handler to use Events.RowInserted<T> with a proper DAC reference. Here's the corrected version:

using System;
using PX.Data;

namespace MYOB.AdvancedLive.People.Objects.PP
{
    public class MPTimesheetDataMapMaint_Extension : PXGraphExtension<MYOB.AdvancedLive.People.Objects.PP.MPTimesheetDataMapMaint>
    {
        protected virtual void _(Events.RowInserted<DataMap> e)
        {
            PXTrace.WriteInformation("DataMap_RowInserted event triggered.");

            if (e.Row is DataMap datamap)
            {
                // Add your logic to update External ID and Description here
            }
        }
    }
}

 


  • Author
  • Freshman II
  • 1 reply
  • February 22, 2025

Hi David,

Thanks for your suggestion, mate. I updated the script based on your comment, and it's working with a slight change: the DAC reference. Instead of DataMap, it’s using MBDataMap.

Also, could I ask how we determine the correct syntax for methods (like RowInserted in this case)? I'm currently using the protected void DataMap_RowInserted(PXCache sender, PXRowInsertedEventArgs e) method for the Employee screen, and it seems to work fine.

I appreciate your response, thanks!

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings