function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pawanpawan 

Error with Notes & Attachments

In my application, I can get a list of task, event, account etc.. ID's properly with function similar to the one below, However, I am not getting any ID's back from my query calls for notes and attachments.  This used to work properly in 1.9 but not in 2.0.  Please help.

-Pawan

public bool GetOpNoteIDs(string opportunityID, out ArrayList noteIDs)
{

Console.WriteLine("Getting list of Note ID's with Opportunity ID " + opportunityID + "...");

object
[] filter = new object[1]; //Final filter array
filter[0] = MakeSimpleFilter("parentID", opportunityID, "equals");

System.Collections.ArrayList SelectList = new System.Collections.ArrayList();
SelectList.Add("id");

return ReturnQueryList("note", filter, (string[])SelectList.ToArray(typeof(string)), out noteIDs);

}

DevAngelDevAngel

Hi Pawan,

You sample raises more questions than possible answers.  I've found the best place to start when doing service orienented development debugging is with the messages be sent and recieved.  Post the SOAP request and we'll see if there is a clue there.

I don't have any idead what's happing in your ReturnQueryList function.  Are you getting a fault back?  A runtime error?

Please note, all query calls in 2.0 require the "scope" parameter.  I assume that you are setting that in your query list wrapper, but, it is just an assumption.  Also, try setting the ifModifiedSince parameter to a date in the 80's.  I may have uncovered a problem with that particular field and you may be seeing it in this context.

 

pawanpawan

Sorry for the bad formatting.  I don't know how to print the SOAP request but here is the code for the ReturnQueryList function.  The response is not an error but the rootNode.InnerText.Length = 0, so it returns false.

private bool ReturnQueryList(string type, object [] filter, string[] SelectList, out ArrayList retList)

{

object[] ret;

retList = new ArrayList();

try

{

ret = (object[]) sForce.query("filter", type, macro.SFORCE_MAX_QUERY_ROWS, SelectList, filter, null, new System.DateTime(1950, 1, 1), false);

}

catch(System.Web.Services.Protocols.SoapHeaderException ex)

{

//This is typical error handling for fault detection and reporting, the .Net Proxy client actually throws an

//error rather than return the fault SOAP Message.

System.Diagnostics.Trace.WriteLine("The server returned the following fault information:");

System.Diagnostics.Trace.WriteLine("Fault Code: " + ((System.Xml.XmlQualifiedName)((System.Web.Services.Protocols.SoapException)ex).Code).Name);

System.Diagnostics.Trace.WriteLine("Fault string: " + ex.Message);

return false;

}

try

{

int i = 1;

int j;

System.Xml.XmlElement rootNode = (System.Xml.XmlElement)ret[0];

if (rootNode.InnerText.Length > 0)

{

System.Xml.XmlNodeList children = rootNode.SelectNodes("valueMap");

//The processing below is typical for the responses returned by the SOAP API

foreach(System.Xml.XmlNode valueNode in children)

{

//Look for XmlElements

for(j=SelectList.GetLowerBound(0);j<=SelectList.GetUpperBound(0);j++)

{

try

{

System.Xml.XmlNode textNode = valueNode.SelectSingleNode(SelectList[j]);

if (textNode == null)

retList.Add(null);

else

retList.Add(textNode.InnerText);

}

catch (Exception ex)

{

System.Diagnostics.Trace.WriteLine(ex.Message);

}

}

i++;

}

return true;

}

else

{

return false;

}

}

catch(System.Exception ex)

{

System.Diagnostics.Trace.WriteLine("Unexpected error: " + ex.Message);

retList=null;

return false;

}

}

DevAngelDevAngel

Hi Pawan,

Thanks for the clarification, but I really need to see the message. 

Are you familiar with SoapExtensionAttributes in .Net?  I am attaching a C# class that allows you to log all inbound and outbound messages.  Just add this class to your project and make the following change to the query stub in the Reference.cs file.  You can name the log file anything you want, I've shown it as query.txt.  This will create a file on the root of your c-drive that contains the requests and replies for the query call only.  You can do this for any of the calls by adding the SoapExtensionAttribute SoapLogger.SoapLogger to any of the other calls.

There is an msdn article on this here http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconalteringsoapmessageusingsoapextensions.asp.

[System.Web.Services.Protocols.SoapHeaderAttribute("headerStructValue")]

[System.Web.Services.Protocols.SoapRpcMethodAttribute("sfconnector:SalesforceConnector#query", RequestNamespace="sfconnector:SalesforceConnector", ResponseNamespace="sfconnector:SalesforceConnector"), SoapLogger.SoapLogger("query.txt")]

[return: System.Xml.Serialization.SoapElementAttribute("return")]

public object query(string scope, string type, int maxRows, object[] select, object[] filter, string[] idList, System.DateTime ifModifiedSince, bool useCaseSafeIDs) {

....

}

 

 

pawanpawan

I have uploaded the SOAP request and response for all notes in a opportunity at

http://web.mit.edu/~pawan/www/note.txt

If it doesn't display correctly, please use view-source.

Also how do you attach files in the forum?

DevAngelDevAngel

Hi Pawan,

The request looks good and does not cause a fault.  Are you absolutely certain that the parentID is for an existing opportunity?  Please verify this by logging into the app and inspecting the url on the detail for the opportunity (https://na1-api.salesforce.com/00630000000h47k).

Currently, file attachments are only available to administrators.

 

pawanpawan

Please see for a screenshot:

http://web.mit.edu/~pawan/www/sshot.JPG

Notice red highlighted areas, the link to the note in the status bar has the correct opportunity id.  I also get the same error for attachments.

DevAngelDevAngel

Hi Pawan,

Looks like a sharing issue.  If the notes are maked private by the opportunity owner and you login as a different use in your org with the API, you will not be able to view the notes.  This means that you search will come up empty.  Verify that you can view the notes when you login using the same username as you are using for the API.

pawanpawan

That's not it, I am not using multiple accounts and I am using the same user as I use to access the API.  Also it is not private.

Here is a screenshot.

http://web.mit.edu/~pawan/www/sshot2.JPG

-Pawan