This post details how you can access Salesforce Files in a Skuid page. I’m using Millau 11.0.3 in this post.
My requirement was to display a list of files (via a Deck) related to an opportunity. Here’s how I did it.
Firstly I created a model based on the ContentDocumentLink object. Querying this object retrieves the file ids related to the opportunity. I created a condition based on the field LinkedEntityId, which I filled with Opportunity Id.
Then I created a second model based on the ContentDocument object. This model then fed the Deck component with the fields I wanted to display (Title, Size, Type etc). The model had a condition set against the Id field (set to multiple specified values as there may be multiple files per opportunity).
I populated the condition’s values and querying of the models in the required sequence via a series of actions (against an opportunity list in a table, which shows a popup containing further details of the opportunity along with related objects such as the files).
One other thing, because my model based on the ContentDocument object had a multiple specified values condition, I created a JS snippet to grab the Ids from the model based on the ContentDocumentLink object and pass these into the condition. The snippet can be found below.
Hope this helps.
Matt
var params = arguments[0],
$ = skuid.$;
var SourceModel = skuid.$M(‘DocumentLinking’);
var selectedIds = ;
//Build the array of linked document Ids, based on the values from the DocumentLinking model
$.each(SourceModel.data,function(i,row){
selectedIds.push(row.ContentDocumentId);
});
//Filter the ContentDocument model to get the files, but only if there are links
if (selectedIds.length >= 1)
{
var TargetModel = skuid.$M(‘ContentDocument’);
var ConIdsCondition = TargetModel.getConditionByName(‘DocIds’);
TargetModel.setCondition(ConIdsCondition,selectedIds);
TargetModel.updateData();
}
Getting a list of Salesforce Files
This topic has been closed for replies.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
