• Peter Boelke
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
Hello,

i need a quick action button to export contact data as csv. I have created a visualforce page which is related to a quick action button. But it doesnt really work proper.
In Classis it shows the cvs-data on the page. In Lightning is just start the download of the file. I want to start the download only if the quick action button is clicked. How can i achiev this?

VF-Page
<apex:page standardController="Task" extensions="CtrlContactExport" contenttype="application/vnd.ms-excel#Export_Contacts.csv">RNAME1;RNAME2;RSTREET;RHHOUSENO;RPOSTAL;RCOUNTRY;RPHONE;REMAIL
    <apex:repeat value="{!list_contacts}" var="c" >
"{!c.Name}";"{!c.Salutation}";"{!c.MailingStreet}";"{!c.MailingStreet}";"{!c.MailingPostalCode}";"{!c.MailingCountry}";"{!c.Phone}";"{!c.Email}"
    </apex:repeat>
</apex:page>
Controller
public class CtrlContactExport {
    
    public list<Contact> list_contacts {get;set;}
    
    public CtrlContactExport (ApexPages.StandardController controller){

        exportContacts();
        
    }
    
    public Pagereference exportContacts(){
        list_contacts = [SELECT Name, Salutation, MailingStreet, MailingPostalCode, MailingCity, MailingCountry, Phone, Email FROM Contact];
        return new Pagereference('');
        
    }
 
}

Thanks for advice
Peter
 
Hello,

i try to "convert" an attachement to a ContentVersion and link it to a related opportunity. Converting works but linking does not!
ia m getting this error message:
FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, You cannot create a link for this type of entity through the api: Linked Entity ID: [LinkedEntityId]

My code is:
trigger TrgAttachment on Attachment (after insert) {
    System.debug('TRG ' + Trigger.New[0]);
    Attachment att = Trigger.New[0];
    //Task t = Trigger.New[0];    
    System.debug('TYPE ' + att.ParentId.getSobjectType());
    Task t = [SELECT Subject, WhatId FROM Task WHERE id=:att.ParentId][0];
    
    System.debug('ATT ' + att);
    if(t.WhatId <> NULL && t.WhatId.getSobjectType() == opportunity.getSObjectType()){

        Opportunity o = [SELECT Id, Name FROM Opportunity WHERE id=:t.WhatId][0];
        System.debug('Related to opps' + o);
        
        ContentVersion cv = new ContentVersion();
        cv.ContentLocation = 'S';
        cv.PathOnClient = att.Name;
        cv.Origin = 'H';
        cv.OwnerId = att.OwnerId;
        cv.Title = att.Name;
        cv.VersionData = att.Body;
        insert cv;
        
        ContentVersion cv1 = [select Id, ContentDocumentId from ContentVersion where Id =: cv.Id][0];
        Id linkDoc = o.Id;
        ContentDocumentLink cl = new ContentDocumentLink();
        cl.LinkedEntityId = linkDoc;
        cl.ContentDocumentId = cv1.ContentDocumentId;
        cl.ShareType = 'V';
        try{
            insert cl;
        }
        catch(Exception ex){
            throw ex;
        }

        
    }
}
Can someone help?

thanks
Peter
 
Hello,
i have problem. We want to have privileged Community User (not PLUS) which should create a specific type of contacts. <- that works
But there a have also a trigger which should create Community User from that contact after insert

Objects involved:
Contact
Event__c
Event_Attendee__c (Junctionobject between Contacts and Event__c)

Everything runs fine with Admin user and Standard User (exended with read/write/edit permissions on required Object. But it doesnt for Community User.

What the matter? Are Community PLUS licenses required to create new Community Users?

regards
Peter


 
Hello,

i need a quick action button to export contact data as csv. I have created a visualforce page which is related to a quick action button. But it doesnt really work proper.
In Classis it shows the cvs-data on the page. In Lightning is just start the download of the file. I want to start the download only if the quick action button is clicked. How can i achiev this?

VF-Page
<apex:page standardController="Task" extensions="CtrlContactExport" contenttype="application/vnd.ms-excel#Export_Contacts.csv">RNAME1;RNAME2;RSTREET;RHHOUSENO;RPOSTAL;RCOUNTRY;RPHONE;REMAIL
    <apex:repeat value="{!list_contacts}" var="c" >
"{!c.Name}";"{!c.Salutation}";"{!c.MailingStreet}";"{!c.MailingStreet}";"{!c.MailingPostalCode}";"{!c.MailingCountry}";"{!c.Phone}";"{!c.Email}"
    </apex:repeat>
</apex:page>
Controller
public class CtrlContactExport {
    
    public list<Contact> list_contacts {get;set;}
    
    public CtrlContactExport (ApexPages.StandardController controller){

        exportContacts();
        
    }
    
    public Pagereference exportContacts(){
        list_contacts = [SELECT Name, Salutation, MailingStreet, MailingPostalCode, MailingCity, MailingCountry, Phone, Email FROM Contact];
        return new Pagereference('');
        
    }
 
}

Thanks for advice
Peter
 
Hello,

i try to "convert" an attachement to a ContentVersion and link it to a related opportunity. Converting works but linking does not!
ia m getting this error message:
FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, You cannot create a link for this type of entity through the api: Linked Entity ID: [LinkedEntityId]

My code is:
trigger TrgAttachment on Attachment (after insert) {
    System.debug('TRG ' + Trigger.New[0]);
    Attachment att = Trigger.New[0];
    //Task t = Trigger.New[0];    
    System.debug('TYPE ' + att.ParentId.getSobjectType());
    Task t = [SELECT Subject, WhatId FROM Task WHERE id=:att.ParentId][0];
    
    System.debug('ATT ' + att);
    if(t.WhatId <> NULL && t.WhatId.getSobjectType() == opportunity.getSObjectType()){

        Opportunity o = [SELECT Id, Name FROM Opportunity WHERE id=:t.WhatId][0];
        System.debug('Related to opps' + o);
        
        ContentVersion cv = new ContentVersion();
        cv.ContentLocation = 'S';
        cv.PathOnClient = att.Name;
        cv.Origin = 'H';
        cv.OwnerId = att.OwnerId;
        cv.Title = att.Name;
        cv.VersionData = att.Body;
        insert cv;
        
        ContentVersion cv1 = [select Id, ContentDocumentId from ContentVersion where Id =: cv.Id][0];
        Id linkDoc = o.Id;
        ContentDocumentLink cl = new ContentDocumentLink();
        cl.LinkedEntityId = linkDoc;
        cl.ContentDocumentId = cv1.ContentDocumentId;
        cl.ShareType = 'V';
        try{
            insert cl;
        }
        catch(Exception ex){
            throw ex;
        }

        
    }
}
Can someone help?

thanks
Peter