NetTalk Central

Author Topic: Where to embed?  (Read 5122 times)

nevy

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Where to embed?
« on: February 19, 2011, 06:09:20 AM »
Hi Guys,

I have a standard form on a table. need to load an image against this record.
So no problem use a   "File Upload" field on a local variable(Loc:Image). And display image on a "display field" against the field name "Asset:Image" so the user can see the image on the form.
Now when the user accepts the File Upload entry I would like to refresh the image so it display immediately, and I need to move the value (if it has been set) from the Loc:Image variable to the Asset:Image field on the table.

I do not seem to get the correct embed point for this. Can anyone please give me an indication as to where the best place is to put the code to move the variable to the tablecolumn

Question: At which point in the life of the form when it is first called are the table fields fetched and loaded in the session queue. As I understand it all fields of the record buffer are loaded into the Session queue. The local variable that is declared in the form procedure, Is it loaded into the session queue automatically or must I do a SSV for the local variable.

Many thanks

Neville

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Where to embed?
« Reply #1 on: February 20, 2011, 10:49:11 PM »
Hi Neville,

>> Now when the user accepts the File Upload entry I would like to refresh the image so it display immediately,

but at the time they tab off the file, you get the _name_ of the image, but not the image itself. The image is only uploaded when they press the "Save" button. It's not possible to (directly) upload the file asynchronously. there are some hacks in this area, which I might implement, but that's for down the road a bit.
 
>> Question: At which point in the life of the form when it is first called are the table fields fetched and loaded in the session queue.

Before the PreUpdate routine.

>> As I understand it all fields of the record buffer are loaded into the Session queue. The local variable that is declared in the form procedure, is it loaded into the session queue automatically or must I do a SSV for the local variable.

Automatically, when the form opens. If you set, or change, the value I recommend updating the SessionQueue at the same time.

Cheers
Bruce

nevy

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Re: Where to embed?
« Reply #2 on: February 21, 2011, 04:53:47 AM »
Ok Thanks Bruce,

So now I have put the following code:
  p_web.SSV('Loc:Image',p_web.GSV('AssetComp:Image1'))
into the start embed of the PreUpdate routine, accepting the fact that the session queue is now already stablished at this point. But when the form open the Loc:Image field is still blank.
The other option is to leave the Local as is and only overwrite the table column if the Loc:Image has been set.
Should I go that path, at which point do I write the Loc:Image value to the AssetComp:Image1.

Hope this all makes sense.

Thanks

Neville

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Where to embed?
« Reply #3 on: February 22, 2011, 02:34:54 AM »
>> But when the form open the Loc:Image field is still blank.

So what is in
  p_web.GSV('AssetComp:Image1')

when you do
  p_web.SSV('Loc:Image',p_web.GSV('AssetComp:Image1'))

?

Also - priming a File-Update field makes no sense.

cheers
Bruce

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Where to embed?
« Reply #4 on: February 22, 2011, 07:24:58 AM »
note: This will be automatic in the next build. So only hand-code this if you're in a hurry.

a) In the PreCopy and PreUpdate routines add the following line;

p_web.SSV('_save_MAI:MailBoxPicture',MAI:MailBoxPicture)

where MAI:MailBoxPicture is the name of the field.

b) In the completeForm routine, embed jsut after the Code statement;
  if (loc:act = Net:CopyRecord or loc:act = Net:ChangeRecord) and p_web.GetValue('MAI:MailBoxPicture') = ''
    p_web.SetValue('MAI:MailBoxPicture',p_web.GSV('_save_MAI:MailBoxPicture'))
  End

again, replace MAI:MailBoxPicture with the correct field name.

Cheers
Bruce

nevy

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Re: Where to embed?
« Reply #5 on: February 22, 2011, 12:06:12 PM »
Thank you very much, works just fine.

Cheers

Neville