cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

DateTime property on Users (via UserExtensions) is not persisting.

jasong
1-Newbie

DateTime property on Users (via UserExtensions) is not persisting.

I am developing on Thingworx 7.0.3

I am having an issue setting DateTime property values on Users from within Java extension package code and having the data persist across Tomcat restarts

Even  in this simple example utilizing a service, the date will not persist over a Tomcat reboot.

However, if I set this value via Composer, it will persist across a Tomcat reboot.

@ThingworxServiceDefinition(name="Test", description ="")

  @ThingworxServiceResult(name="result", description="", baseType="STRING")

  public String Test() throws Exception {

  User usr = EntityTools.GetUser("myUsername");

  usr.setPropertyValue("LastSync", new DatetimePrimitive(DateTime.now()));

  return "finished";

  }

I have also tried setting this via this line, as well, just to see, but with no change.

usr.setPropertyValue(DevicifyConstants.GLOBAL_PROPERTY_LAST_UPDATE_TO_SFDC, new DatetimePrimitive(DateTime.now().getMillis()));

Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
jasong
1-Newbie
(To:jasong)

Sure enough this is a bug, and it is fixed by both 7.2.5 and 7.0.6

View solution in original post

4 REPLIES 4
ankigupta
5-Regular Member
(To:jasong)

Jason Geiger​, Do you see the updated value in composer after running the extension service?

Yes. Everything looks great, until a Tomcat restart.

jasong
1-Newbie
(To:jasong)

More info here, got some time to get back to this. I am beginning to suspect this is a bug so I will put in a case.

I've tried all three constructors for DatetimePrimitive, all accept the date and do not error but tomcat restart looses the data.

The final one, not mentioned above:

DatetimePrimitive dt = new DatetimePrimitive();

dt.setValue(DateTime.now());

usr.setPropertyValue(DevicifyConstants.GLOBAL_PROPERTY_LAST_UPDATE_TO_SFDC, dt);

I have tried initializing DateTime various ways but that is not it either.

I want to test this on 7.2.x to see if it's there but in the meantime I am going to put in a ticket.

jasong
1-Newbie
(To:jasong)

Sure enough this is a bug, and it is fixed by both 7.2.5 and 7.0.6

Top Tags