Is there a method for opening a form in record insert mode?
YES.
Forces the “my_form” application to start in the addition mode.
sc_apl_conf(“my_form”, “start”, “new”);
Thank you Alvagar. But it didn’t work in a blank form.
I have a menu item like: “New Employee”
I want the menu item to send the user to “Employee” form in new record mode. So I made a blank application and put the code you wrote above in “onExecute” section but it does nothing.
Any ideas?
I tried this code in employee form on application init event:
if ({sc_menu_item} == "item_22") { sc_apl_conf("employee", "start", "new"); }
Now I have an error message: “Undefined variable: sc_menu_item”
The code must be in event:
onApplicationInit OR
onScriptInit
sc_apl_conf(“my_form”, “start”, “new”);
That part of the code is working fine. Thank you.
But I want the code to run only when I open the form from the “New Employee” menu item.
Because I’m using the same form in normal grid view with another menu item: “Employees”
So, I need to check if “New Employee” menu item is selected by user.
Anyway, I’ll ask this part of my problem in Menus forum, thanks again.
The code can be into onexecute event.
if ({sc_menu_item} == “item_new”)
{
sc_apl_conf(“form_customer”, “start”, “new”);
}
Yes, I tried that with the Blank application, but it did nothing.
Correction: It gave this error:
Undefined property: blank_apl::$sc_menu_item
It only work with forms.
Yes, I tried it with form also.
When I used it on Employees form, at “onApplicationInit” or “onScriptInit” events, it gives: Undefined variable: sc_menu_item
Finally:
I used the below code in menu application onExecute event and it worked:
if ({sc_menu_item} == "item_18"):
sc_apl_conf("Employees", "start", "new");
endif;
Yes… that would work. For the record, If you try to add the code to the onscriptinit of the form there are two problems:
-
The {sc_menu_item} variable is not a global variable therefore it would not have been passed form the Menu application. (You would need to convert it to a glogal variable within the menu application first. (either set global or [Menu_Item] = {sc_menu_item};… then use the global variable in the recieving application.
-
As far as I’m aware, sc_apl_conf(“Employees”, “start”, “new”); cannot be called within the receiving application… It must be called before the application is initiated.
Putting these both together and doing it within the menu item is why it works now.
I hope this helps.
Ian