NetTalk Central

Author Topic: call an update form without a browse  (Read 2377 times)

alan

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • Email
call an update form without a browse
« on: August 12, 2013, 07:47:40 AM »
At login, I'm fetching the user's account record and using SSV to store the user's sysid.

I have a menu item for the user to edit their account information.  When selected, I want to directly call the update form in update mode with the user's account record loaded (using the unique sysidkey)

I can't figure out what code to embed into the update form to make this happen. (or, can I set a parameter when calling the update form from the menu?)

Help would be appreciated.
Alan Schoolcraft

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11186
    • View Profile
Re: call an update form without a browse
« Reply #1 on: August 12, 2013, 10:01:43 AM »
you can set a parameter where the form is called from, or you can set the form to "know" that it's called in that mode.
Form properties - advanced tab, default action (Change) and set the key field to the stored Session Value. eg
p_web.gsv('userid')

Cheers
Bruce

alan

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • Email
Re: call an update form without a browse
« Reply #2 on: August 12, 2013, 07:12:58 PM »
Bruce,

I previously found the setting for default form action and had it set to "Change".  I also tried setting the unique key after the form was opened.  In fact, I tried setting it in almost every embed in the form.

Now, here's something interesting.  I have 3 forms I am calling directly from the menu.  I embedded a message in the embed immediately after the Code statement on all three forms, as well as on a browse and on a form being called by the browse.

All three of the forms being called from the menu are being called constantly.  That is, when the app first opens and anytime any item on the menu is clicked - all three forms are called with p_stage = 524288.  Neither browses nor forms being called by browses have this behavior.

I have no idea if that's what is causing my problem, but it does seem odd.

One more thing - the error I'm getting when calling the forms directly from the menu (with form action set to Change and the unique key primed) is -  record not found: (-2) Error 30: Entry Not Found from key act:sysIdKey

I can't find in the form where the record is being read.  If you can tell me where that is, I can try setting the key immediately before the fetch.
Alan Schoolcraft

JohanR

  • Sr. Member
  • ****
  • Posts: 339
    • View Profile
    • Email
Re: call an update form without a browse
« Reply #3 on: August 12, 2013, 10:27:27 PM »


Hi Alan

Just a thought.

Did you set the sysid value in the "key field 1 value", this is directly below the drop down where you set the form default action.


Johan

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11186
    • View Profile
Re: call an update form without a browse
« Reply #4 on: August 12, 2013, 10:36:47 PM »
>> I embedded a message in the embed immediately after the Code statement on all three forms

It's important to understand that browse and form "procedures" in the web do not work the same as the ones in windows. On windows they start, run to completion, and close (when the user clicks the close button.) On the web they get called many many times, with each call doing just one small part of the procedure itself, then finishing. Think of them more as "Event handlers" and less like "whole procedures".

so embedding where you did means that code gets triggered lots and lots of times - and sometimes when you're not expecting it at all.

Browses and Forms have a template setting "Send Stage to Debugview". (a "stage" is like an event handler.) If you want to see how often the procedure is called, turn these on and run the app for a bit.

Given the above how do you find the right embed point? Well usually I do exactly that - I turn on the Debugview for the Stage, do whatever it is I want to "trigger" the code, and see what event comes through. Then just look at the stage/event handler and follow the code to a suitable embed point.

this mindset is quite different to windows because even the phrase "... after the form was opened..." becomes problematical.

So let's get back to your original problem;
>> I previously found the setting for default form action and had it set to "Change".

good. Set that to Change.
In the same place you can set the key values for the record to edit. What did you set those values to?

cheers
Bruce



alan

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • Email
Re: call an update form without a browse
« Reply #5 on: August 13, 2013, 01:12:13 AM »
Woohoo!! - it's so easy - after two days of looking

For the benefit of anyone else trying to figure this out:

1.  On the advanced tab, set Default Form Action to Change

2.  On the same tab, set the key field value(s) to the names of the field(s) in the key (in my case, Key field 1 Value is  act:sysid   )

3.  In the first embed after the Code statement, set the value of the key field (in my case -  act:sysid = p_web.GSV('act:sysid')  )

Thanks Bruce
Alan Schoolcraft

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11186
    • View Profile
Re: call an update form without a browse
« Reply #6 on: August 13, 2013, 05:04:35 AM »
Hi Alan,

In step 2;
 set the key field value(s) to the _session values_ of the field(s) in the key (in my case, Key field 1 Value is  act:sysid   )
ie
p_web.GetSessionValue('act:sysid')

This makes step 3 go away (ie no embed code required.)

You're right, it's easy when you know how. there are maybe a thousand factoids like this. Figuring out how to impart all these details is hard. It's one of the reasons I'm doing the training at Devcon this year. But even with that assimilating a bunch of knowledge is hard, unless you "need that factoid right now". I guess that's why we call it Experience  :)

Cheers
Bruce