Create System Default Values

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
bart.gebruers
User
Posts: 23

Create System Default Values

Post by bart.gebruers »

I wonder if it is possible to create some defaults like, for example,

  • CurrentUserName()
  • CurrentUserID()
  • ew_CurrentUserIP()
    .. that I can use in my table settings with the Auto Update Value.

That way I would specify a "UserLocation" value that I would use when a user (employee) creates a record.
(it would be added to the record without being visible on screen)
Employees can work in 1 of 4 locations and I want to do some location specific reporting.
Users have to login and location is a field in the user table (so it is known after log in)

Hope this makes sense :-)

Any hints or tips would be appreciated.

Thx
Bart


mobhar
User
Posts: 11703

Post by mobhar »

As the Help said, you may simply add your own functions by putting your own functions in the server side "Global Code" section (please read "Server Events and Client Scripts" topic), and then add your function name into "Tools" -> "Advanced Settings" -> "Auto-Update values".

The function name must follow the standard rules for naming variables in PHP.

Make sure also you have already added comma (,) separator to separate your own function with the existing ones. For example, your global function name is "UserLocation()", then the new values shoud be as follows:

CurrentUserName(),CurrentUserID(),CurrentParentUserID(),CurrentUserLevel(),ew_CurrentUserIP(),ew_CurrentDate(),ew_CurrentTime(),ew_CurrentDateTime(),UserLocation()


bart.gebruers
User
Posts: 23

Post by bart.gebruers »

Thx.

Issue I have is:
When I echo $UserLocation() on a test page, it works.
When I try to set it as the default value when adding a record, the field stays empty.

Any idea ?

Thx
Bart


mobhar
User
Posts: 11703

Post by mobhar »

Use "Row_Inserting" server event to assign the field with that global function.


bart.gebruers
User
Posts: 23

Post by bart.gebruers »

That is exactly what I did and how I got it to work ... but good to see the confirmation that this is the way I should have done it.
(I just played around with putting it in several places)

I fooled around a bit, my solution now is maybe not the cleanest way but it works.

Thx


Post Reply