Adds a record to your knowledgebase data and reads the result.
EWWSBaseUserObject o = ew.EWCreateAndRead(String sessionId, String table, EWWSBaseUserObject object) or for the table-specific call: WSCase case = ew.EWCreateAndRead_WSCase(String sessionId, WSCase object) |
Use EWCreateAndRead to add records to the tables, such as Support Case or People, in your knowledgebase and read the result in one call, potentially retrieving values for the fields set by business rules and other back-end logic.
The EWCreateAndRead call is analogous to an INSERT statement in SQL immediately followed by SELECT.
When creating records, consider the following rules and guidelines:
Fields that are imported into the table from another table as a part of a Linked Fields set have to be filled via special linking classes.
In WSDL a Linked Fields set takes form of DAO_Dao3_Link<N> field in the complex data structure that corresponds to the target table, where N is a sequential number assigned automatically at the time of the set creation, e.g. WSCase.DAO_Dao3_Link3.
As a value such fields can take one or more WS<Table1><Table2>_Dao3_Link<N> data structures - linking classes, where Table1 is the target table and Table2 is the donor table of the Linked Fields relationship, e.g. WSCaseTeams_Dao3_Link3.
Unfortunately, at this moment one has to rely on investigating the actual sets of fields inside the classes to trace the fields, visible in the Field wizard in the GUI, back to the main object property.
Non-source values for Linked Field sets that allow them are present directly in the table itself additionally to those in the Linking Classes, if the link was in fact forged.
To forge a link the client has to create one or more instances of the linking class and select one of 3 options:
See examples of all of the above in the sample code below.
If any of the query mechanisms are used to identify the related records, one has to take into account if the relationship allows multiple records to be linked. If the query returns multiple results and the relationship doesn't allow multiple records to be linked an EWOperationException is thrown.
The values for choice columns should be supplied as instance(s) of the enumerated types described in the WSDL.
The original text values have undergone the following transformations:
One has to perform the reverse transformation to get to the text value.
Related tables and embedded search results are not supported by the SOAP interface.
Creating records involves the following basic steps:
In MyKB knowledgebase as user A create a case describing a lost present, with High priority, linked to contact #125, owned by a Support Person and assigned to the Support Team. Return the value from "date_created" field.
The task is completed by performing the following steps:
public Date create() { EWServiceAPI binding = new EWServiceAPIServiceLocator().getMyKB(); try { String sessionId = binding.EWLogin("MyKB", "A", "password", "en"); WSCase wsCase = new WSCase(); wsCase.setSummary("A case of a lost present"); wsCase.setProblem_description("People keep losing things"+ +" bought for their dearest."); WSCaseContacts_Dao3_Link5 contact = new WSCaseContacts_Dao3_Link5(); contact.setId(125L); // forge link by specifying the identifier wsCase.setDAO_Dao3_Link5(contact); WSCaseTeams_Dao3_Link3 assignedTo = new WSCaseTeams_Dao3_Link3(); assignedTo.setAssigned_To("Support Team"); //forge link by QBE wsCase.setDAO_Dao3_Link3(assignedTo); wsCase.setPriority(WSChoice_Priority.OPTION_HIGH); WSCaseContacts_Dao3_Link7 ownedBy = new WSCaseContacts_Dao3_Link7(); ownedBy.setSearchSQL("full_name='Support Person'"); //link by SQL wsCase.setDAO_Dao3_Link7(ownedBy); wsCase.setType("case"); WSCase wsCase = (WSCase) binding.EWCreateAndRead(sessionId, "case", wsCase); return wsCase.getDate_Created(); } finally { binding.EWLogout(sessionId); } } |
You can generate sample a Web Services code for any table by selecting Setup > Tables > [Edit Table] > API > Download Sample.
Name | Type | Description |
---|---|---|
sessionId | String | Session token |
tableName | String | The name of the table where the record is to be created (only for generic methods). |
obj | EWWSBaseUserObject or a specific descendent like WSCase or WSContact for table-specific calls. | The descendant of EWWSBaseUserObject - one of the complex types described in the WSDL that correspond to the tables on the side |
The record data as a descendant of EWWSBaseUserObject - a complex structure described in WSDL.
EWSessionException - client not logged in or the session has expired; client should re-login.
EWPermissionException - username used to create the session lacks sufficient privileges to perform the record modification.
EWWrongDataException - client has supplied the wrong data.
EWOperationException - creation operation has been blocked by one of functionalities.
EWIntegrityException - specified table cannot be found or its primary key cannot be identified.
EWUnexpectedException - an unexpected exception has happened; user should report this for investigation.
Related articles |