cancel
Showing results for 
Search instead for 
Did you mean: 

Update date/time user defined field via DI API

Former Member
0 Kudos

Hi,

I'm trying to update a UDF that's type: date/time and structure: time.

I've tried this:

Invoice.UserFields.Fields.Item("U_hrInEnt").Value = "2122"

Invoice.UserFields.Fields.Item("U_hrInEnt").Value = "21:22"

Invoice.UserFields.Fields.Item("U_hrInEnt").Value = "212200"

Invoice.UserFields.Fields.Item("U_hrInEnt").Value = "21:22:00"

They all return error -1013 - "Invalid valid value '' in Enum 'BoYesNoEnum', the valid values are 'N', 'Y'"

Any ideas how this works?

Regards,

Ana Silva

Accepted Solutions (1)

Accepted Solutions (1)

former_member201110
Active Contributor
0 Kudos

Hi Ana,

That's a very strange error message to get if the UDF is a time format!

The time format UDF actually needs a full datetime value. The DI API will remove the date part and just save the time in the database.

Example to store 1:25pm


// Get today's date (the actual date doesn't matter as it won't be saved)
DateTime myTime = DateTime.Today.Date;
// Add the hours and minutes to the date
myTime = myTime.AddHours(13);
myTime = myTime.AddMinutes(25);
Invoice.UserFields.Fields.Item("U_hrInEnt").Value = myTime;

Kind Regards,

Owen

Former Member
0 Kudos

Hi Owen,

That worked fine! Thank you for your help.

Best regards,

Ana Silva

Answers (0)