[SOLVED] Need help quickly - any way on a form onLoad to tell if I am in INSERT mode?

Hi. I am showing a prototype to a client tomorrow am - I need some quick help if possible.

I have a form used for both INSERT and EDIT. I was using the onLoad event to load many of the fields with some default data, however, I just realized that the onLoad fires for both INSERT and EDIT modes for the form.

I guess I could make 2 forms, one for add and one for edit, but was wondering if I can detect the mode the form is in from the onLoad event and just make my default values conditional.

Note - User must be able to edit the default values, hence I am putting them in onLoad and not BeforeInsert…

Thanks,
Jamie

Yes, for example if your primary key is id_employee, just check if that variable is set.


if(!isset({id_employee})){
     //insert mode is on
} 

1 Like

Hi Hirambq!!!

You saved me a lot of work, and I really appreciate it.

I tried the !isset but it did not work, but I was able to just make my ID field a hidden field on the form, then us this variation of what you sent me:

if ({ID} == “”)
{
//insert mode is on

// load 'defaults' using the team (org) settings form current team
{LongName} = [glo_test_name]; 
{Slogan} = [glo_test_slogan];
{Description} = [glo_test_description];
{MiniLogo} = [glo_test_logo];
{ColorPrimary} = [glo_test_colorprimary];
{ColorSecondary} = [glo_test_colorsecondary];
{ColorText} = [glo_test_colortext];

}
else
{
// edit mode - do NOT overwrite any fields :slight_smile:

}


You saved me having to make an additional form, etc. Now I feel good about showing this part of the interface in the morning! If you are ever in Tampa Florida, letr me know and I will buy you lunch :slight_smile:

This forum is a great help because of people like you,
Peace,
Jamie

I also cramped for half a day on such a task. HiramBQ god you are king! Thank you!