thanks for your response. I tried to create TWObject with no TypeName like you said above. My log statements show below error on BAW server logs.
Original Message:
Sent: Fri March 15, 2024 04:47 PM
From: Ajay Katre
Subject: TWObjectfactory createObject and versioning Context
Madhuri,
Executing the code outside BAW will work if the object factory does not need to reference the specific type. You can do this by creating a generic TW object instance. Then set the properties by passing in name-value pair(s) through the setPropertyValue() method.
For example, Let's say we have a BO in BAW called ParentObj which contains three properties: parentId (Integer), description (String), and childObj (a complex type with properties: myObjId (Integer), and theCode (String)). Then, the parent object could be set in the Java code like so:
TWObject aChildTWObj = TWObjectFactory.createObject(); // Notice that typeName is not passed in
aChildTWObj.setPropertyValue("myObjId", 12345);
aChildTWObj.setPropertyValue("theCode", "XYZ_CODE");
TWObject aComplexTWObj = TWObjectFactory.createObject(); // Notice that typeName is not passed in
aComplexTWObj.setPropertyValue("parentId", 67890); // an integer
aComplexTWObj.setPropertyValue("description", "This object contains other object(s)"); // a string
aComplexTWObj.setPropertyValue("childObj", aChildTWObj); // value of a property can be another TWObject
You should be able to execute such a code in your choice of Java IDE/SDK that has psclnt.jar and svrcoreclnt.jar in the path.
If all the properties that you set in Java code exactly match the BAW BO definition, then you can assign it (through data mapping) to the corresponding type just as you would've when creating the TWObject by providing the typeName.
Let us know how it goes.
------------------------------
Ajay Katre
Salient Process
Original Message:
Sent: Fri March 15, 2024 04:16 PM
From: Madhuri Kulkarni
Subject: TWObjectfactory createObject and versioning Context
Hi Ajay,
I am using it in Java project and have included both pciInt.jar and svccoreInt.jar in classpath.
------------------------------
Madhuri Kulkarni
Original Message:
Sent: Fri March 15, 2024 03:17 PM
From: Ajay Katre
Subject: TWObjectfactory createObject and versioning Context
Hi Madhuri,
Where are you executing the code? Are you executing it within BAW or outside (in an IDE or external JRE)? The code needs to know where to look for the object type that you are trying to instantiate.
Think of VersioningContext as a reference to your branch and snapshot. If it isn't explicitly specified, then it will default to the current thread's context, meaning current branch and snapshot. That can be the tip in process center server - your dev environment. All this is available when the code executes on the BAW server (process center or runtime).
------------------------------
Ajay Katre
Salient Process
Original Message:
Sent: Fri March 15, 2024 01:48 PM
From: Madhuri Kulkarni
Subject: TWObjectfactory createObject and versioning Context
When instatiation TWObject using TWObjectFactory.createObject(String objectName) method,
I get exception java.lang.IllegalArgumentException: versioningContext must be specified
at teamworks.TWObjectFactory.createObject(TWObjectFactory.java:87)
at teamworks.TWObjectFactory.createObject(TWObjectFactory.java:67)
I tried to search documentation but could not get any answer. Anyone experienced this issue?
BAW version: 21.0.3.1