This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20 R7
WP Get data context

WP Get data context 


 

WP Get data context ( wpDoc ) -> Function result 
Parameter Type   Description
wpDoc  Object in 4D Write Pro document
Function result  Object in Data context object

The WP Get data context command returns the data context of the wpDoc document. Data contexts are defined using the WP SET DATA CONTEXT command.

In wpDoc, pass the 4D Write Pro document whose data context you want to get.

Example  

You can get a data context from a document and reuse it in another method within the same process.

The following method sets a data context: 

  // method1
 var $person: Object
 var $wpArea : Object
 
 $wpArea:=WP New()
 
  // Create person object
 $person:=New object()
 $person.firstName:="John"
 $person.lastName:="Doe"
 
  // Set context using the person object
 WP SET DATA CONTEXT($wpArea;$person)
 
 method2($wpArea//call the other method

method2 might look something like:

  //method2
 #DECLARE($document Object)
 var $context : Object
 
 $context:=WP Get data context($document)
 ALERT(JSON Stringify($context)) // Displays {"firstName":"John","lastName":"Doe"}



See also 

Blog post - ORDA and 4D Write Pro : The power couple!
WP SET DATA CONTEXT

 
PROPERTIES 

Product: 4D
Theme: 4D Write Pro Language
Number: 1787

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v19 R5

 
ARTICLE USAGE

4D Write Pro Reference ( 4D v20 R7)