Button Click - Stamp Date & User

Good morning Epicor Community,

I have been asked to replicate the “Date/User” stamp in the header comments of the RMA Processing form (RMA Processings > Details > Comments > RMA). It is requesting to be added in the Job Entry form (Scheduling Comments tab).

When this button is clicked, it stamps the current date and user ID into the comments field at the end of the text.

I’ve researched to see if anyone has done something similar, but I’m still trying to understand how I could achieve this (BPM or C#).

Has anyone had any luck doing something like this?

Are you talking about the comment box under Job Details>Operations>Comments>scheduling comments?

That’s the one!

I am not an expert here, maybe another person will chime in.

But what I am doing in the code below (or at least what I believe I am doing… might be incorrect) is grabbing the current data row for the job operation data view (which is whatever data row you currently have displayed on the UI as I understand it…) and then I am using a button click event to insert the current user ID and the time in that field. I know RMA processing button brings in the person’s full name, but that would take a little extra code and I didn’t do that.

First image shows creating the button

Then create the click event.

image

Then navigate to script editor and insert a reference to using Ice.Core; at the top. This will allow you to pull current session userID as I understand it.

// **************************************************
// Custom code for JobEntryForm
// Created: 6/23/2021 11:53:13 AM
// **************************************************

extern alias Erp_Contracts_BO_Project;
extern alias Erp_Contracts_BO_Part;

using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
> using Ice.Core;

Then under your click event you can put the following code to insert the datestamp and user ID:

private void btndatestamp_Click(object sender, System.EventArgs args)
{
	// ** Place Event Handling Code Here **


	/*If the comment is blank don't add a new line before the stamp, otherwise add a new line.*/	
	
	
	EpiDataView edvJobOper = ((EpiDataView)(this.oTrans.EpiDataViews["JobOper"]));
	System.Data.DataRow row = edvJobOper.CurrentDataRow;
	if(row["SchedComment"].ToString() == "")
	{
		row.BeginEdit();
		row["SchedComment"] = ((Session)oTrans.Session).UserID + " " + DateTime.Today + ":";
		row.EndEdit();
	}
	else  
	{
		row.BeginEdit();
		row["SchedComment"] =  row["SchedComment"] + Environment.NewLine + ((Session)oTrans.Session).UserID + " " + DateTime.Today + ":";
		row.EndEdit();
	}
	

	
	
}
4 Likes

I edited that a couple times after post, see latest revision.

This was perfect!
Thanks for all your help Utah!