UD table oTrans.GetByID

Hello,

I’m trying to do Key field upon tab out pull the record into the screen but i’m having -1 row index when i do Refresh button or call oTrans.Refresh().
any suggestion would be helpful.

Actually, better advice: just use a different textbox for the input. Epicor is doing something strange with respect to stepping through the key fields to make sure data is entered in each.

This is working for me:
image

Edit: I’m not actually capturing the Enter KeyCode with Keydown, but you can get the same effect by changing your global option to send the Enter command as Tab here:
image

While we’re at it, we may as well tie your event to a databound key field rather than a control.

Thanks Joseph for the reply. I have changed the textfield to a custom one however i’m still getting the same error. This happens when I tab out of the field then hit refresh. I’m not sure what i’m doing different. then your code


Do you have a record already stored as test blank blank blank blank or are there other key assignments in key2-key5?

Joseph Moeller

I dont think you want an oTrans.Refresh() here. I think you want a oTrans.NotifyAll()

Sorry for the delay, I came to concluded the code above worked with any UD that does not have a Child tabel (i.e UD100A). For example, when I insert the code in UD19 and the refresh worked but when I use it on UD100 it didn’t work. I’m not sure what i’m missing with table that has child table…

After further investigation, the source of the problem is that the oTrans.GetByID method is bugged for UD100-110 business objects. Notably, it does not load the parent object into the navigation list view, which is evident in the navigation pane at the top of the screen. You can work around this bug using the following code:

   if(!String.IsNullOrEmpty(key1))
   {
		SearchOptions opts = new SearchOptions(SearchMode.AutoSearch)
        {
            DataSetMode = DataSetMode.RowsDataSet,
            PreLoadSearchFilter = String.Format("Key1 = '{0}' AND Key2 = '{1}' AND Key3 = '{2}' AND Key4 = '{3}' AND Key5 = '{4}'", key1,key2,key3,key4,key5),
            SelectMode = SelectMode.SingleSelect
        };
		oTrans.InvokeSearch(opts);
    }

Once the navigation view is properly loading using the above workaround, you’ll no longer receive the -1 row error during refresh events.

I hope this helps!
-Joseph

4 Likes

I am having same issue as reported by @snguyen and tried your workaround code. Still receiving “Index 0 is either negative or above rows count” error. Any thought

if ((UD110Form.LaunchFormOptions.ContextValue != null))
{
string Value = Convert.ToString(UD110Form.LaunchFormOptions.ContextValue);
oTrans.GetByID(Value,"","","","");
oTrans.NotifyAll();
if(!String.IsNullOrEmpty(Value))
{
SearchOptions opts = new SearchOptions(SearchMode.AutoSearch)
{
DataSetMode = DataSetMode.RowsDataSet,
PreLoadSearchFilter = String.Format(“Key1 = ‘{0}’ AND Key2 = ‘{1}’ AND Key3 = ‘{2}’ AND Key4 = ‘{3}’ AND Key5 = ‘{4}’”, Value,"","","",""),
SelectMode = SelectMode.SingleSelect
};
oTrans.InvokeSearch(opts);
}

		}

Hello, @shantocthomas.
First, remove this line: oTrans.GetByID(Value,"","","",""); because it serves the same purpose as your last line. If that doesn’t fix the problem when you save, close, and reopen, try adding this to the onload method of a not-yet-customized version of the form to determine if the error comes from this or another part of your code.

1 Like

Thanks Joseph! I was tearing my hair out with this issue this morning. Great solution!

Thanks @josephmoeller Its Worked well.