Because you uncovered a defect or missing functionality in this API :-)

Seriously, indeed, you have found a defect. Currently .NET API is not handling 
assigning a status history value *unless* supplied as a string (i.e. an encoded 
format string value). However unfortunately the utility method (within 
StatusHistory class in this API) for encoding the status history is marked 
internal, so I am attaching a simple implementation of this method for your 
convenience:

       /// <summary>
       /// Encode the status history content to string representation as per AR 
System data file encoding scheme
       /// </summary>
       /// <returns></returns>
       string Encode(StatusHistory sh)
       {
          string encoded = "";
          System.DateTime unixEpoch = new System.DateTime(1970, 1, 1, 0, 0, 0);
          foreach (StatusHistoryItem item in sh)
          {
             if (item.Time != System.DateTime.MaxValue)
             {
                System.TimeSpan span = item.Time - unixEpoch;
                encoded += span.TotalSeconds;
                encoded += (char)4;
                encoded += item.User;
             }
             encoded += (char)3;
          }
          return encoded;
       }

Now, paste this method in your class & convert your status history value 
addition to this statement below:


(BMC.ARSystem.StatusHistory)entry[15];
             fieldValueList.Add(15, Encode(sh));

See how it behaves now....

HTH
Appajee


-----Original Message-----
From: Action Request System discussion list(ARSList) 
[mailto:[email protected]] On Behalf Of André Delcroix
Sent: Tuesday, June 21, 2011 2:47 AM
To: [email protected]
Subject: Problem with Status History in .NET API

Hi list,

Working in C#, I am trying to merge a record, including the status 
history in the list of updated fields.
I create a FieldValueList:
             BMC.ARSystem.FieldValueList fieldValueList = new 
BMC.ARSystem.FieldValueList();

At one point, I execute the following statements:
             BMC.ARSystem.FieldValueList entry = 
_server.GetEntry(currentSchemaName, entryId);
             BMC.ARSystem.StatusHistory sh = 
(BMC.ARSystem.StatusHistory)entry[15];
             fieldValueList.Add(15, sh);

I Check that sh is a Status History object containing the expected values.
After the Add statement, I check the value of fieldValueList[15]. It is 
set to System.DBNull !!

Does anyone know the reason why I cannot set the Status History when 
trying to do a merge operation ?

Thanks

André

_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
attend wwrug11 www.wwrug.com ARSList: "Where the Answers Are"

_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
attend wwrug11 www.wwrug.com ARSList: "Where the Answers Are"

Reply via email to