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 ...
0
votes
1
answer
415
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, ...
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
14
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
337
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 ...
-1
votes
1
answer
851
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 ...
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
867
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
977
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
437
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
465
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 ...
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 ...
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+'",
&...
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
0
answers
835
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 ...
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 ...
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 ...
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>
...
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 ...
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 ...
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 ...
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
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
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 ...
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 =[...
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
385
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 &&...
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
884
views
how do you upload multiple files into contentversion and relate it to records
I have a legacy code which is uploading document as attachment. I am trying to change them to ContentVersion.
for (case c : ARCases) {
// Do something
Blob pdf = Blob.toPdf(emailbody);
//create ...
4
votes
1
answer
626
views
How to export contentVersion using sfdx force:data:tree:export
I am looking for a way to prepopulate my scratch org with some sample data. As part of this sample data, I need to also create few content version records(images).
But the sfdx force:data:tree:export ...
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
1
answer
4k
views
ContentVersion to File Attachment in Email | APEX [closed]
I am trying to get the Blob Version Data from the ContentVersion in Apex class and send it in an Email using the Following Code:
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();...
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
1
answer
1k
views
Is there a way to read large content version with size greater than 100 MB in chunks?
I'm planning to upload files from content version to other webservice that I don't own, the other service provide resumable API that takes only 320 KB per chunk, so Is there a way to split the blob ...
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
1
answer
1k
views
Merging Docx files into one - Apex
I have a requirement, which I should merge two or more word files (.docx) together into one file.
because I can't do arithmetic operations on Blob - I converted it to hex, made the arithmetic, ...
0
votes
1
answer
237
views
Javascript runtime error on Vf page while using Blob(HTML)data as string
I have a VF page and I want to print it by using javascript code (window.print()) and the reason behind javascript - This page is getting used by other teams and I wanted to print this page only on ...