• Virgilio Ganata
  • NEWBIE
  • 20 Points
  • Member since 2014

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

I am trying to update parent record (Contacts) based on Task

Here is my trigger
 
trigger updateContactFromTask on Task (before insert, before update)
{

Map<Id,Contact> contactMap = new Map<Id,Contact>();
Set<id> Ids = new Set<id>();
for (Task tk: Trigger.new) {
Ids.add(tk.WhoId);
}

Map<id,Contact> contactMap2 = new Map<id,Contact>([Select Id, Title from Contact Where Id in :Ids]);

for (Task t: Trigger.new)
if(t.CreatedDate!=system.today()&&Contact.LeadSource != NULL)
{
Contact l = contactMap2.get(t.WhoId);
l.LeadSource = 'Test1234';
contactMap.put(l.id,l);
}
update contactMap.values();

}

So my criteria: 
if(t.CreatedDate!=system.today()&&Contact.LeadSource != NULL)
If Task is created Today and Contact LeadSource Not Equal to NULL, This works and sets a Leadsource value, However when I set the LeadSource to another value Say Web. Trigger still fires for update even it has a value. Perhaps something wrong with my trigger.

Thank you in advanced
 
Hi Team, Having troubles sorting my visualforce page by name, Im a bit playful with my demo org so please bear with me. 

Here is my VF 
<apex:page standardController="Lead" showHeader="false" sidebar="false" tabStyle="lead" >
<link href='https://fonts.googleapis.com/css?family=Ravie' rel='stylesheet' type='text/css' />
    
  <style>
      .alef1 {
        font-family: 'Alef', serif;
        font-size: 24px;
      }
      
      .alef2 {
        font-family: 'Alef', serif;
        font-size: 14px;
      }
         
   
       .activeTab {background-color: #1798c1 ; font-family: 'Alef';font-style: Italic; color:white; width: 100px; height: 23px; padding-top:2px; font-size: 15px; font-style:'Alef'; border:0px;
         background-image:none; border-radius: 10px;}

      .inactiveTab {background-color: #1798c1 ; font-family: 'Alef'; font-style: Italic; color:white; width: 100px; height: 15px; padding-top:2px; font-size: 15px; font-style:bold; border:0px;
         background-image:none; border-radius: 10px;}
    </style>
    
    <div class="alef1"><i>Attach your favorite Music using the attach file button</i></div><br/>
    <div class="alef2"><i><marquee>***Note: Only .mp3 format are supported</marquee></i></div><br/>
<apex:tabPanel switchType="client" selectedTab=" tabdetails" id="LeadTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab" contentStyle="font-family: Poiret One;">  
 
<apex:tab label="Play Here" name="LeadDetails">
<apex:page standardController="Lead">
</apex:page>
<apex:page standardController="Lead" id="pg" extensions="PlayAudio" sidebar="true">
<apex:includeScript value="{!URLFOR($Resource.AudioPlayer, 'audio-player/audio-player.js')}"/>
<script type="text/javascript">  
     AudioPlayer.setup("{!URLFOR($Resource.AudioPlayer, 'audio-player/player.swf')}", {  
         width: 400  
     });  
</script> 

<script type="text/javascript">  
    function playAudio(LeadObj)
        {
            AudioPlayer.embed("audioplayer_1", {soundFile: LeadObj});
        }  
</script>
<apex:form id="frm">
    <apex:pageBlock id="pb">
        <apex:variable value="{!0}" var="count" />
        <apex:pageBlockTable value="{!listAttachment}" var="item" id="pbt">
            <apex:column headerValue="Title">
            
                {!item.Name}
            </apex:column>
            
            <apex:column id="colPlayer" rendered="{!CONTAINS(item.ContentType, 'audio')}">
                <p id="{!count}.audioplayer"></p>
                <script type="text/javascript">
                    AudioPlayer.embed("{!count}.audioplayer", {soundFile: 'https://trialdemo.my.salesforce.com/servlet/servlet.FileDownload?file={!item.Id}'});
                </script>
                <apex:variable value="{!count+1}" var="count" />
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>
</apex:tab>
<apex:tab label="Attach Here" name="NotesAndAttachments" id="tabNoteAtt">

         <apex:relatedList subject="{!Lead}" list="CombinedAttachments" />

      </apex:tab>
</apex:tabPanel>
</apex:page>


and here is my class

//extensions to take care all the lead and activity related attachments and 
public without sharing class PlayAudio {
    
    public List<Attachment> listAttachment {get;set;}
    public Lead lead {get;set;}
    
    //constructor
    public PlayAudio(ApexPages.StandardController controller) {
        
        //get the controller instance
        lead = (Lead)controller.getRecord();
        
        //initialize the attachments list
        listAttachment = new List<Attachment>();
        
        //get all the lead related attachments
        listAttachment = [Select Id, ContentType, Name from Attachment where ParentId = :lead.Id];
        
        //get all the related tasks attachments
        List<Task> listTask = [Select WhatId from Task where WhoId =: lead.Id ];
        listAttachment.addAll([Select Id, ContentType, Name from Attachment where ParentId IN :listTask]);
        
        //get all the related events attachments
        List<Event> listEvent = [Select WhatId from Event where WhoId =: lead.Id ];
        listAttachment.addAll([Select Id, ContentType, Name from Attachment where ParentId IN :listEvent]);
        
    }
    
    @isTest
    private static void testPlayAudio()
        {
            //create a lead record
            Lead lead = new Lead(LastName='test', Company='test');
            insert lead;
            
            //start test from here 
            Test.startTest();
            
            PlayAudio controller = new PlayAudio(new ApexPages.StandardController(lead));
            
            System.assert(lead != null);
            //stop test here
            Test.stopTest();
        }

}

So this gets the attachments from Leads attachments related list to play audio mostly used with voicemails. Id really like to sort by name

I have font renderring pdf in my visualforce page, Successfully added font family now I'd like to use font face btu wieh I tried to seems that it does not work. 

Sample:

VF:

<apex:page standardController="Lead" showHeader="false" sidebar="false" tabStyle="lead" > <link href='https://fonts.googleapis.com/css?family=IM+Fell+English' rel='stylesheet' type='text/css' /> <style> .alef1 { font-family: 'Alef', serif; font-size: 24px; } .alef2 { font-family: 'Alef', serif; font-size: 14px; }

 

Hi,

I am trying to update parent record (Contacts) based on Task

Here is my trigger
 
trigger updateContactFromTask on Task (before insert, before update)
{

Map<Id,Contact> contactMap = new Map<Id,Contact>();
Set<id> Ids = new Set<id>();
for (Task tk: Trigger.new) {
Ids.add(tk.WhoId);
}

Map<id,Contact> contactMap2 = new Map<id,Contact>([Select Id, Title from Contact Where Id in :Ids]);

for (Task t: Trigger.new)
if(t.CreatedDate!=system.today()&&Contact.LeadSource != NULL)
{
Contact l = contactMap2.get(t.WhoId);
l.LeadSource = 'Test1234';
contactMap.put(l.id,l);
}
update contactMap.values();

}

So my criteria: 
if(t.CreatedDate!=system.today()&&Contact.LeadSource != NULL)
If Task is created Today and Contact LeadSource Not Equal to NULL, This works and sets a Leadsource value, However when I set the LeadSource to another value Say Web. Trigger still fires for update even it has a value. Perhaps something wrong with my trigger.

Thank you in advanced
 
Hi Team, Having troubles sorting my visualforce page by name, Im a bit playful with my demo org so please bear with me. 

Here is my VF 
<apex:page standardController="Lead" showHeader="false" sidebar="false" tabStyle="lead" >
<link href='https://fonts.googleapis.com/css?family=Ravie' rel='stylesheet' type='text/css' />
    
  <style>
      .alef1 {
        font-family: 'Alef', serif;
        font-size: 24px;
      }
      
      .alef2 {
        font-family: 'Alef', serif;
        font-size: 14px;
      }
         
   
       .activeTab {background-color: #1798c1 ; font-family: 'Alef';font-style: Italic; color:white; width: 100px; height: 23px; padding-top:2px; font-size: 15px; font-style:'Alef'; border:0px;
         background-image:none; border-radius: 10px;}

      .inactiveTab {background-color: #1798c1 ; font-family: 'Alef'; font-style: Italic; color:white; width: 100px; height: 15px; padding-top:2px; font-size: 15px; font-style:bold; border:0px;
         background-image:none; border-radius: 10px;}
    </style>
    
    <div class="alef1"><i>Attach your favorite Music using the attach file button</i></div><br/>
    <div class="alef2"><i><marquee>***Note: Only .mp3 format are supported</marquee></i></div><br/>
<apex:tabPanel switchType="client" selectedTab=" tabdetails" id="LeadTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab" contentStyle="font-family: Poiret One;">  
 
<apex:tab label="Play Here" name="LeadDetails">
<apex:page standardController="Lead">
</apex:page>
<apex:page standardController="Lead" id="pg" extensions="PlayAudio" sidebar="true">
<apex:includeScript value="{!URLFOR($Resource.AudioPlayer, 'audio-player/audio-player.js')}"/>
<script type="text/javascript">  
     AudioPlayer.setup("{!URLFOR($Resource.AudioPlayer, 'audio-player/player.swf')}", {  
         width: 400  
     });  
</script> 

<script type="text/javascript">  
    function playAudio(LeadObj)
        {
            AudioPlayer.embed("audioplayer_1", {soundFile: LeadObj});
        }  
</script>
<apex:form id="frm">
    <apex:pageBlock id="pb">
        <apex:variable value="{!0}" var="count" />
        <apex:pageBlockTable value="{!listAttachment}" var="item" id="pbt">
            <apex:column headerValue="Title">
            
                {!item.Name}
            </apex:column>
            
            <apex:column id="colPlayer" rendered="{!CONTAINS(item.ContentType, 'audio')}">
                <p id="{!count}.audioplayer"></p>
                <script type="text/javascript">
                    AudioPlayer.embed("{!count}.audioplayer", {soundFile: 'https://trialdemo.my.salesforce.com/servlet/servlet.FileDownload?file={!item.Id}'});
                </script>
                <apex:variable value="{!count+1}" var="count" />
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>
</apex:tab>
<apex:tab label="Attach Here" name="NotesAndAttachments" id="tabNoteAtt">

         <apex:relatedList subject="{!Lead}" list="CombinedAttachments" />

      </apex:tab>
</apex:tabPanel>
</apex:page>


and here is my class

//extensions to take care all the lead and activity related attachments and 
public without sharing class PlayAudio {
    
    public List<Attachment> listAttachment {get;set;}
    public Lead lead {get;set;}
    
    //constructor
    public PlayAudio(ApexPages.StandardController controller) {
        
        //get the controller instance
        lead = (Lead)controller.getRecord();
        
        //initialize the attachments list
        listAttachment = new List<Attachment>();
        
        //get all the lead related attachments
        listAttachment = [Select Id, ContentType, Name from Attachment where ParentId = :lead.Id];
        
        //get all the related tasks attachments
        List<Task> listTask = [Select WhatId from Task where WhoId =: lead.Id ];
        listAttachment.addAll([Select Id, ContentType, Name from Attachment where ParentId IN :listTask]);
        
        //get all the related events attachments
        List<Event> listEvent = [Select WhatId from Event where WhoId =: lead.Id ];
        listAttachment.addAll([Select Id, ContentType, Name from Attachment where ParentId IN :listEvent]);
        
    }
    
    @isTest
    private static void testPlayAudio()
        {
            //create a lead record
            Lead lead = new Lead(LastName='test', Company='test');
            insert lead;
            
            //start test from here 
            Test.startTest();
            
            PlayAudio controller = new PlayAudio(new ApexPages.StandardController(lead));
            
            System.assert(lead != null);
            //stop test here
            Test.stopTest();
        }

}

So this gets the attachments from Leads attachments related list to play audio mostly used with voicemails. Id really like to sort by name