insertItem

This API call inserts a new record into the ExtraView database. All fields are treated as optional, and all defined business rules are executed and checked before and after the record is inserted.

Input

Class Name Type Required Details
InsertItemRequest userId String Yes The callers user name
InsertItemRequest password String Yes The callers password
InsertItemRequest sendEmail boolean Yes
InsertItemRequest itemFields Array[] Yes An array of ItemRecordField objects
ItemRecordField fieldId String Yes
ItemRecordField fieldTitle String Yes
ItemRecordField fieldValue String No
ItemRecordField row int No

Optional parameters for handling document and image files:

Class Name Type Required Details
ItemFileField itemImages Array[] No The array of image files and data
ItemFileField itemDocuments Array[] No The array of document files and data
ItemFileField ddName String No The data dictionary name of the file
ItemFileField fileName String No The target file name to be saved
ItemFileField file String No The file
ItemFileField description String No The description of the file
ItemFileField charset String No The charset of the file
ItemFileField contentType String No The content type – e.g. “image/GIF”
ItemFileField rowId The repeating row Id
ItemFileField rowNumber int No The row number – currently not supported

Output

Class Name Type Required Details
InsertItemResponse success boolean Yes True is succeeded False if failed
InsertItemResponse returnCode String No See Appendix for details
InsertItemResponse returnMessage String No Human readable message
InsertItemResponse itemId String Yes The Id of the insertd item

Note

If you encounter an error inserting large items with this command, the solution is to increase the WSDL package size – for example –

<readerQuotas maxDepth=”2147483647″ maxStringContentLength=”2147483647″ maxArrayLength=”2147483647″ maxBytesPerRead=”2147483647″ maxNameTableCharCount=”2147483647″/>

 In addition, you must increase the maximum size of the POST  request that Tomcat application server will accept.  Please see here for instructions.

Example

public static void testInsertItem(EVItemServiceStub stub) {
try {
InsertItemDocument reqEnvelope = InsertItemDocument.Factory.newInstance();
InsertItemRequest request = reqEnvelope.addNewInsertItem().addNewRequest();
request.setUserId(ServiceClientHelper.ADMIN_USER_ID);
request.setPassword(ServiceClientHelper.ADMIN_PASSWORD);
List items = new ArrayList();
ItemRecordField item = null;
for (int i = 0; i < 4; i++) {
item = ItemRecordField.Factory.newInstance();
item.setRow(0);
// no repeating rows for this example
switch (i) {
case 0:
item.setFieldId("status");
item.setFieldValue("NEW");
break;
case 1:
item.setFieldId("assigned_to");
item.setFieldValue(ServiceClientHelper.generatedUserId);
break;
case 2:
item.setFieldId("short_description");
item.setFieldValue("This is the short desc or title");
break;
case 3:
item.setFieldId("description");
item.setFieldValue("this is the long desc");
break;
default:
item.setFieldId("unknown");
item.setFieldValue("");
break;
}
items.add(item);
}
request.setItemFieldsArray(items.toArray(new ItemRecordField[items.size()]));
request.setSendEmail(false);
InsertItemResponseDocument resEnvelope = stub.insertItem(reqEnvelope);
InsertItemResponse response = resEnvelope.getInsertItemResponse().getReturn();
if (response.getSuccess()) {
System.out.println("success: [" + response.getReturnCode() + "] : " +
response.getReturnMessage());
} else {
System.out.println("failure: [" + response.getReturnCode() + "] : " +
response.getReturnMessage());
}
} catch (Exception e) {
e.printStackTrace();
System.err.println("\n\n\n");
}
}

Example 2 – Handling Document & Image Fields

public static void testInsertItem(EVItemServiceStub stub) {
try {
File imageFile = new File("./test.GIF");
DataInputStream dis = new DataInputStream(new FileInputStream(imageFile));
BufferedReader br = new BufferedReader(new InputStreamReader(dis));
List bFileList = new ArrayList();
try {
byte b;
while (true) {
b = dis.readByte();
bFileList.add(b);
}
} catch (Exception e) { /* handle the EOF the lazy way. */
}
byte[] fileBytes = new byte[bFileList.size()];
for (int i = 0; i items = new ArrayList(); ItemRecordField item = null;
for (int i = 0; i < 4; i++) {
item = ItemRecordField.Factory.newInstance();
item.setRow(0);
// no repeating rows for this example
switch (i) {
case 0:
item.setFieldId("status");
item.setFieldValue("NEW");
break;
case 1:
item.setFieldId("assigned_to");
item.setFieldValue(ServiceClientHelper.generatedUserId);
break;
case 2:
item.setFieldId("SHORT_DESCR");
item.setFieldValue("This is the short desc or title");
break;
case 3:
item.setFieldId("DESCRIPTION");
item.setFieldValue("this is the long desc");
break;
default:
item.setFieldId("unknown");
item.setFieldValue("");
break;
}
items.add(item);
}
request.setItemFieldsArray(items.toArray(new ItemRecordField[items.size()]));
request.setSendEmail(false);
List itemDocumentFields = new ArrayList();
ItemFileField document = ItemFileField.Factory.newInstance();
document.setCharset("UTF-8"); document.setContentType("image/gif");
document.setDescription("This is a test image file in a document field!");
document.setFile(fileBytes); document.setDdName("DOCUMENT");
document.setFileName(imageFile.getName()); itemDocumentFields.add(document);
request.setItemDocumentsArray(itemDocumentFields.toArray(new
ItemFileField[itemDocumentFields.size()]));
InsertItemResponseDocument resEnvelope = stub.insertItem(reqEnvelope);
InsertItemResponse response = resEnvelope.getInsertItemResponse().getReturn();
if (response.getSuccess()) {
System.out.println("success: [" + response.getReturnCode() + "] : " +
response.getReturnMessage());
System.out.println("Item [" + response.getItemId() + "] was created.");
CREATED_Item_ID = response.getItemId();
} else {
System.out.println("failure: [" + response.getReturnCode() + "] : " +
response.getReturnMessage());
}
} catch (Exception e) {
e.printStackTrace();
System.err.println("\n\n\n");
}
}
public static void testUpdateItem(EVItemServiceStub stub) {
try {
File imageFile = new File("./test.GIF");
DataInputStream dis = new DataInputStream(new FileInputStream(imageFile));
BufferedReader br = new BufferedReader(new InputStreamReader(dis));
List bFileList = new ArrayList();
try {
byte b;
while (true) {
b = dis.readByte();
bFileList.add(b);
}
} catch (Exception e) { /* handle the EOF the lazy way. */
}
byte[] fileBytes = new byte[bFileList.size()];
for (int i = 0; i
items = new ArrayList();
ItemRecordField item = ItemRecordField.Factory.newInstance(); item.setRow(0);
// no repeating rows for this example
item.setFieldId("SHORT_DESCR");
item.setFieldValue("This is the short desc or title -- changed!");
items.add(item);
request.setItemFieldsArray(items.toArray(new ItemRecordField[items.size()]));
request.setSendEmail(false);
List itemImageFields = new ArrayList();
ItemFileField image = ItemFileField.Factory.newInstance();
image.setCharset("UTF-8");
image.setContentType("image/gif");
image.setDescription("This is a test image file in a image field!");
image.setFile(fileBytes);
image.setDdName("IMAGE");
image.setFileName(imageFile.getName());
itemImageFields.add(image);
request.setItemImagesArray(itemImageFields.toArray(new
ItemFileField[itemImageFields.size()]));
UpdateItemResponseDocument resEnvelope = stub.updateItem(reqEnvelope);
UpdateItemResponse response =
resEnvelope.getUpdateItemResponse().getReturn();
if (response.getSuccess()) {
System.out.println("success: [" + response.getReturnCode() + "] : " +
response.getReturnMessage());
System.out.println("Item [" + response.getItemId() + "] was changed.");
CREATED_Item_ID = response.getItemId();
} else {
System.out.println("failure: [" + response.getReturnCode() + "] : " +
response.getReturnMessage());
}
} catch (Exception e) {
e.printStackTrace();
System.err.println("\n\n\n");
}
}