Determine How A Form Was Opened


Is it possible to determine using C/AL how a form was opened - I’m particularly interested in whether it was opened using a passed Record variable - e.g.

i) From a RunObject/RunFormLink command
ii) From a FORM.RUN(nnnnn, Rec) command


whether it was opened using no record variable - i.e. pick the last visited record from the ZUP file - e.g.

i) From clicking the forms option in the navigation pane
ii) From a FORM.RUN(nnnnn) command

Any help appreciated,


Hi Jonathan

No, that’s not possible either using standard functionality. Why do you wamt to know how the form was opened?



Hi many thanks for the replies.

What I’m trying to do is for example replace the standard resource card form with one of my own custom forms by adding code to the resource card to call a codeunit function that runs my own form passing through the Rec from the standard form (and then closes the standard form). This way wherever in Navision the resource card is called/looked up it will always use my custom form instead.

I have done this and it’s working great. The only drawback is that because I’m passing through the Rec from the standard resource card, if the user runs the form from the navigation pane then the record position is not on the last record where they left it - it gets set to the ZUP setting for the standard resource card. However if I don’t pass the Rec variable through then if the user for instance looks up the resource card from the resource list (using RunObject property) then the card won’t be set to the correct record.

If I knew how the form had been opened then I could set my codeunit function to either pass the Rec variable or not accordingly.


Hi Jonathan

I understand your issue now but I don’t understand why you go into so much trouble redirecting users to your new Resource Card instead of just changing the standard Resource Card.

Anyway, you might be able to use the filter on the resource number that is being set when Navision opens the resource card and is showing a specific resource. A filter is applied to the resource number when the resource card is opened from the list form or from the resource journal. I think Navision always set a filter on the number when the resource card is opened with a specific resource selected.

Add code the below code to the OnOpenForm trigger.

IF GETFILTER(“No.”) <> ‘’ Then

If the GETFILTER(“No.”) returns a value then pass the record to your codeunit and show the record. If GETFILTER(“No.”) doesn’t return a value then just show the record from the ZUP file.



Also if rec is not pointing to any record, then you just don’t need to redirect to your card. Just open the standard card.