My Oracle Support Banner

Issue with Closures/Lexical Scoping in eScript (Doc ID 1931696.1)

Last updated on NOVEMBER 22, 2019

Applies to:

Siebel CRM - Version 8.2.2 SIA[22320] and later
Information in this document applies to any platform.

Symptoms

I am writing Business Services that create custom objects in eScript, and I wish to create "instance variables" that can not be accessed from outside the object.

The BS tested contains the following scripts:
- - -
function Service_PreInvokeMethod(MethodName, Inputs, Outputs)
{
var a = createClosure();
Outputs.SetProperty("Test",a.getName());
}
- - -
function createClosure()
{
var a = function()
{
  var b = "test";
return{
getName: function() {return b;}
}
}
return a();
}
- - -

When calling createTestClosure(), I am able to retrieve a newly created object.

a.displayName(); fails however and I get an error message saying that "b" is not defined.

However, as eScript is a variant of ecma script, it should be possible to use lexical scoping in order to access the variable b from the literal function getName.

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Cause
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.