Highlighted
Absent Member.
Absent Member.
186 views

HPSM - Closing a changes has an unexpected result.

Hello, 

Im working with HPSM v9.32 and are trying to create a C# application which can Close a Change. 

Currently we have serveral application able create changes, incidents and so on. but when im implementing the Close Change it has a strange outcome.

What happens is that the case im trying to close gets closed, but somehow cloned and recreated with a new ChangeNumber. (The old one is sucessfully set to Closed however). 

Im not sure what can be causing this, so here is my code and im hoping anyone here can shead some light over this issue.

Here is the CloseChange method with some supporting functions. 

 

     public RequestStatus CloseChange(string caseNumber, string closingComment)
        {
            try
            {
                using (var client = new ChangeManagementClient())
                {
                    var model = new ChangeModelType();
                    var keys = new ChangeKeysType()
                    {
                        ChangeNumber = GetStringTypeVal(caseNumber),
                        
                        
                    };

                    SetCredentials(client);

                    model.keys = keys;
                    model.instance = CreateCloseInstance(closingComment, caseNumber);

                    var request = new CloseChangeRequest
                    {
                        model = model,
                        attachmentData = true,
                        attachmentInfo = true,
                        attachmentDataSpecified = true
                    };

    
                    var response = client.CloseChange(request);

                    if (response.status == StatusType.FAILURE)
                    {
                        return RequestHelper.CreateError(response.message);
                    }
                    var caseId = response.messages[0].Value;
                    return RequestHelper.CreateSuccess(CaseIdHelper(caseId));
                }
            }
            catch (Exception e)
            {
                return RequestHelper.CreateError(e.ToString());
            }
        }

private ChangeInstanceType CreateCloseInstance(string closeComment, string caseNumber)
{
var change = new ChangeInstanceType();

change.header = new ChangeInstanceTypeHeader
{
ChangeNumber = GetStringTypeVal(caseNumber),
CloseTime = GetDateTypeVal(DateTime.Now),
CurrentPhase = GetStringTypeVal("Inform & Closure:887")
};
change.ClosureComments = new ChangeInstanceTypeClosureComments()
{
ClosureComments = GetStringArrayTypeVal(closeComment)
};

return change;
}

private static StringType GetStringTypeVal(string value)
{
return new StringType { Value = value };
}

private static StringType[] GetStringArrayTypeVal(string value)
{
var temp = new StringType[1];
temp[0] = GetStringTypeVal(value);
return temp;
}

 

0 Likes
1 Reply
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: HPSM - Closing a changes has an unexpected result.

I doubt your issue is in your code here....Have you tried tracing Service Manager?

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.