125 views

Description

Scripts that offer a current global variable, such as business rules, behave unexpectedly when using the newRecord() method from the scoped GlideRecord class. The method does not properly set the default value when used with a current global variable.

Steps to Reproduce

  1. Navigate to System Applications > Applications.
  2. Click New.
  3. Click the Create button from Start from a template.
  4. Enter a valid application name. For example, enter Example.
  5. Click Configure for Advanced Service Management.
  6. Verify the values of required fields such as the Task number prefix.
  7. Click Create.
    The system creates an application and table.
  8. Navigate to System Definition > Scripts - Background.
  9. In Run script, paste the following code:
    var example = "x_example_request";
    var current = new GlideRecord(example);
    current.state = 31;
    current.insert();
    var table = new GlideRecord(example);
    table.newRecord();
    gs.addInfoMessage("Current state = " + current.state);
  10. In scope, select Global.
  11. Click Run script.
    The current.state has a value of 31.
  12. In scope, select your application scope.
    For example, x_example.
  13. Click Run script.
    The current.state has a value of 1.

Workaround

Use the initialize() method instead of newRecord().


Related Problem: PRB706362

Seen In

Fuji Patch 7 Hot Fix 5
Fuji Patch 7 Hot Fix 9
Helsinki Patch 2

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2016-10-21 22:36:33
Published:2016-10-22