4

I decided to switch to v31.0 metadata, needed to update some code to make it compile, but that's fine. However, now it's not working the way it used to. My code is in C#, it was used to retrieve page layouts and worked just fine. Here it is:

SFDCMetadata.RetrieveRequest rr = new SFDCMetadata.RetrieveRequest();              
            SFDCMetadata.Package package = new SFDCMetadata.Package();
            SFDCMetadata.PackageTypeMembers ptm = new SFDCMetadata.PackageTypeMembers();
            ptm.name = "Layout";
            ptm.members = new string[] { "*" };
            package.types = new SFDCMetadata.PackageTypeMembers[] { ptm };

            rr.singlePackage = true;
            rr.unpackaged = package;

            SFDCMetadata.AsyncResult res = port.retrieve(sh, null, rr);
            Thread.Sleep(1000);
            SFDCMetadata.RetrieveResult retRes = port.checkRetrieveStatus(sh, null, res.id);
            while (!retRes.done)
            {
                retRes = port.checkRetrieveStatus(sh, null, res.id);
                Thread.Sleep(500);
            }
            List<FileInfo> fis = DecompressToFiles(retRes.zipFile, ThisAddIn.TempDirectory, objName);

Now it breaks in a very weird way. It passes the port.retrieve() line, does a couple of iterations inside the while loop (while retRes.done is false), but then just as I expect the retRes.done to turn to true to continue getting the files, I'm getting the following exception: INVALID_LOCATOR: Retrieve result has been deleted

It's like instead of returning the result to me Salesforce just deletes it on the server. Anyone has any idea what's going on?

4

1 Answer 1

0

Taralex, I have seen something similar but not the exact thing. salesforce sometimes returns a result that is not actually XML. So, please first check to see if retRes is not null and has a done element in there before checking its value. I know that the API says it is there but not always true.

By the way, sorry for nitpicking but wouldn't you want to sleep when it is not done and before checking the status again?

Good luck.

Sridhar

1
  • thanks Sridhar! the sleep before checking the status makes more sense of course. I tried checking for null, but it doesn't matter actually, the exception is thrown on the line: SFDCMetadata.RetrieveResult retRes = port.checkRetrieveStatus(sh, null, res.id); And it specifically says that the result has been deleted.
    – taralex
    Commented Jul 24, 2014 at 18:13

Not the answer you're looking for? Browse other questions tagged .