Skip to content

Instantly share code, notes, and snippets.

@lfreeland
Created March 18, 2018 20:19
Show Gist options
  • Select an option

  • Save lfreeland/e2774720d9249db3a90f4f326645e1dd to your computer and use it in GitHub Desktop.

Select an option

Save lfreeland/e2774720d9249db3a90f4f326645e1dd to your computer and use it in GitHub Desktop.
Lightning Record Video Viewer Component Apex Controller
public with sharing class RecordVideoViewerController {
@AuraEnabled
public static String getVideoURL(Id recordId, String videoField) {
Schema.SObjectType objectType = recordId.getSobjectType();
String objectName = objectType.getDescribe().getName();
String videoSOQL = 'SELECT ' + videoField +
' FROM ' + objectName +
' WHERE Id = :recordId';
SObject record = Database.query(videoSOQL);
String videoSrcURL = (String) record.get(videoField);
return videoSrcURL;
}
}
@douglascayers

Copy link
Copy Markdown

Consider escaping the string input fields in the query to avoid SOQL injection:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_security_tips_soql_injection.htm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment