You are viewing limited content. For full access, please sign in.

Question

Question

How Do You Update a Date Field in the SDK?

asked on January 3, 2016 Show version history

Here's the snippet of code I'm using:

FieldValueCollection FVCNew = DI.GetFieldValues();
FVCNew.Add("Res/Ord Number", "Test");
DateTime Date = DateTime.Parse("01/01/1950");
FVCNew.Add("Date", Date);
DI.Lock(LockType.Exclusive);
DI.SetFieldValues(FVCNew);
DI.Save();
DI.Unlock();

Here on answers the recommendation is to use a DateTime object, which I am, but I don't get anything in the field. I don't get an error either.

The other field does update, so I do know I'm doing it correctly in general. I tried a string also but that did not work either. Any advice is appreciated.

0 0

Replies

replied on January 4, 2016


Alex - Try instantiating a new FieldValueCollection instead of using the BoundEntryInfo FieldValueCollection.  This code snippet works on my system;

            EntryInfo di = this.BoundEntryInfo;
            FieldValueCollection FVCNew = new FieldValueCollection();
            DateTime Date = DateTime.Parse("01/01/1950");
            FVCNew.Add("Date", Date);

            di.Lock(LockType.Exclusive);
            di.SetFieldValues(FVCNew);
            di.Save();
            di.Unlock();

 

replied on January 4, 2016 Show version history

Alex - I went back to the SDK documentation to verify your code and it would appear that there might be a bug in the overloaded Add method of the FieldValuesCollection.  From the SDK documentation this code should work but it does not (no errors reported per your post);


FieldValueCollection FVC = EI.GetFieldValues();

FVC.Add("Date of Service", System.DateTime.Parse("01/01/1950"));
EI.Lock(LockType.Exclusive);
EI.SetFieldValues(FVC);
EI.Save();
EI.Unlock();

However, this code snippet does work;



FieldValueCollection FVC = EI.GetFieldValues();

FVC.Item("Date of Service") = System.DateTime.Parse("01/01/1950");
EI.Lock(LockType.Exclusive);
EI.SetFieldValues(FVC);
EI.Save();
EI.Unlock();

Strange! 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.