Method detail for the Change Manager script include

isAuthorized(GlideRecord record)

Determines if the user is authorized to make changes.

Input Fields

Parameters:
  • record - (GlideRecord) The current record.

Output Fields

Returns: (boolean) true if the user is authorized to make changes.

Example

isAuthorized : function (current ) { return gs. hasRole ( 'chef_admin' ) ; }

isChangeRequired()

Determines if change management is required.

Input Fields

Parameters:
  • None

Output Fields

Returns: (boolean) true if change management is required; otherwise, false.

Example

isChangeRequired: function ( ) { return gs. getProperty ( 'glide.config_auto.chef.node_definition.use_change' ) == 'true' ; }

getChangeId(GlideRecord current)

Returns the change ID associated with the passed current record. If change management is required, a change record must be associated with the resource to be changed.

Input Fields

Parameters:
  • current - (GlideRecord) The current record.

Output Fields

Returns: (String) the Change ID.

Example

getChangeId : function (current ) {
 
     if (JSUtil. nil (current ) ) return null ;
 
     if ( !current. instanceOf ( 'node_definition' ) ) { return null ; }
 
     return current [ 'change' ] ; }

setChangeId(GlideRecord record, String changeId)

Associates the passed change request ID with the passed record.

Input Fields

Parameters:
  • record (GlideRecord) The current record.
  • changeId (String) The Change Request ID.

Output Fields

Returns: void

Example

setChangeId : function (current , changeId ) {
 
     if (JSUtil. nil (current ) ) return ;
 
    current [ 'change' ] = changeId ;
    current. update ( ) ; }

prepare(GlideRecord record)

Prepares the changes. This method is called before the execution of the changes.

Input Fields

Parameters:
  • record - (GlideRecord) The current node definition draft record.

Output Fields

Returns: (GlideRecord) the current node definition draft record.

Example

prepare : function (current ) {
 
     var change  = current. cfg_auto_change ;
 
     if (JSUtil. notNil (change ) ) { var phaseList  = new ChoiceList ( 'cfg_auto_change' , 'phase' ) ; var gr  = new GlideRecord ( 'cfg_auto_change' ) ;
        gr. get (change. sys_id ) ;
        gr. setValue ( 'phase' ,phaseList. getValue ( this. IN_PROGRESS ) ) ;
        gr. update ( ) ; } return current ; }

finalizeChange(GlideRecord record)

Finishes the change process. This method is called before the change request is closed. Anything that needs to be done before the change request closes goes here.

Input Fields

Parameters:
  • record - (GlideRecord) The current node definition draft record.

Output Fields

Returns: void

Example

finalizeChange : function (current ) {
 
     var changeId  = current. cfg_auto_change. sys_id ;
 
     //Update current node definition from requested var changeGr  = new GlideRecord ( 'cfg_auto_change' ) ;
    changeGr. get (changeId ) ;
 
    current. fqdn = changeGr. fqdn ;
    current. cfg_auto_provider = changeGr. provider ;
    current. cfg_auto_management_server = changeGr. management_server ;
    current. node_definition = changeGr. node_definition ;
    current. update ( ) ;
 
    ...
 }

getWorkflowVariables(String workflowName, GlideRecord record)

If a workflow is required by the provider, returns the variables that the workflow consumes. Even if you do not need to use a workflow, implement this function and return an "undefined" value.

Input Fields

Parameters:
  • workflowName - (String) The workflow name.
  • record - (GlideRecord) The current record.

Output Fields

Returns: (Object) the workflow variables.

Example

getWorkflowVariables : function (wfName , nodeDefGr ) {
 
     var wfVars  = { 'u_node_def_id' : nodeDefGr. getValue ( 'sys_id' ) } ; return wfName  === 'Deploy Chef Change Master' ? wfVars  : { } ;
 
 }

getPushWorkflowName()

If a workflow is required by the provider, returns the master workflow name. Even if you do not need to use a workflow, implement this function and return an "undefined" value.

Input Fields

Parameters:
  • None

Output Fields

Returns: (String) The workflow name.

Example

getPushWorkflowName : function ( ) { return 'Deploy Chef Change Master' ; }

cleanupAfterCancelChange(GlideRecord record)

Cleans up any resource or data if a change is canceled. This method is called after the change request is canceled.

Input Fields

Parameters:
  • record - (GlideRecord) The node definition draft record.

Output Fields

Returns: void

Example

cleanupAfterCancelChange : function (nodeDefDraftGr ) {
 
     new Workflow ( ). cancel (nodeDefDraftGr ) ; // cancel the flows against our extended table
    nodeDefDraftGr. change = '' ;
    nodeDefDraftGr. update ( ) ; }