Start form app in insert mode from Main Menu

Hi All,
I have a form application with with Single record option. How can I create a link to this application from my main menu to open it in insert mode? My idea is to have a menu item called ‘Add new record’ and when user click that option it will open the form in insert mode.

I cannot use sc_apl_conf(“my_form_name”,“start”,“new”) in appinit event as I need this form in somewhere else to open in edit mode.

Regards,
Aari

Why don’t you use scriptinit and use a condition to do the conf?

Hi aducom,
Thank you for your quick reply. Could you please explain little bit further about using the condition?

Appreciate your assistance.
Regards,
Aari

try in toolsbar disable options UPDATE and DELETE

so what condition i should use?

In main menu it calls “my_form_name” and it will open the form. then in appinit what do i have to look for in order block update and delete? i know how to block those options but just can’t get my head around the condition.

Am i missing out something very simple here?

no code. OPEN FORM - CONFIGURATION - TOOLSBAR disable options UPDATE and DELETE.

This will only allow insert of code. If that’s your need then it will work. Otherwise, if you want one application to behave differently depending on the application which is calling it then you can set a global var like:

[glob_insert]=1; to start in insert mode and
[glob_insert]=0; to start in edit mode.

Then you do a sc_redir(your.php);

in this ‘your’.php you do onscriptinit:

if ([glob_insert]==1){
sc_apl_conf(“my_form_name”,“start”,“new”)
}

But the option of alvagar works too. You can enable/disable these buttons in the same event by using a macro.

@alvagar - thank for your suggestion but that will permanently block edit function of this form. I only need to start in insert mode if user click ‘Add new Record’ in main menu. Otherwise it will go to browse mode which then users can add/edit data.

aducom - your solution works perfectly if I can set that global variable from main menu. Inside an app I can do this by setting the global variable to “1” and then calling my form. But how can I do that when I call this form from a Menu?

Please see attached image.

main_menu.jpg

ohh noo I cannot believe I missed this one. Looking at macros for Main Menu, I found that there is a macro already for this. :slight_smile:

All you need to do is add this code onExecute event inside main menu application.

// item_12 is the menu item to call ‘Add new record’

if ({sc_menu_item} == “item_12”)
{
sc_apl_conf(“form_Employees”, “start”, “new”);
}

Thanks guys for your input on this.

thanx Aari, I was looking for the same problem.
Neverthelese, I think SC team could spend more attention to the most basic RAD scenariou’s and make it more clear. At least the examples on the righ of OnExecute
does not show any hints on ac_app_confm nor on any menu variables
.
#aari How did you find the name sc_menu_item ?