Iterate Time and Expense Entries

Good morning,
I am working on a customization to the Time and Expense entry form. I would like to add some code to the forms ‘on close’ event. This would look at all the labor transactions for the selected employee/date. If any of the transactions still have status of “Entered”, then pop up a text box to remind the user to submit before closing.

Normally closing the TE form saves “entered” transactions because we have that check box ticked. However, if you open a transaction and “Recall” it, then you can close the form without getting a reminder to save first, thus leaving an unapproved transaction.

So my question is, how do I access the list of transactions loaded for a particular date, then iterate over those transactions to check each one’s status?
Capture

From the trace, I see a method called: Erp.Proxy.BO.LaborImpl.GetRowsCalendarView() Can I access the results of this method call from my on close event?

This is some placeholder code that will need to be updated to include a break out if there are any labor transactions still unapproved.

	private void TimeExpenseForm_Closing(object sender, System.ComponentModel.CancelEventArgs args)
	{
		String myRef ="5b2c4aba-7b90-42e1-a0fe-ef9097392c89";
		EpiUltraCombo statCombo;		
		statCombo = (EpiUltraCombo)csm.GetNativeControlReference(myRef);
		MessageBox.Show("Don't forget to approve this labor transaction!" + statCombo.Text);
	}

*Bump - Anyone have any ideas on iterating through the records for this form?

It turns out that the tree is actually in a DataView called LaborDtlTree.
I used this on button click and was able to get the status for the day I selected.

	private void epiButtonC1_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		var edv = oTrans.Factory("LaborDtlTree");

		for(int i = 0; i < edv.dataView.Count; i++ )
		{
			MessageBox.Show(edv.dataView[i]["TimeStatus"].ToString());
		}
	}

1 Like

This worked like a charm! Thanks! Here is the final code I used in my forms on close event to remind users to approve unapproved transactions:

private void TimeExpenseForm_Closing(object sender, System.ComponentModel.CancelEventArgs args)
	{
	    var edv = oTrans.Factory("LaborDtlTree");
		int flag = 0;

		for(int i = 0; i < edv.dataView.Count; i++)
		{
			if ((edv.dataView[i]["TimeStatus"].ToString()) != "A")
				flag = flag+1;		
		}
		if (flag > 0)
		{
		    string message = "There are " + flag + " labor transactions that are not approved. Are you sure that you would like to close the form without approving them?";
	    	const string caption = "Form Closing";
			var result = MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
		    // If the no button was pressed ...
		    if (result == DialogResult.No)
		    {
		        // cancel the closure of the form.
		        args.Cancel = true;
		    }
		}
	}

1 Like