Developer Q&A
Multiple documents at Work Order Creation time not uploading
Hi!
When creating a work order with multiple documents none of the documents are being uploaded. The work order appears to be created correctly, a valid response is returned from the call, and the work order number available.
If we only have a single document to upload that does get uploaded.
The code also works if we don't have any documents to upload.
Below is the code we are using to generate the document array and the work order.
// Build document array and return CORRIGO.Document[]
private CORRIGO.Document[] GenerateCorrigoDocumentData(int numDocs)
{
CORRIGO.Document[] imageDocuments = new CORRIGO.Document[numDocs];
for (int i = 0; i < numDocs; i++) {
byte[] barrImg = (Byte[])imageData;
string fileName = "ImageFileName";
imageDocuments[i] =
new CORRIGO.Document {
Description = "Local Upload",
Title = "Image 1",
DocType = new CORRIGO.DocumentType { Id = 3 },
StorageTypeId = CORRIGO.DocumentStorageType.Local,
MimeType = "image/jpg",
Blob = new CORRIGO.Blob { Body = barrImg, FileName = filename, TypeId = '8' },
};
}
return imageDocuments;
}
// Build work order request
var workOrder = new CORRIGO.WorkOrder {
TypeCategory = CORRIGO.WOType.Request,
SubType = new CORRIGO.WorkOrderType { Id = Int32.Parse(StatusCode) },
Customer = new CORRIGO.Customer { Id = customerId },
ContactName = userContactName,
ContactAddress = new CORRIGO.ContactInfo {
AddrTypeId = CORRIGO.ContactAddrType.Contact,
Address = userPhoneNumber,
},
Priority = new CORRIGO.WoPriority { Id = priority },
Items = new[] {
new CORRIGO.WoItem {
Asset = new CORRIGO.Location { Id = assetId },
Task = new CORRIGO.Task { Id = taskId, ModelId = modelId },
Comment = descriptionOfWork,
}
},
Documents = GenerateCorrigoDocumentData(2),
};
// Build WO Create command
var command = new CORRIGO.WoCreateCommand {
WorkOrder = workOrder,
ComputeAssignment = true,
ComputeSchedule = true,
SkipBillToLogic = false,
};
// Execute wo create command
response = corrigoService.Execute(command);
Any help in resolving this would be appreciated - thanks!