Created
March 18, 2018 20:19
-
-
Save lfreeland/e2774720d9249db3a90f4f326645e1dd to your computer and use it in GitHub Desktop.
Lightning Record Video Viewer Component Apex Controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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