All Questions
Tagged with contentversion apex
136 questions
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 ...
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
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 ...
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
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:
...
0
votes
2
answers
3k
views
content version - clone from one object to another
I am trying to clone File(s) from a parent object to child. The code I am using is doing that but the file type is set to "LINK" while doing so, and I am unable to open that file or it has nothing ...
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
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
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>();
...
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 ...
0
votes
0
answers
15
views
Capture EXIF Data in Salesforce and Delete [duplicate]
IS there a way to capture data on image(EXIF data) while an user tries to upload a image file into chatter and delete the data on the image file?
0
votes
1
answer
338
views
Accessing ContentVersion file data from Lightning web component
We are trying to build a zip download feature for documents.
The zip can contain files stored in ContentVersions and external files.
It works fine for external files.
But due to CORS, we cannot access ...
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
2
answers
1k
views
Not getting any records from ContentVersion in Salesforce SOQ query which we are not owner of
When I am creating a new record (release), I would like to get a file off a related record (inventory) and then create a copy of it on the release.
The problem I am facing, is that this only works if ...
0
votes
0
answers
22
views
How to sent ContentVersion's VersionData through API? [duplicate]
I am trying to send a pdf file attached to a record of custom object to an external system. I am using ContentDocumentLink and ContentVersion to get the file in apex and make a api call. File is ...
0
votes
1
answer
82
views
DistributionPublicUrl String length limit
Can anyone know what is the DistributionPublicUrl in ContentDistribution object String length limit in Salesforce ? I was trying to create an DistributionPublic URL whenever a new file is created or ...
-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 ...
7
votes
1
answer
18k
views
How can I set the ContentVersion.FileType when creating new File via Apex?
I'm working on a webservice to create new Salesforce Files. To validate the underlying methods, I manually uploaded a PNG file, which shows up in the file preview in Files.
I can retrieve the ...
-1
votes
1
answer
869
views
Unable to access ContentVersion.VersionDataURL field
In the documentation of ContentVersion object, VersionDataURL field is mentioned. But when I'm trying to query the same in an Apex class, it is throwing an error saying -
Error : No such column '...
0
votes
2
answers
981
views
What is the order of execution in content related objects?
I have a scenario to insert the content document link for sharing the contentdocument with contentworkspace (library) when the contentdocument is created.
I want to write a trigger to achieve this.
I ...
-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 ...
1
vote
1
answer
416
views
How to convert a JSON string stored in a Content Document back to a Map and merge it with a Map of similar type? [duplicate]
I have a Map of type -
Map<String, List<List<LineInfo>>> valuesMapOne = new Map<String, List<List<LineInfo>>>();
This Map is serialized and saved into a ...
0
votes
1
answer
610
views
Trigger for Content Version (SNOTE) before Insert
I need to prevent ALL Users from creating a new Enhanced Note (we ended up creating our own object because we needed more customization). I'm trying to write a trigger but am getting stuck on an ...
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 ...
2
votes
1
answer
1k
views
File corrupted on sending data to create file via workbench using REST API
I am trying to create a file in in salesforce via workbench. The file is getting created although the file is corrupted. I feel there is some issue in binary data. What I am doing to get the binary ...
1
vote
3
answers
2k
views
upload a file in VF page to content Version is broken
I have a huge and complex vf page (force.com site) - So I will try to explain my issue with an example instead publish here all the code - I hope it will be understanble:
I want to upload a file from ...
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 ...
3
votes
2
answers
2k
views
How to get Salesforce content files base URL via Apex?
As per this salesforce help document, the content files base URL is different compare to the salesforce org domain URL.
The domain URL formats with or without enhanced domains are as follows
//with ...
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 ...
2
votes
1
answer
2k
views
What controls ContentVersion access in non-sharing apex class?
I recently wrote an apex class which queries the ContentVersion records for a lead and embeds them in a PDF page. The class is not running with Sharing, so system access, and everything is working in ...
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 ...
2
votes
2
answers
1k
views
Is there any way to get or edit the metadata in images posted to salesforce?
Is there a way through apex or using the VersionData of the ContentVersion for me to change that EXIF data of a ContentVersion image so that it won't register as needing to rotate?
To be more ...
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 ...
3
votes
1
answer
923
views
How to find enhanced domains enabled in salesforce org via apex? [duplicate]
I am looking for ways to find out whether salesforce org is enabled with enhanced domains or not via apex.
As per this document, the content (files) domain is different in each case. And dynamically ...
3
votes
1
answer
7k
views
File is uploaded in the private library or public library
I have written a triger (before insert) on ContentVersion object and I am checking that the user is going to upload the file in private library or public library.
According to my findings which I got ...
4
votes
2
answers
7k
views
ContentVersion file not viewable to Guest Site User
I have Salesforce Files associated with a Contact that I'd like to pluck out the ContentVersion Id in order to display the image on a public-facing Visualforce page (via Sites):
<!-- This is ...
0
votes
1
answer
2k
views
How do I convert a ContentVersion record to JSON to pass via API?
I need to share files attached to an account externally via API to another Salesforce org (to recreate the files there).
In order to do this I'm trying to create a JSON file to contain the file/s ...
-2
votes
1
answer
239
views
How we can convert contentVersion Title to string ,i am getting some type casting error [closed]
Please help me where i am writing wrong.
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 ...
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
1
answer
774
views
APEX Class invoked by flow to delete Content Documents, get DML exception on delete "ENTITY_IS_DELETED
I have made this simple class to assist a flow to delete content documents, it is working just fine in my apex tests but when I invoke it from a flow I get the following error message: 13:35:33:092 ...
-1
votes
1
answer
3k
views
Get Id of Files record
Is it possible to get the ID of a file that has been attached using Files. Below is a picture and when hovering over the download link, it display the id.
As seen above, the id of the attached image ...
0
votes
1
answer
82
views
How to run the code when the parameter was passed
I am facing the problem that I cannot run the code because there are no triggers to run it.
I need the pdf file to be previewed in the module window. Tried through conectedCallback and wire, it didn't ...
0
votes
1
answer
2k
views
System.StringException Invalid Id [closed]
I'm getting this error in APEX class which converts CSV file into records. I'm sorry for bad editing of this question but I turned problem liner into quotes.
Example of the data that causes the error:
...
1
vote
1
answer
803
views
I have used Multipart/message but still i got the error as heap size limit too large. I'm able to send below 2MB file
I have used Multipart/message to send Large size of file from Salesforce to External system. but still I got the error as heap size limit too large, I'm able to send below 2MB file.
Source Org
public ...
0
votes
1
answer
7k
views
While Inserting a ContentVersion through Apex i'm not able to get the Image of the File [closed]
Target Org Code
@RestResource(urlMapping='/getContentVersions/*')
global with sharing class ShareFileRest {
@HttpPost
global static String getFileToStore() {
RestRequest req = RestContext.request;...
1
vote
1
answer
2k
views
How we can read Content Version body and update in Long rich text area field of an object?
I have file attached (Word Document) to the custom object record . I want read the file and get the content between some text and store it in the Custom object record field
apex:
ContentVersion con =[...
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
1
answer
3k
views
Update OwnerId of ContentDocument from Apex class
I need to update OwnerId of ContentDocument in my Apex class.For thati am updating it like this:
if(!participantDocumentsOwnerId.isEmpty() && participantDocumentsOwnerId.size() > 0 &&...