• VinnieBacon
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies

I thought I had this working but I was going about it all wrong.  The key section of code I'm having trouble with is below.  This works except that I'm trying to grab the full path from the web form and passing it below as the variable 'error_log_file'. 

 

Being new to this type of development, I didn't realize that you can't provide the local path to the browser.  Instead, I'm assuming that the user has to enter this using a standard HTML input where "type=file".  I can code for this but I don't see then how I would provide that file handle to the code below. Can anyone provide some simple examples of how this is done.

 

I'm sure this is pretty basic stuff.  I'm hoping that I'm missing something fairly easy here.  THANKS!!

 

Attachment attachment1 = new Attachment();SObject [] sObjects1 = new SObject[1];

sObjects1[0] = attachment1;

 

if (error_log_l == "yes") {

File f = new File(error_log_file);

try {

InputStream is = new FileInputStream(f);

byte[] inbuff = new byte[(int)f.length()];

is.read(inbuff);

attachment1.setBody(inbuff);

} catch (Exception e){System.out.print(e);

}

attachment1.setName("error.log");attachment1.setParentId(

sess_curr_case_id);

}

I'm getting the following message when trying to do this. 

 

"Unable to create/update fields: BodyLength. Please check the security settings of this field and verify that it is read/write for your profile."

 

I can use the same code to get a caseComment created but it fails for attachments.  The relevant code is below.  I'm pretty new to this so the answer is probably pretty simple.  :smileyhappy:  THANKS!!

 

Attachment attachment = new Attachment();

File f = new File("C:\\test.doc");

try {

InputStream is = new FileInputStream(f);

byte[] inbuff = new byte[(int)f.length()];

is.read(inbuff);

attachment.setBody(inbuff);

attachment.setBodyLength(new Integer(inbuff.length));

} catch (Exception e){ 
System.out.print(e);

}

 

attachment.setName("test.doc");attachment.setParentId(sess_curr_case_id);

 

 

SObject [] sObjects2 = new SObject[1];

sObjects2[0] = attachment;

 

 

try {

SaveResult[] saveResults = myBinding.create(new SObject[] {attachment});

for(int i = 0; i < saveResults.length ;i++) {

if (saveResults[i].isSuccess()) {

success = true;

return success; }
else {
success = false;

System.out.println("Error (2) from createAttachment in AddAttachment!!");

System.out.println(saveResults[0].getErrors(0).getMessage());

return success;

}

}

}
catch (InvalidSObjectFault isof) {

System.out.print(isof.getExceptionMessage());}

catch (RemoteException rex) {

System.out.print(rex.getMessage());

}

 

I'm getting the following message when trying to do this. 

 

"Unable to create/update fields: BodyLength. Please check the security settings of this field and verify that it is read/write for your profile."

 

I can use the same code to get a caseComment created but it fails for attachments.  The relevant code is below.  I'm pretty new to this so the answer is probably pretty simple.  :smileyhappy:  THANKS!!

 

Attachment attachment = new Attachment();

File f = new File("C:\\test.doc");

try {

InputStream is = new FileInputStream(f);

byte[] inbuff = new byte[(int)f.length()];

is.read(inbuff);

attachment.setBody(inbuff);

attachment.setBodyLength(new Integer(inbuff.length));

} catch (Exception e){ 
System.out.print(e);

}

 

attachment.setName("test.doc");attachment.setParentId(sess_curr_case_id);

 

 

SObject [] sObjects2 = new SObject[1];

sObjects2[0] = attachment;

 

 

try {

SaveResult[] saveResults = myBinding.create(new SObject[] {attachment});

for(int i = 0; i < saveResults.length ;i++) {

if (saveResults[i].isSuccess()) {

success = true;

return success; }
else {
success = false;

System.out.println("Error (2) from createAttachment in AddAttachment!!");

System.out.println(saveResults[0].getErrors(0).getMessage());

return success;

}

}

}
catch (InvalidSObjectFault isof) {

System.out.print(isof.getExceptionMessage());}

catch (RemoteException rex) {

System.out.print(rex.getMessage());

}

 

If I assign a Lead to a queue using the API, by assigning its OwnerID to the Id of the queue, no email notification seems to be fired which is annoying. Is this expected behaviour?

 

If I created a lead using the API but instead of assigning its ownerID to a queue, I specified a specific assignment rule, so that the lead is put into the right queue rather than directly, could I expect the email notification then?

 

It would be tedious to have to generate my own notification messages.