Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <aura:component controller="openfile" implements="forceCommunity:availableForAllPageTypes">
- <aura:attribute name="currentContentDocumentId" type="String" default="06928000005l5I4AAI"/>
- <p>{!v.currentContentDocumentId}</p>
- <ui:outputURL aura:id="url" click="{!c.openSingleFile}" label="Click here"
- value="{!v.currentContentDocumentId}"/>
- </aura:component>
- //JS controller
- ({
- openSingleFile : function (component,event){
- alert('hihih');
- var action = component.get("c.openfile1");
- var fireEvent = $A.get("e.lightning:openFiles");
- action.setCallback(this,function(actionResult) {
- //alert('inisde');
- //alert(actionResult.getReturnValue());
- var state = actionResult.getState();
- var id=actionResult.getReturnValue();
- alert(id);
- if (component.isValid() && state == "SUCCESS"){
- alert(state);
- component.set("v.currentContentDocumentId",actionResult.getReturnValue());
- }
- });
- $A.enqueueAction(action);
- fireEvent.fire({
- recordIds: [id]
- });
- },
- });
- //Server side controller
- public with sharing class openfile{
- @AuraEnabled
- Public static id openfile1(){
- system.debug('hihi');
- ContentVersion Cvid=[SELECT ContentDocumentId FROM ContentVersion where ContentDocumentId='06928000005l5I4AAI'];
- system.debug(Cvid.ContentDocumentId);
- return Cvid.ContentDocumentId;
- }
- }
- <aura:component implements="flexipage:availableForAllPageTypes">
- <aura:handler name="init" value="{!this}" action="{!c.openSingleFile}" />
- </aura:component>
- ({
- openSingleFile : function (component,event){
- var fireEvent = $A.get("e.lightning:openFiles");
- fireEvent.fire({
- recordIds: ["069500000033oBoAAI"]
- });
- }
- });
Add Comment
Please, Sign In to add comment