Cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot set "Date" type property on Form using SOA API

Phenom
Phenom

I created a custom form using BMIDE and added custom properties of String, int, Date, etc. I am trying to create and update form using SOA API (createOrUpdateForms). Form is created successfully and all properties excepet Date type property can be successfully updated.

 

I get error: "Unable to set value on property x9test_date"

 

I can however set the property in RAC.

 

Anyone has an idea or experience on setting Date properties using SOA ?

3 REPLIES

Re: Cannot set "Date" type property on Form using SOA API

Siemens Phenom Siemens Phenom
Siemens Phenom

I got this from GTAC FAQ:

 

Solution
The following java code will convert a java.util.Calendar object to a string
that is compatible with Teamcenter.

 

public static String CalendarToTcDateString(final Calendar date)
{
	// Following two formats are supported for date string:
	// yyyy-MM-ddThh:mm:sszz:zz 2005-05-20T14:32:05-08:00
	// yyyy-MM-ddThh:mm:ss.SSSzz:zz 2005-05-20T14:32:05.345-08:00
	
	// final String format = "%1$tFT%1$tT"; // without millisecons
	final String format = "%1$tFT%1$tT.%1$tL"; // with milliseconds
	final String timeZone = String.format("%1$tz", date);
	
	return String.format(format + timeZone.substring(0, 3) + ":" + 
timeZone.substring(3), date);
}

Re: Cannot set "Date" type property on Form using SOA API

Phenom
Phenom

Thanks @xtof for your answer. This helped us.

Also apart from this, I got to know SOA API "Property.toXXXString()"  

i.e. for Date type property we can use Property.toDateString() to convert a Date property to TC-recognisable format.

Re: Cannot set "Date" type property on Form using SOA API

Siemens Phenom Siemens Phenom
Siemens Phenom

Thanks for the feedback. Using toDateString() method is much better than writing a own method!