ObjectGears Help

           
Forum   ObjectGears (Version: 1.6.0.0)

Creating problem record from incident

Functionality description

Within Incident and Problem management processes ObjectGears provides user with possibility to create a Problem record from an existing Incident record. This functionality is available to user by means of a button in the incident detail, which is not linked to any problem at the moment. After clicking on the button the user is asked whether they actually want to create a new Problem. After confirmation information from columns Name, Description, Solver and Related CI of the incident record is copied into corresponding columns of a problem class record. User then can add other information in the new record about the problem and save the record. After saving the user is returned to the detail of the incident record from which the new problem was created and the problem record is linked to the incident in column Problem. The button for creating a new incident is not displayed at incidents that are already linked to an existing problem.

Solution description

In the class Incident there is button, that has checked options Display in the detail on toolbar and Display by a record change. In the property Confirmation query  there is a message asking the user, wheather they really want to create a new problem from incident. In the property Button picture there is selected icon that will be displayed on toolbar as a button. The button launches Action type Script:

// Saves incident, creates URL for a new problem record and includes incident Id into it (for further getting information about Name, Description etc. from incident). It creates a return URL pointing at the incident from which the new problem is created. It opens a new problem record with stating the return URL.
if ( OGDataDetailForm.Save(false))
{
    var clProb = OG.ClassDef.GetByCode( OGModel.Id, 'problem');
    var newProblem = 'DataDetail.aspx?Id=' + clProb.Id + '-0&incId=' + OGActualDataRowId;
    var ret = 'returnUrl=DataDetail.aspx%3fId%3d' + OGActualDataRowParentId + '-' + OGActualDataRowId;
    OGForm.RedirectTo(newProblem + '&' + ret);
}

We set following script in the class Problem for record detail:

function OnCreateEntity()
// Looks for string incId in URL. If it is found and Id points to an incident which is not deleted, it saves values from the incident columns into corresponding columns of the problem record.

{
  var incId = OGForm.QueryString.GetInt('incId');
  var clInc = OG.ClassDef.GetByCode( OGDataRow, 'incident');

  if ( incId != null)
 {
    var drInc = OG.DataRow.GetDataById( clInc.Id, incId);
    if ( drInc != null && !drInc.IsDeleted)
    {
       OGDataRow['name'] = drInc['name'];
       OGDataRow['description'] = drInc['description'];
       OGDataRow['solver'] = drInc['solver'];
       OGDataRow['related-ci'] = drInc['related-ci'];
    }
  }
}

Above stated script sets the values in the form for a new record. Problem record with these values will be saved after user clicks on Save button.

After problem record creation this new problem record has to be linked to the incident from which it was created. This will be ensured by a rule After new record save in the class Problem. This rule will be of type Script.
 

// If there is incident ID in URL, problem will be linked to the incident.


var qs = System.Web.HttpContext.Current.Request.QueryString;
var incId = Com.ObjectGears.Common.Helpers.ExtendMethod.GetInt( qs, 'incId');

if ( incId != null)
{
    var clInc = OG.ClassDef.GetByCode( OGActualDataRow, 'incident');

    var drInc = OG.DataRow.GetDataById( clInc.Id, incId);
    if ( drInc != null && !drInc.IsDeleted)
    {
       drInc['problem'] = OGActualDataRow.Id;
       OG.DataRow.SaveData( drInc);
    }
}

In order the button for a new problem creation is displayed only for incidents that are so far not linked to any problem, we set a script for record detail in the class Incident:

// Hiding button 'new_problem', if there is already reference in the column 'problem'


function OnPreRender()
{
  var s = OGColumns.GetByCode('problem').ColumnUI.GetData();
  //if ( s != null)
  if ( s != null && s.Count > 0)
  {
     OGControlOperations.GetByCode('new_problem').Visible = false;
  }
}

This website is using cookies files to provide services and analyse visits. You agree with that by using this website.     Further information