Job Deletion Tracking

I’ve been tasked with tracking when jobs are deleted. I’m assuming I can accomplish this by a BPM of some sort that writes the information to a UD table. Then from there we can track the deleted jobs by doing a BAQ on that UD Table…

Does anyone have any resources or old threads of someone asking a similar question? I looked around for a while but couldn’t find anything that will help me.

I’d basically want the following info to write to a UD table -
Job Num that was deleted, userid of who deleted the job, date/time of deletion.

If anyone can help with this, I’d greatly appreciate it.

A slightly different method compared to what you’re going for, but I have a method directive on the Pre-Processing section of the JobEntry.Update that sends me emails containing job information when they’re deleted. I just set the condition to go off when “there is at least one deleted row in the ttjobhead table” and “The jobhead.jobfirm of all rows is true” (this way you don’t have to worry about any MRP/non-firm jobs being deleted). What you’re probably going to want to do from here is have an ABL action (I believe it might be a C# action in E10?) to create a new UD~ table and fill in whatever information from the ttJobHead table you are looking for. In abl there are some key words you can use like dcd-userid to get the id of the user who enacted this method directive, I’m assuming there’s a similar method in C# as well.

Do you have any examples of some code? I can’t seem to get the correct syntax for the Execute Custom Code part… I just need to write the JobNum, ChangeDate, and currentUserID to the UD fields Key1,Key2, and Key3.

What I have so far (off of Google) -

For each ttJobHead where ttJobHead.RowMod = 'D';

    If available ttJobHead Then

    Assign ttJobHead.JobNum = UD13.Key1;
    Assign ttJobHead.ChangeDate = UD13.Key2;
    Assign DCD-USERID = UD13.Key3;
    End;

I got some of these off of someone that was doing something similar but they were using an older version of Epicor and I feel like the syntax is incorrect in E10…

I think the problem with that code is that you’re not creating a new UD13 table record to write this information to. I’ll try to mess around with the concept myself to see if I can figure it out, but this discussion might be worth looking into to work off what they have going on.

http://erp.ittoolbox.com/groups/technical-functional/epicor-l/abl-to-create-and-update-rows-in-user-defined-tables-from-maintenance-window-4285966

This should help you. Granted there are better methods. Using the Adapter or REST.

        UD05Impl ud05BO = WCFServiceSupport.CreateImpl<UD05Impl>(FormFunctions.getILaunchSession(oTrans), UD05Impl.UriPath);
        UD05DataSet tempSet = new UD05DataSet();
        ud05BO.GetaNewUD05(tempSet);

        tempSet.Tables[0].Rows[0]["Key2"] = currentECR["Key1"].ToString();

        tempSet.Tables[0].Rows[0]["ShortChar02"] = userName;
        tempSet.Tables[0].Rows[0]["ShortChar03"] = userEmail;
        tempSet.Tables[0].Rows[0]["ShortChar05"] = DateTime.Now;
        tempSet.Tables[0].Rows[0]["ShortChar06"] = dept;
        tempSet.Tables[0].Rows[0]["ShortChar07"] = currentECR["ShortChar05"].ToString();
        tempSet.Tables[0].Rows[0]["ShortChar08"] = currentECR["ShortChar06"].ToString();
        tempSet.Tables[0].Rows[0]["ShortChar09"] = type;

        tempSet.Tables[0].Rows[0]["Character01"] = message;
        tempSet.Tables[0].Rows[0]["Character02"] = currentECR["Character01"].ToString();
        tempSet.Tables[0].Rows[0]["Character03"] = currentECR["Character02"].ToString();
        tempSet.Tables[0].Rows[0]["Character04"] = subject;
        tempSet.Tables[0].Rows[0]["Character05"] = optional;

        tempSet.Tables[0].Rows[0]["Date01"] = DateTime.Now;
        tempSet.Tables[0].Rows[0]["Date02"] = currentECR["Date02"];

        ud05BO.Update(tempSet);

Could you explain this a little bit?

sure.

You are looking to create custom code to add a record to a UD table when someone deletes a JobHead record.

I will try and use your example instead of mine.
You will need to make sure there is a reference for your UD table added to the code. This code should be a good start you will need to update the UD table based on which one you are going to use. My example is UD05.

//start your loop
foreach (var ttJobHeadrow in ttJobHead.Where(ttJobHead_Row=>ttJobHead_Row.Deleted()))
    {
		//Setting up variables you will need to add a record to the DB
		UD05Impl ud05BO = WCFServiceSupport.CreateImpl<UD05Impl>(FormFunctions.getILaunchSession(oTrans), UD05Impl.UriPath);
		UD05DataSet tempSet = new UD05DataSet();

		//Get new UD Record and set it to the tempSet
		ud05BO.GetaNewUD05(tempSet);
		
		//fill in your tempSet with the data you want
		tempSet.Tables[0].Rows[0]["Key1"]  = ttJobHeadrow.JobNum;
		tempSet.Tables[0].Rows[0]["Key2"]  = ttJobHeadrow.ChangeDate;
		tempSet.Tables[0].Rows[0]["Key3"]  = callContextClient.CurrentUserId;

		//Update the database with your new record
		ud05BO.Update(tempSet);
 	}
1 Like

If you run MRP, you may want to exclude those jobs otherwise you might get many, many records that you really don’t want to log.

Mark W.

Here’s my code:

//References
Erp.Tables.ShipHead ShipHead;
Ice.Tables.UD13 UD13;


foreach (var ttJobHeadrow in ttJobHead.Where(ttJobHead_Row=>ttJobHead_Row.Deleted()))
    {
		//Setting up variables you will need to add a record to the DB
		UD13Impl ud13BO = WCFServiceSupport.CreateImpl<UD13Impl>(FormFunctions.getILaunchSession(oTrans), UD13Impl.UriPath);
		UD13DataSet tempSet = new UD13DataSet();

		//Get new UD Record and set it to the tempSet
		ud13BO.GetaNewUD13(tempSet);
		
		//fill in your tempSet with the data you want
		tempSet.Tables[0].Rows[0]["Key1"]  = ttJobHeadrow.JobNum;
		tempSet.Tables[0].Rows[0]["Key2"]  = ttJobHeadrow.ChangeDate;
		tempSet.Tables[0].Rows[0]["Key3"]  = callContextClient.CurrentUserId;

		//Update the database with your new record
		ud13BO.Update(tempSet);
 	}

Here are the errors:

Details:  
Error CS0246: The type or namespace name 'UD13Impl' could not be found (are you missing a using directive or an assembly reference?) [Update.Pre.JobDeletionTrack.cs(136,3)]
Error CS0103: The name 'WCFServiceSupport' does not exist in the current context [Update.Pre.JobDeletionTrack.cs(136,21)]
Error CS0246: The type or namespace name 'UD13Impl' could not be found (are you missing a using directive or an assembly reference?) [Update.Pre.JobDeletionTrack.cs(136,50)]
Error CS0103: The name 'FormFunctions' does not exist in the current context [Update.Pre.JobDeletionTrack.cs(136,60)]
Error CS0103: The name 'oTrans' does not exist in the current context [Update.Pre.JobDeletionTrack.cs(136,92)]
Error CS0103: The name 'UD13Impl' does not exist in the current context [Update.Pre.JobDeletionTrack.cs(136,101)]
Error CS0246: The type or namespace name 'UD13DataSet' could not be found (are you missing a using directive or an assembly reference?) [Update.Pre.JobDeletionTrack.cs(137,3)]
Error CS0246: The type or namespace name 'UD13DataSet' could not be found (are you missing a using directive or an assembly reference?) [Update.Pre.JobDeletionTrack.cs(137,29)]
Error CS1061: 'Erp.Tablesets.JobHeadRow' does not contain a definition for 'ChangeDate' and no extension method 'ChangeDate' accepting a first argument of type 'Erp.Tablesets.JobHeadRow' could be found (are you missing a using directive or an assembly reference?) [Update.Pre.JobDeletionTrack.cs(144,53)]

Here are my references too:

Do I need to add more references or something?

Nevermind all of this. I got it working without using the Custom Code.

For future purposes check this thread out -

1 Like

great

@knash Sorry if I wasted any of your time. I’ll save the snippets of code that you wrote up for future purposes though.

Thank you.

All good.

not a waste of time. Glad you have something that is working!!!