One of the benefits of an object oriented language, is the ability to instantiate classes and manipulating the instance of that class.
Current is an instance of a GlideRecord.
The constructor or class of an object is always the ‘template’ for an instance of that specific object.
Even new Object has the constructor Object.

In javascript, var x = new Object or var x = {}, will create an instance of Object in variable x.

This is not surprising for a OOP-language.

One of the biggest benefits of this however is the flexibility it provides.
Now we know that current is an instance of a GlideRecord, we know it can be manipulated as any instance can.
Imagine we’d be creating a before business rule and want to use (or abuse??) the current object that is available.

Try the following two business rules:

Name: Before BR
When: Before
On: Insert, Update
Script: current.nvar_test_value = ‘Hello! I am being transferred from the before to the after current object.’;

Name: After BR
When: After
On: Insert, Update
Script: gs.print(current.nvar_test_value);

Put them on a random table and either create or update a record.
Also note that prints will only appear when you have your debugger on, so make sure its running.
Continue reading…»