• Sascha Deinert
  • NEWBIE
  • 260 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 107
    Questions
  • 135
    Replies
Hello,
 
I can't get the LinkedEntityId form ContentDocumentLink because the record is not created if the trigger fires. I tried to add Trigger.isAfter but the contentdocumentlink is still not created.
 
How can I solve it?
 
The goal is to check if the new uploaded document is related to sobject Mediathek__c.
 
trigger ContentDocumentMediathek on ContentDocument (after insert) {  
    if (Trigger.isAfter) {
        for (ContentDocument objCD : trigger.new) {        
            ContentDocument newCD = Trigger.newMap.get(objCD.Id);                            
            for (ContentDocumentLink cdl : [SELECT LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId = :newCD.Id]) { 
                System.debug('cdl.LinkedEntityId: ' +cdl.LinkedEntityId);        
                If(cdl.LinkedEntityId.getSObjectType() == Mediathek__c.SObjectType) { system.debug('super');}
            }
        }
    }
}

Thanks,
Sascha




 
Hello,

I have two different lists. A list of opportunities and a list of sales (Umsatz__c), the accountid appears in both lists. How can I merge these lists into one finallist at account level?

list
CLASS
public class VTPv1 {       
    Public List<AggregateResult> OppGroup {get; set;}
    Public List<AggregateResult> SalesGroup {get; set;}
    
    public VTPv1() {          
        OppGroup    = [SELECT Account.Name AccName, Sum(ExpectedRevenue) Rev, Sum(Amount) Fin FROM Opportunity WHERE OwnerId = '005b0000001UAm4AAG' AND CloseDate = THIS_YEAR AND (IsClosed = false OR IsWon = true) GROUP BY Account.Name];
        SalesGroup  = [SELECT Einzelrisiko__r.Gruppenvertrag__r.Unternehmen__r.Name AccName, Sum(BWS_Brutto__c) BWS FROM Umsatz__c WHERE Berater__r.Id = '005b0000001UAm4AAG' AND Bewertungsmonat__c = THIS_YEAR GROUP BY Einzelrisiko__r.Gruppenvertrag__r.Unternehmen__r.Name];          
    }
}
VISUALFORCE PAGE
<apex:page controller="VTPv1">        
    <apex:pageBlock title="Opportunities Group">
        <apex:pageBlockTable value="{!OppGroup}" var="oppg">  
            <apex:column value="{!oppg['AccName']}">
                <apex:facet name="header">Account Name</apex:facet>
            </apex:column>
            <apex:column value="{!oppg['Rev']}">
                <apex:facet name="header">Expected Revenue</apex:facet>
            </apex:column>
            <apex:column value="{!oppg['Fin']}">
                <apex:facet name="header">Amount</apex:facet>
            </apex:column>             
        </apex:pageBlockTable> 
    </apex:pageBlock>           
    <br/>           
    <apex:pageBlock title="Sales Group">
        <apex:pageBlockTable value="{!SalesGroup}" var="salesg">  
            <apex:column value="{!salesg['AccName']}">
                <apex:facet name="header">Account Name</apex:facet>          
            </apex:column>
            <apex:column value="{!salesg['BWS']}">
                <apex:facet name="header">Sales</apex:facet>          
            </apex:column>
        </apex:pageBlockTable> 
    </apex:pageBlock>                
</apex:page>
Thanks,
Sascha


 
Hello,

I need to export a list of records to an excel XLSX file. I found a good way to export data via lightning component, but the export extension is csv. Is there a way to change it into xslx extension?

https://www.sfdc-lightning.com/2019/10/export-to-csv-in-lightning-component.html

Thanks,
Sascha
Hi,

I need to export contact data which are related to the current user into an excel file. This works fine, but now I need the export only for a time range which the user can set at the visual force page. How can I pass the dates (from/to) from the visual force to the apex class?

It is possible to export the data in xlsx format? Currently it is xls format.
 
APEX CLASS

public with sharing class ExportToExcel {

    public List<Contact> contactlist{get;set;}        
    public Id currentUserId { get; set;}  
    public Date datefrom {get;set;}   
    public Date dateto {get;set;}
    
    public String xlsHeader {
        get {
            String strHeader = '';
            strHeader += '<?xml version="1.0"?>';
            strHeader += '<?mso-application progid="Excel.Sheet"?>';
            return strHeader;
        }
    }
    
    public ExportToExcel(){
        
        currentUserId = UserInfo.getUserId();      
        If(datefrom != Null && dateto != Null) {
        Map<Id, Event> relatedEventCon = new Map<Id, Event>([select whoId from Event where activitydate >= :datefrom and activitydate <= :dateto and subject = 'BookingTime AN Termin' and owner.id = :currentUserId]); 
        Set<Id> eventidsset = new Set<Id>();
        for(event relation:relatedEventCon.values()){
            eventidsset.add(relation.whoid);
        }
        contactlist = [select Salutation, Firstname, Lastname, Birthdate, E_Mail_privat__c, Mobiltelefon_privat__c, Account.Name from Contact where Id IN :eventidsset];
        }
    }
    
    
    public Pagereference exportAll(){
        Date datefrom = datefrom;
        Date dateto = dateto;
        
        return new Pagereference('/apex/beratertag3out');      
    }
    
}
VISUAL FORCE PAGE to set the date range (ExportToExcel)

<apex:page controller="ExportToExcel" docType="html-5.0" id="vfpage">
    <apex:form >
        
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:pageBlockSectionItem >
                    date from: <apex:input type="date" value="{!datefrom}"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    date to: <apex:input type="date" value="{!dateto}"/>
                </apex:pageBlockSectionItem>            
            </apex:pageBlockSection>
        </apex:pageBlock>
        
        <apex:pageBlock title="Contacts">            
            <apex:pageBlockButtons >
                <apex:commandbutton value="Export contacts to Excel" action="{!exportAll}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
VISUAL FORCE PAGE to convert data into excel file (berater3out)

<apex:page controller="ExportToExcel" contentType="txt/xml#myTest.xls" cache="true">  
    <apex:pageBlock > 
        <apex:pageBlockTable value="{!contactlist}" var="con">
            <apex:column value="{!con.Salutation}" headerValue="Anrede"/>
            <apex:column value="{!con.Firstname}" headerValue="Vorname" />
            <apex:column value="{!con.Lastname}" headerValue="Nachname" />
            <apex:column value="{!con.Birthdate}" headerValue="Geburtsdatum" />
            <apex:column value="{!con.E_Mail_privat__c}" headerValue="E-Mail-Adresse" />
            <apex:column value="{!con.Mobiltelefon_privat__c}" headerValue="Telefonnummer" />
            <apex:column value="{!con.Account.Name}" headerValue="Firma" />    
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

Thanks,
Sascha



 
Hello, 

I would like to insert a picture depending on the type at my visualforce page.
My code below does n't work, could you help me please.
 
<span class="slds-icon_container" style="background-color: #49648C;">
   <svg aria-hidden="true" class="slds-icon slds-icon_small">
      <use xlink:href="{!IF(wl.objectlabel = 'Event', {!URLFOR($Asset.SLDS, 'assets/icons/standard-sprite/svg/symbols.svg#event')}, 
                         IF(wl.objectlabel = 'Task',  {!URLFOR($Asset.SLDS, 'assets/icons/standard-sprite/svg/symbols.svg#task')},
                         ''))
                       }" />
      </svg>
   </span>

Thanks,
Sascha
Hello,

I need to query all related task of the current contact. But If I run my code below I get always an error: Invalid bind expression type of TaskRelation for Id field of SObject Task

What is wrong? :-(
 
List<Taskrelation> RelatedTaskIds = [select taskId from taskrelation where relationid = :currentRecordId];                
for(Task a: [select Id, Subject, CreatedDate, Createdby.Name, Owner.Name, RecordType.Name, Status, Who.Name, Who.Id, What.Name from Task where Id In :RelatedTaskIds]) {
    wrapperList.add(new Wrapper(a, 'Task'));
}

Thanks,
Sascha
Hello,

If I add the component to my visualfoce page the buttons doesn't work. If I run the component alone it works.

VISUALFORCE PAGE
<apex:page >
    <apex:includeLightning />
    <div id="Con" />
    <script>
        $Lightning.use("c:buttontest_app", function() {
            $Lightning.createComponent(
                "c:buttontest",
                {},
                "Con",
                function(cmp) {
                    console.log("Component is created!");
                    console.log(cmp);
                });
            });        
      </script>
</apex:page>

COMPONENT APP
<aura:application access="GLOBAL" extends="ltng:outApp" >
    <aura:dependency resource="c:buttontest"/>
</aura:application>

COMPONENT
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global">
    
    <lightning:quickActionAPI aura:id="quickActionAPI" />
    
    <aura:attribute name="buttonLabel1" type="String" default="new Event"/>
    <aura:attribute name="objectName1" type="String" default="Contact"/>
    <aura:attribute name="actionName1" type="String" default="new_Event"/>
    <aura:attribute name="variantType1" type="String" default="brand" />
    <aura:attribute name="isButton1" type="Boolean" default="true" />
    
    <aura:attribute name="buttonLabel2" type="String" default="new Task" />
    <aura:attribute name="objectName2" type="String" default="Contact"/>
    <aura:attribute name="actionName2" type="String" default="new_Task" />
    <aura:attribute name="variantType2" type="String" default="brand" />
    <aura:attribute name="isButton2" type="Boolean" default="true" />

    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <lightning:card>
        <div class="{!'slds-size_' + v.containerSize + '-of-12 slds-form-element'}">
            <div class="container">
                <lightning:layout multipleRows="true">
                    <lightning:layoutItem size="{!v.setSize}" padding="around-small">
                        <aura:if isTrue="{!v.isButton1}">
                            <lightning:button class="{!v.buttonClass}" variant="{!v.variantType1}" label="{!v.buttonLabel1}" onclick="{!c.selectAction1}" />
                        </aura:if>
                    </lightning:layoutItem>
                    <lightning:layoutItem size="{!v.setSize}" padding="around-small">
                        <aura:if isTrue="{!v.isButton2}">
                            <lightning:button class="{!v.buttonClass}" variant="{!v.variantType2}" label="{!v.buttonLabel2}" onclick="{!c.selectAction2}" />
                        </aura:if>
                    </lightning:layoutItem>
                </lightning:layout>
            </div>
        </div>
    </lightning:card>
    
</aura:component>

COMPONENT CONTROLLER
({
    doInit: function (component, event, helper) {
        console.log('Label 1: [' + component.get("v.buttonLabel1") + ']');
        if (component.get("v.buttonLabel1"))
            component.set("v.isButton1", true);
        console.log('Label 2: [' + component.get("v.buttonLabel2") + ']');
        if (component.get("v.buttonLabel2"))
            component.set("v.isButton2", true);
        var calcCount = 12 / parseInt(component.get("v.buttonCount"),10);
        component.set("v.setSize", calcCount);
        if (component.get("v.buttonSize").toLowerCase() == 'full')
            component.set("v.buttonClass", 'slds-size_full');
    },

    selectAction1 : function( component, event, helper) {
        var actionAPI = component.find("quickActionAPI");
        var quickAction = component.get("v.objectName1")+"."+component.get("v.actionName1");
        console.log(quickAction);
        var args = {actionName: quickAction, entityName: component.get("v.objectName1")};
        actionAPI.selectAction(args).then(function(result) {
            var fields = result.targetableFields;
            console.log(fields);            
        }).catch(function(e){
            if(e.errors){
                console.log(e);
            }
        });
    },

    selectAction2 : function( component, event, helper) {
        var actionAPI = component.find("quickActionAPI");
        var quickAction = component.get("v.objectName2")+"."+component.get("v.actionName2");
        console.log(quickAction);
        var args = {actionName: quickAction, entityName: component.get("v.objectName2")};
        actionAPI.selectAction(args).then(function(result) {
            var fields = result.targetableFields;
            console.log(fields);            
        }).catch(function(e){
            if(e.errors){
                console.log(e);
            }
        });
    },

})

Thanks,
Sascha
 
Hello, 

I create a button at the account record to create a PDF. That works good, but now I want to pass information from the account record into my visual force. I tried it, see below, but the (example accid) account id does not appear at the pdf.

APEX CLASS
public class attachPDFToAccount2 {

private Id accId {get; set;}
Public List<Account> AccList {get; set;}
public String AName {get; set;}

public attachPDFToAccount2() {
    accId = ApexPages.currentPage().getParameters().get('id');
    AccList = [SELECT Name FROM Account WHERE Unternehmens_Id_Long__c = :accId]; 
    FOR (Account Acc : AccList) {
        AName = Acc.Name;
    }
}

public final Account a;

public attachPDFToAccount2(ApexPages.StandardController standardPageController) {
    a = (Account)standardPageController.getRecord(); 
}

public PageReference attachPDF() {
    
    PageReference pdfPage2 = Page.pdfpage2; 
    pdfPage2.getParameters().put('id', accId);
    Blob pdfBlob; 
    if (!Test.isRunningTest()) { 
       pdfBlob = pdfPage2.getContent(); 
     } else { 
     pdfBlob = Blob.valueOf('...');
     }

    Attachment attach = new Attachment(parentId = a.Id, Name = 'pdffile.pdf', body = pdfBlob); 
    insert attach;
    
    PageReference pageWhereWeWantToGo = new ApexPages.StandardController(a).view();
    pageWhereWeWantToGo.setRedirect(true); 
    return pageWhereWeWantToGo; 
}

}

ACTION PAGE
<apex:page action="{!attachPDF}" extensions="attachPDFToAccount2" standardController="Account">
    <apex:pageMessages ></apex:pageMessages>
    <apex:detail inlineEdit="true" relatedList="true"></apex:detail>
</apex:page>

RENDER PAGE
<apex:page renderAs="pdf" controller="attachPDFToAccount2">
<apex:stylesheet value="{!$Resource.pdfStyle}"/>
<center>
    <h1>Visualforce PDF Sample - {!accId}</h1>
</center>
<table align="center" style="border: 1px solid #6699CC;">
    <tr>
        <td style="background-color: #6699CC; color: #FFFFFF; font-size: 200%; padding: 10px;">NOTES</td>
        <td>
            <ul>
                <li>TEST</li>
            </ul>
        </td>
    </tr>
</table>
</apex:page>

​​​​​​Thanks,
Sascha
 
Hi,

In setup under Deliverability I checked the box "Activate bounce management" and "Return bounced emails to sender". found information that there should be another checkbox "show bounce alert next to all instances of the email address", but this checkbox is not available. I created a new customfield to store the emailaddress and I run a flow to send emails to the customer. I tested to send an email to undeliverable address but salesforce doesn't show the bounced information, but the logfile shows the error. Is that setting just working for the standard email field?

Thanks,
Sascha
Hi,

I add an email handler service to my org. I store some information from the plainTextBody in fields of the object bt__c (Firstname, Phone....), this works so far. But now I want to store each row in a separate field which the code can't assign. Or can I remove the row which can be assigned to field from the plainTextBody and at the end should store the plainTextBody in one separate field.

Because the mail contains information that I cannot assign to any specific field. For this reason I want to store the rest of the mail in seperate field. Or can I store each row which cannot assign to any specific field in a variable which I can insert into a field? 

I tried to remove the row from the variable emailBodyRows.remove[i] but it doesn't work.
 
if(email.plainTextBody != Null && email.plainTextBody != '') {
        String[] emailBodyRows = email.plainTextBody.split('\n');           
        Set<String> fieldimport = new Set<String>{'Firstname', 'Phone'};
             FOR (Integer i = 0; i < emailBodyRows.size(); i++) {
                 FOR (String fi : fieldimport) {                  
                     IF (emailBodyRows[i].contains(fi)) {
                         String fieldName = fi + '__c';
                         c.put(fieldName, emailBodyRows[i].substringAfter(fi));
                    }
                 }
             }                         
    }
            
  try {
    insert c;   
      
    Note note = new Note();    
        note.Title = email.subject + ' - ' + email.fromName + ' - ' + DateTime.now();
        note.Body = email.plainTextBody;
        note.ParentId = c.Id;
    insert note;
              
  } catch (System.exception e) {
    System.debug(e.getMessage() + e.getStackTraceString());  // assume things may not work, and you'll want details as to why.
  }      
  return result;
}

}
Thanks,
Sascha
 
Hi,

I add a inbound email handler into my org to add a new record in a custom object (bt).

Sometime the mails are not processed and I don't know why. Is there a way to check the incoming mails in Salesforce?

can I enter a line in the code where the process should begin and end? Because sometimes is some text before or after the relevant points.
 
global class btFromEmail implements Messaging.InboundEmailHandler {
    
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
    Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
    bt__c C = new bt__c(); 
        if(email.plainTextBody != Null && email.plainTextBody != '') {
            String[] emailBodyRows = email.plainTextBody.split('\n');
            for (String bodyRow:emailBodyRows) {
                String[] rowContents = bodyRow.split(':');
                String label = rowContents[0].trim();
                String value = rowContents[1].trim();
                switch on label {
                    when 'Firstname' {
                        c.Firstname__c = value;
                    }
                    when 'Lastname' {
                        c.Lastname__c = value;
                    }                 
                    when 'Birthdate' {
                         c.Birthdate__c = date.valueOf(value);
                    }                   
                    when 'Phone' {  
                        c.Phone_private__c = value;
                    }              
                    when 'Email' {        
                        c.E_mail_private__c = value;                                        
                    }                            
                }            
            }
        }
      insert c;             
      return result;
  }
    
}
Thanks,
Sascha
 
Hello,

could I add a (command)button on visualforce like a quick action at the record page? 
Because I created a flow and I created a action button and I want to run this from a visualforce page.

new account
create_account2

Thanks,
Sascha
Hi,

how can I add to my visualforce an inputfield with the possibility to change the formatting - text like bold or to change the color ....?  

Like this -->
html

Thanks,
Sascha
Hello, 

I have a very simple trigger which is working fine in the sandbox but it doesn't work in the production. If someone change the owner of the opportunity or add a new opportunity the customfield team__c should be filled with the owner team value. But if I change the owner the field keep blank. If I change the team field at the opportunity manuelly and then I change the owner then becomes the field also blank.
 
trigger setTeamOpportunity on Opportunity (before update) {

 for(Opportunity o : trigger.new) { 
     Opportunity oldOpportunity = trigger.OldMap.get(o.ID);
         if(o.ownerid != oldOpportunity.ownerid) {
                    o.Team__c = o.Owner.Team__c;
         }
     }
}
Can someone help me please.

Thanks,
Sascha
Hi,

I have two maps and I want to merge this maps into one list, key should be the account. My goal is an overview of the accounts with the opportunities.
How can I merge these lists?
 
public map<Id, Account> getMapFieldLabel1() {
    Map<Id, Account> mapField_Label1= new Map<Id, Account>([SELECT Id, Name FROM Account LIMIT 10]);
    return mapField_Label1;
}

public map<Id, Opportunity> getMapFieldLabel2() {
    Map<Id, Opportunity> mapField_Label2= new Map<Id, Opportunity>([SELECT Id, Account.Id, Name FROM Opportunity]);
    return mapField_Label2;
}
<apex:pageBlockSection columns="2" collapsible="false">              
            <apex:repeat value="{!MapFieldLabel1}" var="item" >
                  <apex:outputText value="{!MapFieldLabel1[item].Id}" />
                   <apex:outputText value="{!MapFieldLabel1[item].Name}" />
            </apex:repeat>   
            </apex:pageBlockSection>
 </apex:pageblock>
 <br/><br/>
 <apex:pageblock>
  <apex:pageBlockSection columns="3" collapsible="false">              
            <apex:repeat value="{!MapFieldLabel2}" var="item" >
                  <apex:outputText value="{!MapFieldLabel2[item].Account.Id}" />
                  <apex:outputText value="{!MapFieldLabel2[item].Id}" />
                   <apex:outputText value="{!MapFieldLabel2[item].Name}" />
            </apex:repeat>   
            </apex:pageBlockSection>
 </apex:pageblock>
Thanks,
Sascha

 
Hi,

I need for our sales colleagues to a list of responsible accounts for sales planning. I can do that quickly with a report, but I need this list enriched with additional information. For example sales last year (sales object), sales current year (sales object), current planning (object opportunity).

Can I build a report that displays the cumulative values ​​of these objects?
If not, how can I solve this via a visualforce site?
 
AccountSales Last YearSales Current YearOpportunity Amount
ABC5.00020.00050.000
DEF10.0005.00025.000
GHI01.5000


Thanks,
Sascha
Hi,

I've tried to add two aggregate results in one list, but I don't know if its correct because I don't know how can I show the results at the visualforce page.

Just for testing....
What is my plan, I want to count the number of accounts grouped by account Id, this make no sense but for the test its ok and on the other hand I want to count the number of sales and the sum of the sales grouped by account Id. The both aggregate results should be maped into one list.

Could you tell me is my code correct and how can I display the results?
 
Public Class VTP32_class {

    public String CombinedSummary { get; set; }

Public VTP32_class() {

}

Public class CombinedSummary {
    public Integer CountAcc {get; set;}
    public Id UId {get; set;} 
    public Integer CountSales {get; set;}
    public Double Brutto_BWS {get; set;}  
    
Public CombinedSummary (AggregateResult arM, AggregateResult arS) {
    CountAcc = (Integer) arM.get('CountAcc');
    UID = (Id) arS.get('Id');
    CountSales = (Integer) arS.get('CountSales');
    Brutto_BWS = (Double) arS.get('Brutto_BWS');
    }
}

Public List<CombinedSummary> generateWrappers() {
        Map<Id, AggregateResult> AccMap = new Map<Id, AggregateResult>();
        Map<Id, AggregateResult> AccSales = new Map <Id, AggregateResult>();

        List<CombinedSummary> combinedSummaries = new List<CombinedSummary>();
      
        FOR(AggregateResult arM: [SELECT COUNT(OwnerId) CountAcc, Id FROM Account GROUP BY Id]) {
            AccMap.put((Id)arM.get('Id'), arM);
        }
       
        FOR(AggregateResult arS: [SELECT COUNT(Id) CountSales, SUM(BWS_Brutto__c) Brutto_BWS, Einzelrisiko__r.Gruppenvertrag__r.Unternehmen__r.Id FROM Umsatz__c GROUP BY Einzelrisiko__r.Gruppenvertrag__r.Unternehmen__r.Id]) {
            AccSales.put((Id)arS.get('Einzelrisiko__r.Gruppenvertrag__r.Unternehmen__r.Id'), arS);
        }
            
        Set<Id> AccSet = new Set<Id>();
        AccSet = AccSales.keySet();
        AccSet.addAll(AccSales.keySet());
        
        FOR (Id Id : AccSet) {
            combinedSummaries.add(new CombinedSummary(AccMap.get(Id), AccSales.get(Id)));
        }
        
        Return combinedSummaries;
    
}

}
Thanks,
Sascha
Hello,

I need a overview like a table of all accounts and additional the sum of sales 2017, sum of current sales, sum of opportunities.
How can I to this?

Accountname | Sales 2017 | Sales 2018 | Opps 
----------------------------------------------------------------------
ABC               |        15.000 |          2.000 |       20.000
XYZ               |                 0 |        10.000 |       50.000

Thanks,
Sascha
 
Hello,

I have a list with contract numbers which are displayed in a visualforce page, the user could select the numbers which he will need for the analysis. The user should check the checkbox from the contract (multiple choices possible), how can I transport the checked contracts to the nextpage or anlayze?
 
public class Contract_class {

private Id accId {get; set;}

public Contract_class() {
accId = ApexPages.currentPage().getParameters().get('id');

}

public List<Contract__c> getContracts() {
    List<Contract__c> Contracts = [SELECT Name FROM Contract__c WHERE Account_ID_Long__c = :accId];
    RETURN Contracts;
}

public PageReference nextPage () {    
        
    return new PageReference('/apex/Contract_next?id='+accid);   
  
} 

}
<apex:page controller="Contract_class">

<apex:form >

<apex:repeat value="{!Contracts}" var="con">
<apex:inputCheckbox value="{!con.Name}" selected="true" />
<apex:outputField value="{!con.Name}" />
</apex:repeat>

<table>
    <tr>
        <td>
            <apex:commandbutton value="analyze" action="{!nextPage}" />
        </td>
    </tr>
</table>

</apex:form>

</apex:page>
Thanks,
Sascha

 
Hi,

I have some question about the Lightning Design System.
Below you will find a screen and the code for this screen. 

Can I put the text closer to the left border?
Can I change the backgroundcolor from the Header or the marked item?
Can I change the margin between the different items?

Pic1
 
<apex:page standardStylesheets="false" docType="html-5.0">
    
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" lang="en">

<apex:slds /> 
    
<div class="slds-scope">
 
<div class="Navigation" style="width: 180px;">
<nav class="slds-nav-vertical slds-nav-vertical_compact" aria-label="Sub page">
<div class="slds-nav-vertical__section">
    <h2 id="entity-header" class="slds-nav-vertical__title slds-text-title_caps"><b>Header 1</b></h2>
<ul>   
    <li class="slds-nav-vertical__item"><a href="" target="_parent" class="slds-nav-vertical__action" aria-describedby="entity-header">Test 1</a></li>
    <li class="slds-nav-vertical__item"><a href="" target="_parent" class="slds-nav-vertical__action" aria-describedby="entity-header">Test 2</a></li>
    <li class="slds-nav-vertical__item"><a href="" target="_parent" class="slds-nav-vertical__action" aria-describedby="entity-header">Test 3</a></li>
</ul>
</div>
    
<div class="slds-nav-vertical__section">
    <h2 id="folder-header" class="slds-nav-vertical__title slds-text-title_caps"><b>Header 2</b></h2>
<ul>
    <li class="slds-nav-vertical__item"><a href="" target="_parent" class="slds-nav-vertical__action" aria-describedby="folder-header">Test 1</a></li>
    <li class="slds-nav-vertical__item"><a href="" target="_parent" class="slds-nav-vertical__action" aria-describedby="folder-header">Test 2</a></li>
</ul>
</div>
    
</nav>
    
</div>
        
</div> <!-- ENDE SLDS-SCOPE -->

</html>
    
</apex:page>
Thanks,
Sascha
Hello,

I need to query all related task of the current contact. But If I run my code below I get always an error: Invalid bind expression type of TaskRelation for Id field of SObject Task

What is wrong? :-(
 
List<Taskrelation> RelatedTaskIds = [select taskId from taskrelation where relationid = :currentRecordId];                
for(Task a: [select Id, Subject, CreatedDate, Createdby.Name, Owner.Name, RecordType.Name, Status, Who.Name, Who.Id, What.Name from Task where Id In :RelatedTaskIds]) {
    wrapperList.add(new Wrapper(a, 'Task'));
}

Thanks,
Sascha
Hello,

If I add the component to my visualfoce page the buttons doesn't work. If I run the component alone it works.

VISUALFORCE PAGE
<apex:page >
    <apex:includeLightning />
    <div id="Con" />
    <script>
        $Lightning.use("c:buttontest_app", function() {
            $Lightning.createComponent(
                "c:buttontest",
                {},
                "Con",
                function(cmp) {
                    console.log("Component is created!");
                    console.log(cmp);
                });
            });        
      </script>
</apex:page>

COMPONENT APP
<aura:application access="GLOBAL" extends="ltng:outApp" >
    <aura:dependency resource="c:buttontest"/>
</aura:application>

COMPONENT
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global">
    
    <lightning:quickActionAPI aura:id="quickActionAPI" />
    
    <aura:attribute name="buttonLabel1" type="String" default="new Event"/>
    <aura:attribute name="objectName1" type="String" default="Contact"/>
    <aura:attribute name="actionName1" type="String" default="new_Event"/>
    <aura:attribute name="variantType1" type="String" default="brand" />
    <aura:attribute name="isButton1" type="Boolean" default="true" />
    
    <aura:attribute name="buttonLabel2" type="String" default="new Task" />
    <aura:attribute name="objectName2" type="String" default="Contact"/>
    <aura:attribute name="actionName2" type="String" default="new_Task" />
    <aura:attribute name="variantType2" type="String" default="brand" />
    <aura:attribute name="isButton2" type="Boolean" default="true" />

    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <lightning:card>
        <div class="{!'slds-size_' + v.containerSize + '-of-12 slds-form-element'}">
            <div class="container">
                <lightning:layout multipleRows="true">
                    <lightning:layoutItem size="{!v.setSize}" padding="around-small">
                        <aura:if isTrue="{!v.isButton1}">
                            <lightning:button class="{!v.buttonClass}" variant="{!v.variantType1}" label="{!v.buttonLabel1}" onclick="{!c.selectAction1}" />
                        </aura:if>
                    </lightning:layoutItem>
                    <lightning:layoutItem size="{!v.setSize}" padding="around-small">
                        <aura:if isTrue="{!v.isButton2}">
                            <lightning:button class="{!v.buttonClass}" variant="{!v.variantType2}" label="{!v.buttonLabel2}" onclick="{!c.selectAction2}" />
                        </aura:if>
                    </lightning:layoutItem>
                </lightning:layout>
            </div>
        </div>
    </lightning:card>
    
</aura:component>

COMPONENT CONTROLLER
({
    doInit: function (component, event, helper) {
        console.log('Label 1: [' + component.get("v.buttonLabel1") + ']');
        if (component.get("v.buttonLabel1"))
            component.set("v.isButton1", true);
        console.log('Label 2: [' + component.get("v.buttonLabel2") + ']');
        if (component.get("v.buttonLabel2"))
            component.set("v.isButton2", true);
        var calcCount = 12 / parseInt(component.get("v.buttonCount"),10);
        component.set("v.setSize", calcCount);
        if (component.get("v.buttonSize").toLowerCase() == 'full')
            component.set("v.buttonClass", 'slds-size_full');
    },

    selectAction1 : function( component, event, helper) {
        var actionAPI = component.find("quickActionAPI");
        var quickAction = component.get("v.objectName1")+"."+component.get("v.actionName1");
        console.log(quickAction);
        var args = {actionName: quickAction, entityName: component.get("v.objectName1")};
        actionAPI.selectAction(args).then(function(result) {
            var fields = result.targetableFields;
            console.log(fields);            
        }).catch(function(e){
            if(e.errors){
                console.log(e);
            }
        });
    },

    selectAction2 : function( component, event, helper) {
        var actionAPI = component.find("quickActionAPI");
        var quickAction = component.get("v.objectName2")+"."+component.get("v.actionName2");
        console.log(quickAction);
        var args = {actionName: quickAction, entityName: component.get("v.objectName2")};
        actionAPI.selectAction(args).then(function(result) {
            var fields = result.targetableFields;
            console.log(fields);            
        }).catch(function(e){
            if(e.errors){
                console.log(e);
            }
        });
    },

})

Thanks,
Sascha
 
Hi,

In setup under Deliverability I checked the box "Activate bounce management" and "Return bounced emails to sender". found information that there should be another checkbox "show bounce alert next to all instances of the email address", but this checkbox is not available. I created a new customfield to store the emailaddress and I run a flow to send emails to the customer. I tested to send an email to undeliverable address but salesforce doesn't show the bounced information, but the logfile shows the error. Is that setting just working for the standard email field?

Thanks,
Sascha
Hi,

I have two maps and I want to merge this maps into one list, key should be the account. My goal is an overview of the accounts with the opportunities.
How can I merge these lists?
 
public map<Id, Account> getMapFieldLabel1() {
    Map<Id, Account> mapField_Label1= new Map<Id, Account>([SELECT Id, Name FROM Account LIMIT 10]);
    return mapField_Label1;
}

public map<Id, Opportunity> getMapFieldLabel2() {
    Map<Id, Opportunity> mapField_Label2= new Map<Id, Opportunity>([SELECT Id, Account.Id, Name FROM Opportunity]);
    return mapField_Label2;
}
<apex:pageBlockSection columns="2" collapsible="false">              
            <apex:repeat value="{!MapFieldLabel1}" var="item" >
                  <apex:outputText value="{!MapFieldLabel1[item].Id}" />
                   <apex:outputText value="{!MapFieldLabel1[item].Name}" />
            </apex:repeat>   
            </apex:pageBlockSection>
 </apex:pageblock>
 <br/><br/>
 <apex:pageblock>
  <apex:pageBlockSection columns="3" collapsible="false">              
            <apex:repeat value="{!MapFieldLabel2}" var="item" >
                  <apex:outputText value="{!MapFieldLabel2[item].Account.Id}" />
                  <apex:outputText value="{!MapFieldLabel2[item].Id}" />
                   <apex:outputText value="{!MapFieldLabel2[item].Name}" />
            </apex:repeat>   
            </apex:pageBlockSection>
 </apex:pageblock>
Thanks,
Sascha

 
Hi,

I've tried to add two aggregate results in one list, but I don't know if its correct because I don't know how can I show the results at the visualforce page.

Just for testing....
What is my plan, I want to count the number of accounts grouped by account Id, this make no sense but for the test its ok and on the other hand I want to count the number of sales and the sum of the sales grouped by account Id. The both aggregate results should be maped into one list.

Could you tell me is my code correct and how can I display the results?
 
Public Class VTP32_class {

    public String CombinedSummary { get; set; }

Public VTP32_class() {

}

Public class CombinedSummary {
    public Integer CountAcc {get; set;}
    public Id UId {get; set;} 
    public Integer CountSales {get; set;}
    public Double Brutto_BWS {get; set;}  
    
Public CombinedSummary (AggregateResult arM, AggregateResult arS) {
    CountAcc = (Integer) arM.get('CountAcc');
    UID = (Id) arS.get('Id');
    CountSales = (Integer) arS.get('CountSales');
    Brutto_BWS = (Double) arS.get('Brutto_BWS');
    }
}

Public List<CombinedSummary> generateWrappers() {
        Map<Id, AggregateResult> AccMap = new Map<Id, AggregateResult>();
        Map<Id, AggregateResult> AccSales = new Map <Id, AggregateResult>();

        List<CombinedSummary> combinedSummaries = new List<CombinedSummary>();
      
        FOR(AggregateResult arM: [SELECT COUNT(OwnerId) CountAcc, Id FROM Account GROUP BY Id]) {
            AccMap.put((Id)arM.get('Id'), arM);
        }
       
        FOR(AggregateResult arS: [SELECT COUNT(Id) CountSales, SUM(BWS_Brutto__c) Brutto_BWS, Einzelrisiko__r.Gruppenvertrag__r.Unternehmen__r.Id FROM Umsatz__c GROUP BY Einzelrisiko__r.Gruppenvertrag__r.Unternehmen__r.Id]) {
            AccSales.put((Id)arS.get('Einzelrisiko__r.Gruppenvertrag__r.Unternehmen__r.Id'), arS);
        }
            
        Set<Id> AccSet = new Set<Id>();
        AccSet = AccSales.keySet();
        AccSet.addAll(AccSales.keySet());
        
        FOR (Id Id : AccSet) {
            combinedSummaries.add(new CombinedSummary(AccMap.get(Id), AccSales.get(Id)));
        }
        
        Return combinedSummaries;
    
}

}
Thanks,
Sascha
Hello,

I need a overview like a table of all accounts and additional the sum of sales 2017, sum of current sales, sum of opportunities.
How can I to this?

Accountname | Sales 2017 | Sales 2018 | Opps 
----------------------------------------------------------------------
ABC               |        15.000 |          2.000 |       20.000
XYZ               |                 0 |        10.000 |       50.000

Thanks,
Sascha
 
Hi,

I test the code from salesforce to unsubscribe via mail, below you will find the original code from salesforce. This works fine, but what is happen if the unsubscriber send an email to salesforce without the subject string "unsubscribe". Can I see this mails somewhere?
 
Global class unsubscribe implements Messaging.inboundEmailHandler{

    Global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, 
                         Messaging.InboundEnvelope env ) {
    
        // Create an inboundEmailResult object for returning 
        // the result of the email service.
        Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
         
        // Create contact and lead lists to hold all the updated records.
        List<Contact> lc = new List <contact>();
        List<Lead> ll = new List <lead>();
         
        // Convert the subject line to lower case so the program can match on lower case.
        String mySubject = email.subject.toLowerCase();
        // The search string used in the subject line.
        String s = 'unsubscribe';
         
        // Check the variable to see if the word "unsubscribe" was found in the subject line. 
        Boolean unsubMe;
        // Look for the word "unsubcribe" in the subject line. 
        // If it is found, return true; otherwise, return false.
        unsubMe = mySubject.contains(s);
         
         // If unsubscribe is found in the subject line, enter the IF statement.
         
        if (unsubMe == true) {
            
            try {
               
            // Look up all contacts with a matching email address.
               
            for (Contact c : [SELECT Id, Name, Email, HasOptedOutOfEmail
                          FROM Contact
                          WHERE Email = :env.fromAddress
                          AND hasOptedOutOfEmail = false
                          LIMIT 100]) {
                          
                // Add all the matching contacts into the list.   
                c.hasOptedOutOfEmail = true;
                lc.add(c);
            }
            // Update all of the contact records.
            update lc;
        }
        catch (System.QueryException e) {
            System.debug('Contact Query Issue: ' + e);
        }   
        
        try {
            // Look up all leads matching the email address.
            for (Lead l : [SELECT Id, Name, Email, HasOptedOutOfEmail
                     FROM Lead
                     WHERE Email = :env.fromAddress
                     AND isConverted = false
                     AND hasOptedOutOfEmail = false
                     LIMIT 100]) {
                // Add all the leads to the list.       
                l.hasOptedOutOfEmail = true;
                ll.add(l);
                   
                System.debug('Lead Object: ' + l);   
            } 
            // Update all lead records in the query.
            update ll;
        }
        
        catch (System.QueryException e) {
            System.debug('Lead Query Issue: ' + e);
        }   
        
        System.debug('Found the unsubscribe word in the subject line.');
         } 
         else {
            System.debug('No Unsuscribe word found in the subject line.' );
         }
        // Return True and exit.
        // True confirms program is complete and no emails 
        // should be sent to the sender of the unsubscribe request. 
        result.success = true;
        return result;
    }   
}

thanks,
Sascha
HI,

If I click on the button the parameter calc_view should set to value 1.
But the value is still 0.

Please help me.
 
<apex:commandButton value="CALC" onclick="window.open('/apex/calc_test','_blank','height=500,width=500,toolbar=no,scrollbars=no,resizeable=no,menubar=no,top=200,left=200'); return false;">
	<apex:param name="TEST" value="1" assignTo="{!calc_view}"/>
</apex:commandButton>
 
public class calc_class {

    public Integer calc_VIEW {get; set;}
    
    public Double value1 {get; set;}
    public Double value2 {get; set;}
    
    public calc_class() {
        calc_VIEW = 0;
    }
	
    
    public PageReference Pr_calc() {
        value2= value1/ 3.35 * 100;
        return new PageReference('/apex/calc_test');   
    }

}
Thanks,
Sascha
 
Dear All,

I have the following code and I want to show the value at the top of the bars.
Could you help me.
 
<apex:page controller="Samplepage_class" sidebar="true"> 
    
<apex:includeScript id="a" value="https://www.google.com/jsapi" />

<apex:pageblock title="Samplepage">

<div id="chart_div"></div>
        
<script type="text/javascript">

google.load('visualization', '1.1', {'packages': ['bar']});

google.setOnLoadCallback(drawStuff);

function drawStuff() {
    var data = new google.visualization.DataTable();
    data.addColumn('string', 'Team');
    data.addColumn('number', 'Level 1');
    data.addColumn('number', 'Level 2');
    data.addColumn('number', 'Level 3');
    data.addColumn('number', 'Level 4');
    data.addColumn('number', 'YTD');    
    data.addRows([
        ['Team1',  {!Level1_Team1}, {!Level2_Team1}, {!Level3_Team1}, {!Level4_Team1}, {!YTD_Team1}],
        ['Team2',  {!Level1_Team2}, {!Level2_Team2}, {!Level3_Team2}, {!Level4_Team2}, {!YTD_Team2}],
    ]);

    // Set chart options
    var options = {
        isStacked: true,
        width: 850,
        height: 500,
        backgroundColor: '#F8F8F8',
        
        chartArea: { backgroundColor: '#F8F8F8' },

        chart: {
<!--            title: 'SamplePage', -->
            subtitle: 'SampleSubTitle'
        },        
        vAxis: {
            format: 'decimal',
            viewWindow: {
                min: 0,
                max: 15000000
            }
        },
        series: {
            4: { targetAxisIndex: 1 }, 
            5: { targetAxisIndex: 1 }
        }
    };

    var chart = new google.charts.Bar(document.getElementById('chart_div'));
    chart.draw(data, google.charts.Bar.convertOptions(options));
};   

</script>

</apex:pageblock>

</apex:page>
Thanks,
Sascha

Hi is there anyway to export into excel ".xlsx" extension using visualforce page.

 

I am using contentType = "application/vnd.ms-excel#MyFile.xlsx" but gives en error while opening a file.

 

Excel cannot open the file 'MyFile.xlsx' becuase the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.

 

Please suggest me on this.

 

Thanks,

Hi All,

This is the VF page code to disply google map for single Account (billing address)it is working. like this i want to display all the account on Google map. Can anyone please tell how to resolve this issue.Also tell what is the change i need to do for this.  

 

VF Code:

 

<apex:page standardController="Account" >
<apex:pageBlock >
<head>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">

$(document).ready(function() {

var myOptions = {
zoom: 20,
mapTypeId: google.maps.MapTypeId.HYBRID,
mapTypeControl: true
}

var map;
var marker;

var geocoder = new google.maps.Geocoder();
var address = "{!Account.BillingStreet}, {!Account.BillingPostalCode} {!Account.BillingCity}, {!Account.BillingState}, {!Account.BillingCountry}";



var infowindow = new google.maps.InfoWindow({
content: "<b>{!Account.Name}</b>"
});

geocoder.geocode( { address: address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK && results.length) {
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {

//create map
map = new google.maps.Map(document.getElementById("map"), myOptions);

//center map
map.setCenter(results[0].geometry.location);

//create marker
marker = new google.maps.Marker({
position: results[0].geometry.location,
map: map,
title: "{!Account.Name}"
});

//add listeners
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
google.maps.event.addListener(infowindow, 'closeclick', function() {
map.setCenter(marker.getPosition());
});

}

} else {
$('#map').css({'height' : '15px'});
$('#map').html("Oops! {!Account.Name}'s address could not be found, please make sure the address is correct.");
resizeIframe();
}
});

function resizeIframe() {
var me = window.name;
if (me) {
var iframes = parent.document.getElementsByName(me);
if (iframes && iframes.length == 1) {
height = document.body.offsetHeight;
iframes[0].style.height = height + "px";
}
}
}

});
</script>

<style>
#map {
font-family: Arial;
font-size:12px;
line-height:normal !important;
height:500px;
background:transparent;
}
</style>

</head>

<body>
<div id="map"></div>
</body>
</apex:pageBlock>
</apex:page>

 

Regards,

Udaya