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 ?

4 REPLIES 4
Highlighted

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!

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

Solution Partner Experimenter Solution Partner Experimenter
Solution Partner Experimenter

Hi,
I am getting same error, not able to use Property.toDateString(); in SOA java code.
Could you please help me out!
My code is:

Calendar c = Calendar.getInstance();
revisionCreateIn.stringProps.put("a9_EstImpDate",Property.toDateString(c.getTime()));

 

Error :-

 

*****
Partial Errors caught in com.teamcenter.clientx.AppXPartialErrorListener.
Partial Error for client id Create ECN-10000
Code: 515032 Severity: 3 The given date is invalid.
Code: 214200 Severity: 3 Unable to create Business Object.
ztomsw10ccb2.28508.01.georpras.00012: Core-2006-03-DataManagement.createItems
ztomsw10ccb2.28508.01.georpras.00012.01.georpras.00013: Core-2011-06-Session.getTypeDescriptions


Thanks in advance!