Difference between revisions of "Pandora - Sample - Obtain System Variable"

From SmartWiki
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
The following code will obtain the value from the [[System Variable]] called '''Registration Deadline'''
 
The following code will obtain the value from the [[System Variable]] called '''Registration Deadline'''
  
 
+
  var rs= session_getuser(false,"","firstname");
  var rs=variables_replace(false,"",40,"@me.userid@","@system.Registration Deadline@");
+
USERID=rs.getfieldbyname(1,"userid");
 +
rs=variables_replace(false,"",40,USERID,"@system.Registration Deadline@");
 
  var msg=rs.getfieldbyname(1,"msg");
 
  var msg=rs.getfieldbyname(1,"msg");
 
  alert("The Registration Deadline is " + msg);
 
  alert("The Registration Deadline is " + msg);
 
   
 
   
 
==Notes==
 
==Notes==
* For system variables it doesn't matter what object you process them against. In this case the current user account is used.
+
* This would ONLY be required on a page that does not go through the SmartSimple variable process such as a static page in a SmartFolder. Any content in custom fields would be processed directly, so '''@system.Registration Deadline@''' will be replaced directly without the need to use Pandora.
 +
* The first 2 lines obtain your user ID, in case it is relevant to the variables_replace search (ie: if the variable is a user variable)
 
* The '''variables_replace''' function returns the result in recordset in a field named '''msg'''
 
* The '''variables_replace''' function returns the result in recordset in a field named '''msg'''
  

Latest revision as of 18:47, 7 January 2013

The following code will obtain the value from the System Variable called Registration Deadline

var rs= session_getuser(false,"","firstname");
USERID=rs.getfieldbyname(1,"userid");
rs=variables_replace(false,"",40,USERID,"@system.Registration Deadline@");
var msg=rs.getfieldbyname(1,"msg");
alert("The Registration Deadline is " + msg);

Notes

  • This would ONLY be required on a page that does not go through the SmartSimple variable process such as a static page in a SmartFolder. Any content in custom fields would be processed directly, so @system.Registration Deadline@ will be replaced directly without the need to use Pandora.
  • The first 2 lines obtain your user ID, in case it is relevant to the variables_replace search (ie: if the variable is a user variable)
  • The variables_replace function returns the result in recordset in a field named msg


See Also