Skip to main content
Version: 20 R7 BETA

WP Get data context

WP Get data context ( wpDoc ) -> Function result

ParameterTypeDescription
wpDocObject4D Write Pro document
Function resultObjectData context object

This command is not thread-safe, it cannot be used in preemptive code.

Description

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