Context Menu Passing Values to form


(Matt Spotts) #1

Hello,

I have added a new context menu item to the job right click menu. I use it to open Move Mtl Request. Problem is that it doesn’t automatically enter the job number into the job number field. This is probably because it would want the employee number which when not in MES needs to be entered. I am using the MES and I am wondering is there a way within the process that is called to customize that screen to handle that value?

Thanks
Matt


(Jose C Gomez) #2

Sure thing, the valuein in the LFO will contain the job number, the Employee ID you can get from the Session or the CallContextClient.


(Matt Spotts) #3

This is my code. when I test the code it says it compiled successfully. When I actually launch it I get an error the object reference is not set to the instance of the object. I have the code in the form load event.

object jn = MoveMtlRequestForm.LaunchFormOptions.ContextValue.ToString(); MessageBox.Show(jn.ToString());

(Matt Spotts) #4

Maybe I am doing something wrong. I added the context menu item under customization. I am in mes looking at the production grid view. I right click the job number I am clocked into and then try to open with the new context menu item. The issue is that the context value appears to be null. Is there something more I need to do to get the value to the context value?


(Matt Spotts) #5

Found it using the object explorer. I used valuein in place of ContextValue and it worked. Thanks for the help Jose.


(Chris Conn) #6

A few suggestions.

First make sure that your sender is in fact setting a ContextValue in the LFO it is passing.

Second, do a null check to avoid errors. Also, no need to cast the LFO to object if youre expecting a string

string jn = "LFO or ContextValue is null";
if(MoveMtlRequestForm.LaunchFormOptions != null && MoveMtlRequestForm.LaunchFormOptions.ContextValue != null)
jn = MoveMtlRequestForm.LaunchFormOptions.ContextValue.ToString();

 MessageBox.Show(jn);

(Matt Spotts) #7

I have the if statement in there now. It was ValueIn instead of ContextValue. I was almost certain it was ContextValue tho but my memory is hazy from a few years ago when I did this last.


(Matt Spotts) #8

Ok so now I am stuck again. I remember doing this but can’t seem to find my code samples. I have the string now I want to load the dataview with the job number I just got so the record loads. I swore it was an Epicor data view call but I can’t seem to find what I am looking for in object explorer. I have the Job number and now in the Move material request I need to pull up the job. any suggestions?


(Chris Conn) #9

Probably something like:

var TheEDV = oTrans.Factory("The Correct Edv Name Here");
TheEDV.dataView[TheEDV.Row].JobNum = jn;

(Matt Spotts) #10

I tried the .JobNum = jn. I was playing around and tried this and it worked. Thanks for pointing me in the right direction.
EpiDataView reqedv = (EpiDataView)(oTrans.EpiDataViews[“MoveRequest”]);
reqedv.dataView[reqedv.Row][“JobNum”] = jobnumbertext;