How to get back to mainform

Hi! I’ve made a function which prossesses the activated line(record) from the General Ledger, General Journals(gets called from a button). The trouble I’m having is that when I’m done prossessing the activated line, I can’t update or get back to the GJ form. The form that is visible now looks like a tempform(??) of the GJ with only the activated line/record in it. The only way to get back is to close the form and open the GJ again from the menu. GJ is now updated. Is there a way to view the GJ and the new records without having to close and open again? The second problem only needs to be solved if the first problem isn’t… Second problem is: the activated line only gets a dot when it has been prosessed, and I can call my function until eternity…[:I] This isn’t exactly a good thing… What can I do? TiA

Try to call CurrForm.UPDATE(FALSE) after calling your function.

Thank you for replying but I did that already… doesn’t work…

The problem is that I use a form to get innputvar. and the code is under the OnPush() on this form. I don’t now where to put the update on the GJtempform… do you?

Are we talking about the standard Navision Form 39 “General Journal” ?

Yes we do…:slight_smile: When the line is activated and i call my function from the button the other lines disappear. After prosessing the line, I must close and open it again to se it updated…

Can you explain how you call the function and what you are doing with the record ?

ok… I activate the record I want to prosess, push the menubutton and select my function. A form pops up and i enter the values needed and push the ok button which call the function. The record is prosessed and the new records are added to the GJ(but here is my problem… I can’t see them right away…) Birte

Are you changing the record inside the form you are popping up ? How do you popup the form ? Using the OnPushTrigger or PushAction = RunObject ?

I just prosesse the records, they are not displayed in any way… I use the PushAction.

The form you are calling has table 81 defined as Source Table ? What does “Processing” mean ? do you change a record or are you adding new records ? Or are you deleting records ?

yes, source table 81. I am adding new records.

OK, try the following: Define a variable of the type form and assign the form number you want to call. Clear the PushAction of the menu item. Change the OnPush() trigger for that menu item OnPush() CLEAR(processform); processform.SETTABLEVIEW(Rec); processform.SETRECORD(Rec); processform.RUNMODAL(); CurrForm.UPDATE(FALSE); that should

Thank you for trying to help, Thomas! But I don’t seem to get this right… I get an errormessage because of the runmodal. ‘RM() is not allowed in write transactions’(this in addition to quite a long errormessage…:l )

I know what my problem is now! When I activte the record and select the menuitem, a filter is set. How do I get it back to normal instead of using ctrl+shift+F7? Anyone?? TiA

OnPush() COMMIT; CLEAR(processform); processform.SETTABLEVIEW(Rec); processform.SETRECORD(Rec); processform.RUNMODAL(); CurrForm.UPDATE(FALSE); This will prevent the error.

Yes, prevented the error :slight_smile: And I’m back to where I started… :l It doesn’t update the window…

The filter is most probably getting set in the form you are calling. When you use the PushAction = RunObject, then Navision takes the filter currently applied to the called form (when running OnRec) and when you close the target form it get’s the filter back from the called form. The code I sent you also prevents this.

hmm… ? I use the PushAction=RunObject, and OnRec. I don’t quite understand what u are saying… can u please explain it more carefully?which form does it get the filter from(what do u mean by target form)? my form? if so, is ther a way to get the original filter from form 39? this way I can set the filter before closing my form… ??

I would suggest that you encapsulate the form you are calling into a CU: create a new codeunit and make it use the table 81 (TableNo property of the CU). create a global variable using the Table 81 and create a function called “Code”: OnRun(); GJLine.COPY(Rec); Code(); Rec := GJLine; Code() COMMIT; CLEAR(processform); processform.SETTABLEVIEW(GJLine); processform.SETRECORD(GJLine); processform.RUNMODAL(); processform.GETRECORD(GJLine); Now call this CU instead of the form directly in the RunObject. A short explanation of what is happening: If you call a form using the PushAction = RunObject and set the RunFormOnRec to true then Navision is performing the following action: It copies the currently marked record including the filters which apply to the current record (i.e. the filters set in the GJ Form) to the form (object) you are calling. The control is handed over to the form you called. Inside this form you are performing some action on the “Rec” variable, which has the same filters set as the form you have been calling from. Now you are setting new filters to the “Rec” variable while performing your inserts. When you close the form, Navision is giving the active record back to the GJ Form including the filters you have been setting in the called form. The result is that you can see the filtered records only after returning from the form.