All Questions
Tagged with contentversion apex
35 questions with no upvoted or accepted answers
5
votes
0
answers
2k
views
ContentPublication Limit exceeded in Unit Test
I have Apex triggers on ContentDocument and ContentDocumentLink Sobject.
I wrote my Apex Unit Tests for those triggers and I was creating more then one Content Data record to test the Logic in Bulk.
...
3
votes
0
answers
74
views
Why doesn't ContentVersion Query doesn't respect OFFSET when you include VersionData?
I have some code where I have to be careful about how much ContentVersion data I load into memory at any particular time to avoid blowing the heap limit.
I was planning to do an initial query on ...
3
votes
0
answers
960
views
Is it possible to download archived contentversion or contentDocument
I am having a hard time downloading a contentversion/contentdocument where contentdocument is already archived.
I am trying to download the file by hitting rest endpoint
services/data/v44.0/...
2
votes
1
answer
1k
views
no preview for ContentVersion when inserting from Apex
I'm using the following code to generate ContentVersion.
String title = 'sample file.txt';
ContentVersion contentVersion = new ContentVersion(
VersionData = Blob.valueOf(...
1
vote
1
answer
498
views
Variable does not exist error while trying to set custom field on ContentVersion record
I'm trying to do something relatively mundane, which is store an offset value for Timezone on a custom field on the ContentVersion object. It seems like no matter what field I reference (including ...
1
vote
0
answers
482
views
Prevent creating new file while uploading new file from Salesforce standard upload button
Whenever a user uploads a new file under a particular record, I need to check for an existing file with the same name. If there is an existing file, then it should not create a new document; instead ...
1
vote
0
answers
3k
views
Sending Files From Salesforce using REST
We have a process in which we need to send a JSON of leads every day to an external system (Not Salesforce).
Until now we just created the JSON with the desired data and sent it via REST.
From time to ...
1
vote
1
answer
5k
views
How to create contentversion by using file url?
We want to create ContentVersion related to the account object. We have one field on account which contains the URL of the file(png/jpg/pdf). And by using that URL we want to create ContentVersion. ...
1
vote
1
answer
389
views
ContentPublication Limit exceeded in Test Class?
Is the content publication limit applicable to test class as well? All i am doing on my test class is to create a contentversion record. It still says that ContentPublication Limit exceeded.
Does ...
1
vote
0
answers
1k
views
Inserting Content Version via Community User in test class Failing
I think this is very straight forward I just can't figure out the issue behind it.
Error:
: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, You do ...
1
vote
1
answer
2k
views
How to upload multiple files to ContentDocumentLink Object in one call from a lightning component?
I want to upload multiple files from a public site to salesforce ContentDocumentLink. How I can create bulk of files on javascript (client) side and handle them from apex?
Lightning Component:
...
1
vote
0
answers
2k
views
ContentVersion trigger event AfterInsert -> Insert ContentDocumentLink -> FIELD_INTEGRITY_EXCEPTION
We need to get a solution / workaround to insert in ContentDocumentLink several links when a File that has just been inserted (ContentVersion) and
sibling records of other Custom Object.
A third ...
1
vote
0
answers
823
views
How to create content version in specific content folder from Apex?
I'm able to create content version and content folder in salesforce files using Apex but can anyone please help me how to create content version in one of content folder .
Thanks
1
vote
2
answers
4k
views
How to have NetworkId (Community Id) logic working in both production and unit tests?
Some existing product code that creates ContentVersion instances is now being called from a community and the code fails with:
INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, You do not have the
level ...
0
votes
0
answers
31
views
Is there a way to "copy" an external file from files connect/external data source using apex/salesforce apis?
Context
We have an app that extends Salesforce Content functionality that creates a custom collaboration and approval process experience.
In the app we've developed a custom component that utilizes ...
0
votes
1
answer
418
views
Salesforce Apex - POST multipart/form-data Content-Type + TEXT
This is the second case that I open regarding this topic to ask more specific questions (the first Using blob variables in apex code)
In the first one they already indicated to me a first solution ...
0
votes
0
answers
69
views
Can't share a file because it's managed by library , How to share a library then?
i want to create a public link for a file , Class :
public void execute(Database.BatchableContext BC, List<Challenge__c> scope) {
Set<Id> testIsd = new Set<Id>();
...
0
votes
1
answer
108
views
SOSL query on ContentVersion not returning consistent results for all users
I need to search for keywords in some files in Salesforce. I am using the following SOSL query for the same:
FIND {search_term} IN ALL FIELDS RETURNING ContentVersion(ContentDocumentId, FileExtension, ...
0
votes
0
answers
59
views
Why does the content version insert fail in a test?
I have a method that
takes a contentVersion where the data is stored locally and
does a callout to transfer it to sharepoint
creates a new ContentVersion with a link to the sharepoint file to replace ...
0
votes
0
answers
466
views
Cannot insert ContentVersion Apex code
Hello I am having problems to create a ContentDocument with Apex code. I am trying to create those records from a partner user community that has some permission set. I get the next error when trying ...
0
votes
1
answer
384
views
File encryption using Crypto in apex
I am trying to encrypt and decrypt file using apex but getting below error while decryption of file. Goal is to encrypt the file in salesforce and send it to third party. Third party should be able to ...
0
votes
1
answer
132
views
Post request with polymorphic field on the body
I am trying to send a post request to ContentVersion to migrate my contentVersions from point A to B :
i build the body like this :
body = ('{"Title" :"'+Title+'",
&...
0
votes
0
answers
836
views
Sending an image as a POST request
I am trying to make a POST request to Eventbrite API to send an image from Salesforce along with other parameters. Under the hood Eventbrite is using Amazon AWS S3 bucket. When I send the request ...
0
votes
0
answers
575
views
The field VersionData not queried in SOQL for ContentVersion sobject
I queried the ContentVersion object by following soql, VersionData field is not retrieved in results.
SELECT Id, Title, VersionData, PathOnClient, ContentSize FROM ContentVersion WHERE Id=<Id>
...
0
votes
0
answers
4k
views
Get Base64 Encoded binary data from file in Apex
I am trying to generate binary data from files in base64 encoded format in Apex. The purpose is to send that resume data to an external system so that they can parse and send it back.
I was able to ...
0
votes
1
answer
141
views
Files visibility while adding them to a library
I am currently trying to figure out one problem connected to Libraries and ContendDocuments.
So I currently have 2 libraries. One library is to store all of the files in the system, while another one ...
0
votes
0
answers
427
views
Need help with a trigger to update custom field based on new ContentNote
I am having an issue getting this trigger to fire. The requirements are that when a new ContentNote is created on the Opportunity record, I need Opportunity.Last_Note__c to update with the Title of ...
0
votes
0
answers
881
views
How to add a new image file into ContentVersion using Apex?
I have a URL which is a PNG file which is hosted on external cloud and I would like to create a new file with this image in my salesforce opportunity object as a file. Could anyone point me on how to ...
0
votes
0
answers
780
views
Transfer Notes and Attachments from One Object to Another
need help figuring our my batch job that moves Notes and Attachments from one object(dsfs__DocuSign_Status__c), to its related Account, then delete the notes and attachments after they are moved. I ...
0
votes
0
answers
143
views
Email notification on ContentVersion object
I am sending an email notification if a field is changed on Content Version object through Apex as we cannot create Workflows/processbuilder on Contentversion object. In my Apex code, I am referring ...
0
votes
0
answers
187
views
Error while inserting a new revision of a file programatically
I am trying to upload a new revision of a file in ContentVersion object programmatically by Apex. I am getting the below error while inserting a new record of ContentVersion.
15:21:52:424 ...
0
votes
1
answer
99
views
Related Files Component
I have a component and apex controller that calls/displays all the related files on a record.
How can I filter the returned files by a field that is set on ContentVersion?
ie. only show files if ...
0
votes
0
answers
686
views
Insert ContentVersion without VisualForce
I've got a CSV file stored on the user's hard drive and I want to store it in Salesforce. The code I have uses Visualforce and Apex to, I think, open up the file and place the contents on a hidden ...
-1
votes
1
answer
852
views
Create a Public Download Link for my Attachment
I have an Object which has attachments and I can access those using ContentDocument and ContentVersions. but when i try to create a download link for the same using ContentDistribution I am able to ...
-1
votes
1
answer
439
views
Batch Import ContentVersion data via the REST endpoint
I am trying to upload a large amount of photos for Salesforce via the /sobjects/ContentVersion REST endpoint. Currently I am able to use this endpoint to upload one photo at a time. Is there a way to ...