Identify the Calling Object?

Hello All. Can anyone tell me if there is a way to identify what objects calls another object? Example… I have multiple forms that on_open call another form(runmodal). In the second form can I identify which object activated the runmodal? Nav 3.10b Native. Thanks, Owen

I don’t know if there is anyway of doing what you require directly but here is a workaround I have used. Create a global variable CallingForm on the form you are calling. Create a function SetCallingForm that has one parameter ‘CallingFormName’. All SetCallingForm does is write the value of the parameter to the Global variable. Before you call Form.RunModal, call Form.SetCallingForm(‘FormName’). You can then reference the variable to see which was the calling form. The only downside is you have to modify every object that calls the form [:(]

Thanks Gary, I was hoping to avoid having to do this type of manipulation. It just seems messy. I’ve used this approach before to flag boolean values. It also means I’ve got to retro-fit all my preexisting forms. It works but it isn’t pretty.[:X] I wish we could simply override runmodal to be a polymorphic function which would pass the calling object id. Maybe in Version 5.0?[:p] Best Rgds, Owen

… but what about forms called via lookup-/drilldownfunctionality?

Oops, forgot to mention that here. The forms I am using do not know anything about each other, no association with lookup/drilldown id etc. If you were refering to my hint on polymorphism then it wouldn’t change the functionality of lookup-/drilldown. Otherwise, I am not sure what you mean sv?

Code Coverage knows which form opens the new form, but I don’t think you can get a the information without actually running it from the Tools Menu [|)]…Just an observation. Sometimes you don’t have to retrofit all of your forms. If you only want different results based on a small number of calling forms, check the passed parameter for those and if there is nothing in the parameter (no retrofitting), then run with the default processing. You will only have to change the smaller number of forms (sometimes only one).

My point was simply that forms can be invoked from a lot of different places (not only via run or runmodal) but also under a lot of different circumstances. I certainly agree that it would be very nice to be able to identify the calling object (type and -id) within an object, but this info in itself would not always be enough. Example: Form20 “General Ledger Entries” can be activated in at least 7 different ways from Form16 “Chart of Accounts” (6 flowfields & Ctrl+F5).

I think the only thing you can do is create a parameter table and before activating a form insert a record with the formid and the parameter. The form can read the parameter then.

Hi, On the situations where you implemented these kind of workarounds, was it just not possible to use different Forms (based on the same Table) according to the intended usage?

Thanks everyone for the advice. Sv, for my purposes the control Id would be needed, only the High lvl object id (form). So if I could overide it would be nice. Erik, thanks for the idea hadn’t thought about this. I wonder if a temp table could be used? I would guess no because of the two different forms a server call to read the table would be required. Nelson, the form that needs to know the object ID is a security form. Its a secure login for management personnel. It allows management to overide different various functions that I could not lock out with the security model (i.e. – profit overide, zero cost sales, promotions, etc…). It records the log-in Id for document archive. For different conditions we have various management passwords stored in a different table. Depending on what form called my security form I need to know which password to look up. (Didn’t want to burn multiple forms for a log-in prompt). Best Rgds: Owen

OK, I understand. It would be frustrating to create lots of forms for something so simple. Thanks for making it clearer, best regards,

Hi Owen, I would suggest to use a codeunit with property SingleInstance = Yes. From source form before you call the next form set in the codeunit a global variable to say which is the source form no and then in the opened form you read the global variable and you have your answer. It might not be the cleanest way but I used it before and it is not bad … Regards, Cristi Nicola

Since we all (reluctantly) must agree that it can’t be done without modifying the calling object(s), I would follow Gary’s initial advise. IMHO this is by far the most simple, cheap and easy solution. I would use CallingFormId instead of CallingFormName as parameter, though (in case you decide to rename the objectname - e.g. Form.SetCallingForm(FORM::MyForm)).

I would have to agree sv. I do not want to use any other objects except my forms. I don’t want to use a table or codeunit to pass one parm. Perhaps in the future we will need more functionality of this type, but for now, I will be calling functions to set the globals. (similar to a constructor for object instantiation) However, it was nice to see so much feedback on the topic. Thanks all. Owen