1

So far I'm successfully uploading a test document to Salesforce. An ID is being returned with no errors.

However, I can't see the uploaded files through Salesforce itself when I view the object referred to by the ParentId field.

Why doesn't the file appear under 'Files' when viewing the Account set as the ParentId? How can I do this?

The only way I can find the document is by manually entering the returned ID into the URL in my browser.

Here are the parameters being passed with JSON and cURL:

$data = file_get_contents($_FILES['file']['tmp_name']);
$base64Data = base64_encode($data);

$params = array(
        'Name' => $_FILES['file']['name'],
        'Description' => $_POST['description'],
        'ParentId' => $_POST['salesforceID'],
        'Body' => $base64Data,
    );

$result = create_sobject("Attachment", $params, $instance_url, $access_token);
// this uses the appropriate generic JSON/cURL code to make an API request

I'm thinking my understanding of the Salesforce frontend may be the issue, since I'm new to Salesforce rather than PHP/cURL. I've got create requests to various other parts of the API working fine

  • 1
    Please share code you are using for this – Mohith Shrivastava Jul 11 '16 at 11:23
  • I've added some, but I'm doubtful it'll be of much use since the underlying code does create an attachment object. I just can't seem to find it in the Salesforce Frontend when looking at the parent Account object, or find it anywhere else – Solflux Jul 11 '16 at 11:36
  • So you are creating notes and attachment record .See under notes and attachment for parent record to discover the file – Mohith Shrivastava Jul 11 '16 at 11:38
1

Currently you are inserting into "Notes and Attachments" .Notes and Attachments are separate related list than salesforce Files.

If you want to insert record into salesforce Files ,you will need to insert record into contentversion object and also create a content document link record of type "v" to appear under files .

  • I had a feeling it was more my lack of understanding of Salesforce and it's workings. Seems a little odd there's no "Files" endpoint in the API to handle this for you, but ah well. I think I'll just make sure the 'Files and Attachments' section is visible to the Salesforce users. Thank you! – Solflux Jul 11 '16 at 12:05
0

You don't have the parent object access permission. So, You couldn't access the parent object. only way to access attachment with that attachment Id. https://{salesforceinstance}.salesforce.com/{attchmentId} or View the attachment. https://{salesforceinstance}.content.force.com/servlet/servlet.FileDownload?file={attachmentId}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.