NetTalk Central

Author Topic: DROP field - Add Selected Record Fields to Session Values  (Read 1481 times)

David

  • Full Member
  • ***
  • Posts: 127
    • View Profile
DROP field - Add Selected Record Fields to Session Values
« on: December 24, 2022, 05:21:16 PM »
NetWebForm

for the DROP field there is the Value field, description field, and you can add additional fields to the view.  I have added an additional field to the view and want to use that value to then hide/unhide other fields on the form.  From my testing it does not appear that NT is writing the DROP record fields to Session values.  Would it be possible to add a DROP template option to write the selected DROP record fields to Session values?

David
NT12

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11155
    • View Profile
Re: DROP field - Add Selected Record Fields to Session Values
« Reply #1 on: December 26, 2022, 10:16:29 PM »
Hi David,

I'm not really sure what you are asking - but no, It's not like the whole view record (from a drop) is saved to a session value. The Unique ID is saved, from there you can lookup whatever you need.

If you have something specific in mind, or are unsure, then make an example showing the effect you are chasing and I can be more explicit on what you might do to achieve that effect.

Cheers
Bruce

Rene Simons

  • Hero Member
  • *****
  • Posts: 649
    • View Profile
Re: DROP field - Add Selected Record Fields to Session Values
« Reply #2 on: December 27, 2022, 04:04:09 AM »
Hi David,

You can always click the drop's 'send new value to server'-check box and write some server side code to achieve
what you want/need.

Cheers,
Ren?
Rene Simons
NT14.14

Alberto

  • Hero Member
  • *****
  • Posts: 1844
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: DROP field - Add Selected Record Fields to Session Values
« Reply #3 on: December 27, 2022, 07:42:24 AM »
I think that David is asking:
What are the purpose of "add additional fields to the view"
The page says to be use in embed points but they have no value.
« Last Edit: December 27, 2022, 07:58:22 AM by Alberto »
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11155
    • View Profile
Re: DROP field - Add Selected Record Fields to Session Values
« Reply #4 on: December 28, 2022, 10:09:44 PM »
Hi Guys,

Firstly - if you want to understand what the template is doing, then it's always a good idea to look at the generated code in the embeditor. Familiarity with that code makes embedding easier, because you know what is happening where.

Adding fields to the VIEW means that while the view is looping through record, those fields are primed from the database. So in order to understand where they are useful it's good to see the generated code surrounding that view.

In the following walkthough, I changed a "lookup customer" string field to be a drop. (Books(71) example, UpdateInvoices procedure).

First the VIEW declaration;

INV:Customer_OptionView   View(Customer)
                          Project(CUS:ID)
                          Project(Cus:Name)
! Start of "Custom View Code"

! End of "Custom View Code"
                        End

As you can see the View declaration also includes an embed point for adding more information like more fields, JOINS and so on.

Then search for it's use;

In
Value::INV:Customer  Routine

      open(INV:Customer_OptionView)
      Loc:Filter.SetValue('')
      INV:Customer_OptionView{prop:filter} = p_web.AssignFilter(loc:Filter.GetValue())
      INV:Customer_OptionView{prop:order} = p_web.CleanFilter(INV:Customer_OptionView,'UPPER(Cus:Name)')
      ! Start of "Option Filter & Order"
     
      ! End of "Option Filter & Order"
      Set(INV:Customer_OptionView)
      Loop
        Next(INV:Customer_OptionView)
        If ErrorCode() then Break.

You can see the view is opened here, and looped through, and so on. So in these embeds the field values are in scope.
Alberto, this is where you can add embed code for these values.

Cheers
Bruce




osquiabro

  • Hero Member
  • *****
  • Posts: 664
    • View Profile
    • Email
Re: DROP field - Add Selected Record Fields to Session Values
« Reply #5 on: December 29, 2022, 03:54:34 AM »
my technique is in add server side code with the value of value field like this:

Rou:RouteCode = p_web.gsv('ByRoute')
Access:Route.Open()
Access:Route.UseFile()
IF Access:Route.TryFetch(Rou:IX_RouteCode) = Level:Benign
    ByRouteId = Rou:RouteID
    p_web.ssv('ByRouteId',ByRouteId)
    p_web.SetValue('SelectField','ByLoteCode')
End

and move to session value any other field for a record selected

Alberto

  • Hero Member
  • *****
  • Posts: 1844
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: DROP field - Add Selected Record Fields to Session Values
« Reply #6 on: December 29, 2022, 08:32:41 AM »
Hi Bruce, thanks for the explanation.
Problem is theres never any situation in which we need to change or to some calculation inside the loop of the view, but theres many situations in which we need all the view values in the Server side embed.
If its possible, it will be very usefull to add the template the feature to save the view values in the session (when selected) to be used in the server side code, otherwise we need to use the code osquiabro post.
May be add a check in the view to select wich one we need to save as session.
Just an idea.
Thanks
« Last Edit: December 29, 2022, 10:28:25 AM by Alberto »
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11155
    • View Profile
Re: DROP field - Add Selected Record Fields to Session Values
« Reply #7 on: January 01, 2023, 10:39:02 PM »
>> Problem is theres never any situation in which we need to change or to some calculation inside the loop of the view,

That doesn't sound like a problem. Clearly I'm not going to remove the embed points just because _you_ don't find them useful? So I'm not sure what you are asking me to do there :)

>> If its possible, it will be very useful to add the template the feature to save the view values in the session (when selected) to be used in the server side code.

If you need to set additional values aftr a Drop item is selected, then the correct place to embed the code is in validate::somefield  routine

The following code should be sufficient;

p_web.SetValue('primarykeyfieldname',somevalue)
p_web.LoadRecord(tablename, primarykeyname)
p_web.FileToSessionQueue(tablename)

for example;

p_web.SetValue('cus:guid',p_web.GSV('inv:Customerguid'))
p_web.LoadRecord(customer, cus:guidkey)
p_web.FileToSessionQueue(Customer)

This has nothing to do with additional View fields. And you should not use Additional View fields for this purpose. I recommend you don't add to the Additional View Fields unless you want to use the field in an expression, or embed point, as discussed earlier.

this might become a template option in NT14, but I'm not adding things to NT12 at this point.

David

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Re: DROP field - Add Selected Record Fields to Session Values
« Reply #8 on: January 02, 2023, 05:07:25 AM »
Thank you all for your responses.  I've added code to the server side that loads the additional field into a session value, which triggers when a drop option is selected, as recommended in this thread.