• Alex Edelstein 9
  • NEWBIE
  • 5 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
I am working on sending an email with the opportunity files based on certain criteria. I am able to send an email with the 'versionData' as an email body which is queried from 'Contentversion'. 
Problem: When i try to open the attachment from email it says 'Preview not available' and also i am not able to open the downloaded attachment too.
Please find the code below and let me know where I am going wrong. Thanks!
List<id> ContentDocumentids = new List<id>();

for(contentDocumentLink CDLink : [SELECT LinkedEntityid, ContentDocumentid FROM contentDocumentLink WHERE LinkedEntityid=:'Object id'])
                {
                   ContentDocumentids.add(CDLink.ContentDocumentid);  
                }
                for ( ContentVersion cversion : [SELECT title, 
                                                        PathOnClient, 
                                                        versiondata 
                                                  FROM contentversion 
                                                  WHERE ContentDocumentId IN :ContentDocumentids  
                                                   AND title LIKE 'WOCF%'])
                 {
                  blob WOCFbody = cversion.versiondata;
                  system.debug('body : '+WOCFbody+'-----------'+cversion.title);
                  Messaging.Emailfileattachment efa1 = new Messaging.Emailfileattachment();
                  efa.setFileName(war2.opportunity__r.name+'-'+cversion.title);
                  efa.setBody(WOCFbody);
                  fileAttachments.add(efa); 
                 }

 
  • March 14, 2018
  • Like
  • 0
I created a flow with a text input only variable that inserts the current account record ID because later in the process it updates fields on that account record. 

I know how to insert the value of this variable using a button with the following formula: /flow/Flow_Name?AccountID={!Account.Id}&retURL=%2F{!Account.Id} 

Now, instead of using a button, I want to launch this flow using Utility Bar in LEX. I do this by editing Sales Console under Lightning Experience App Manager and under the Utility Bar under Component Properties, there is the option to enter values for flow variables. This is where I can enter the variable I created in the flow (AccountID).
My question is- what do I enter so the Account ID that launches the flow is used? I’ve tried using: {!Record.Id}, {!Account.Id}, ?AccountID={!Account.Id}&retURL=%2F{!Account.Id}, and all sorts of other combinations. Does anyone know if it is possible to pass the record ID into the flow when launching a from the Utility Bar and how?
 
Side note: I know it is possible to pass the Record ID into the flow using a Lightning Component in Lightning Pages. There is a checkbox titled Pass record ID into this variable. So, it looks like it is possible to pass a record ID, but I want to do it from the Utility Bar and not from a Lightning Component in Lightning Pages.

Thank you
Hi All,

I get this error all the time when I try to create an 'ApexClass' from one apex class using metadata:
Web service callout failed: WebService returned a SOAP Fault: INVALID_TYPE: This type of object is not available for this organization faultcode=sf:INVALID_TYPE faultactor=

The code is similar than create an 'ApexPage', although 'ApexPage' works.
So could you help me with this?

Code to create 'ApexClass':
public PageReference mCreateApexClass(){
  MetadataService.MetadataPort service = createService();    
     MetadataService.ApexClass lvApexClass = new MetadataService.ApexClass();
     lvApexClass.apiVersion = 29;
     lvApexClass.fullName = myApexClassName;
     lvApexClass.status = 'Active';
     
     lvApexClass.content = EncodingUtil.base64Encode(Blob.valueOf(myApexClassContentAsString));
     MetadataService.AsyncResult[] results = service.create(new List<MetadataService.Metadata> { lvApexClass });
     result = results[0];
     displayStatus();
     return null;
}

 

Thanks in advance.