• Vishal_Gupta
  • SMARTIE
  • 960 Points
  • Member since 2015

  • Chatter
    Feed
  • 31
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 200
    Replies
Hello,

I have certain fields on my paglayout. X, Y, Z.

I want to ad a button on the page, say..Custom button.

When "Custom button" is clicked, i want to call a APEXclassName.FunctionName(Value of CustomField X, Value of CustomField Y, Z).

I want to execute like this.

How cani implement the same

Thank you in advance
  • January 29, 2019
  • Like
  • 0
Hello,

I am making a SOQL quesry to object contact and lead.

From the values i get from the SOQL query, i will construct need to construct a JSON

I have multiple tree, like example below:
https://json.org/example.html
{
    "glossary": {
        "title": "example glossary",
		"GlossDiv": {
            "title": "S",
			"GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
					"SortAs": "SGML",
					"GlossTerm": "Standard Generalized Markup Language",
					"Acronym": "SGML",
					"Abbrev": "ISO 8879:1986",
					"GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
						"GlossSeeAlso": ["GML", "XML"]
                    },
					"GlossSee": "markup"
                }
            }
        }
    }
}

How can i construct a JSON from SOQL responce?
  • January 24, 2019
  • Like
  • 0
Hi All,
      my requirement is  to Create a trigger that uses the From Address of the Email Message object on a new Case to update the Case Owner. The Case Owner will be the user that sent the email and will be identified by their email address as it corresponds to active users on the user table 

FromAddress = User.Email the assign CaseOwner = User.Id 
my triggerHelper class is as follow:-
public class EmailMessageTriggerHelper {
    
    public static List<EmailMessage> newEmailMessages = new List<EmailMessage>();
    public static List<EmailMessage> oldEmailMessages = new List<EmailMessage>();
    public static Map<Id, EmailMessage> newMapEmailMessages = new Map<Id, EmailMessage>();
    public static Map<Id, EmailMessage> oldMapEmailMessages = new Map<Id, EmailMessage>(); 
          
    public static void UpdateOwner(){
        set<Id> caseIds = new set<Id>();
        map<Id,string> case2OwnerValueMap = new map<Id,string>();
        for(EmailMessage message : newEmailMessages){
            if(message.Incoming == false){
                string OwnerValue;
                message.FromAddress = String.Valueof(User.Email);

            caseIds.add(message.ParentId);
            case2OwnerValueMap.put(message.ParentId, OwnerValue);
        }
    }
    list<Case> casesToUpdate = [Select Id, OwnerId   From Case Where Id in: caseIds];
    for(Case c : casesToUpdate){
        c.OwnerId = case2OwnerValueMap.get(c.Id);
    }

    update casesToUpdate;
        
     }    
}
Am i missing something?
guide me?
Any suggestions?
Hi Guys - how to populate lastmodifiedby on a custom text filed using trigger on customobj__c. please suggest
Hi - 

We have a schedueld job that is designed to remove old documents that no longer need to be in our system. It appears around 6/20 (Summer 16?) permissions were changed and we were not able to query all documents via the system administrator profile. I have fixed this issue by adding "USING SCOPE Team" to our query.

I am now receving an "INSUFFICIENT_ACCESS_OR_READONLY" on the Content Document object when trying to run the delete through a class ran by a schedueld job. I have tested a one off delete of the object via the Developer console and am able to successfully delete the job thorugh there. I have also checked my class to ensure the job is running under my profile, which it is. 

It seems strange to me I can run a detele through the developer console but am unable too when running the schedueld job on the same object.

Code Snippit: 

//scope in this case is passed in as an SObject of ContentDocument
global void execute(Database.BatchableContext BC,List<SObject> scope) {
 if( dataCleanup.Delete__c )
            delete scope;
}
Hi,

I'm having trouble getting some of the parent record information to display on my visualforce page. I have a custom controller extension that is returning the values when I open the logs. However, the fields do not populate on the Visualforce page.

Parent Obejct - Opportunity
Child Object - Pursuit Survey

I'm trying to get StageName from opportunity to show on the custom visualforce page.

 
public with sharing class SurveyParentIDExt{
    public Pursuit_Survey__c PursuitChild{get;set;}
    public Opportunity ParentOpp{get;set;}
    
    public SurveyParentIDExt(ApexPages.StandardController controller){
        PursuitChild=(Pursuit_Survey__c)controller.getRecord();
        String oppid = (PursuitChild.Opportunity__c);
        String parentID = System.currentPagereference().getParameters().get('parentid');
        if (parentID != null){
            PursuitChild.Opportunity__c=parentid;  
        }     
        Opportunity ParentOpp = [SELECt name, id, stagename, priority__c from Opportunity where id =: parentid];
    system.debug(PursuitChild);
    system.debug(PursuitChild.Opportunity__c); 
    system.debug(ParentOpp);
    }

When I look for the debug of ParentOpp, it does return all of the fields and values as expected:
 
14:21:18:203 USER_DEBUG [15]|DEBUG|Opportunity:{Name=Pursuit Survey Process, Id=006e000000An8XJAAZ, StageName=Pursuing, Priority__c=Target, RecordTypeId=012i00000002n45AAA}

When I try and call the StageName in my visualforce page with: 
Opportunity Stage: <apex:outputfield value="{!ParentOpp.StageName}" />

Nothing is rendered. It remains a blank space (and I'll write your name....to all the Taylor fans).

Thanks so much for any help!

Richard 
I seem to have problems around line 43 where I have my

zipMapState.get(l.postalcode.substring(0,5));

Statement.  I was wondering if there is a more efficient way of doing this??  Please help if you can I'd really appriciated it.

Thank you, Steve
trigger ZipCodeStateCityFix on Lead (before insert, before update) { 
    
    set<string> left5zips = new set<string>();
    
    String ZipVar;
     
    for (lead l: trigger.New) {
        
        ZipVar = l.postalcode;
        
        if(l.PostalCode != null)
        {
          if(l.postalcode.length()>= 5)
          {
               
            if ((l.State == null || l.City == null) && l.postalcode != null) {
                left5zips.add(l.postalcode.substring(0,5));
            }
          }
        }  
    }

    //query the zip_code object to get the zipcode (Name) and zone from the zip code object
    if(ZipVar != null)
    {
    if(ZipVar.length() >= 5)
    {
     
    map<string,string> zipMapState=new map<string,string>(); 
    map<string,string> zipMapCity=new map<string,string>();
    
    
    for(Zip_Code_Look_up__c z : [Select name, State__c, City__c 
    from Zip_Code_Look_up__c WHERE name IN :left5zips]) 
    {
            zipMapState.put (z.name, z.State__c); 
            zipMapCity.put (z.name, z.City__c);
    }

    for (lead l: trigger.new) {
        if((l.State == null || l.City == null) && l.postalcode != null) {
              
              String State = zipMapState.get(l.postalcode.substring(0,5));
              String City = zipMapCity.get(l.postalcode.substring(0,5));
              
              if (State != null) 
              {
                  l.State = State;
                  l.City = City;
                  l.Country = 'USA';
              }

        }
        if (l.State == null )
        {
            Return;        
        }
    }
    }}
    Return;
}

 
I have two icons on my replacement page for a custom tab. One is from the enhanced list, and the other from section header.

Can I remove the icon from the enhanced list or from the section header? I only want one.

User-added image
 
<apex:page showHeader="true" tabstyle="SEActivity__c">
    <apex:sectionHeader title="SE Activities" subtitle="Home" />
    <apex:enhancedList type="SEActivity__c" height="600" rowsPerPage="50" />
</apex:page>



 
Hi ,

I'm attempting to update the lookup field in the object and unable to do so.. Please anyone guide me the correct way of updating the field in apex.

PO_requisition__c poreq = new PO_requisition__c();
            poreq = [select SecondApprover__r.FirstName from PO_requisition__c where ID ='a0J9000000tinJl'];
            poreq.SecondApprover__r.Id = UserInfo.getUserId();
            update poreq;
            System.debug('----------------------This is approved now-----'+poreq.SecondApprover__r.Id);


getting below error..

System.NullPointerException: Attempt to de-reference a null object

Thanks
VIshwa
  • September 13, 2015
  • Like
  • 0
We have a process where the rep creates a physical contract (not a Salesforce contract record) using DrawLoop. There is a button on the opportunity or quote the rep can push to initiate the process. When the document is created, there is an option to send using DocuSign. When the rep clicks the link, it sends to DocuSign, thereby creating a DocuSign Status record (DocuSign_Status custom object). 

I wrote a trigger that would create a contract when the DocuSign Status field "Envelope Status = Completed". It works...but only when I create the DocuSign Status record manually and change the trigger from after insert to after update. If it is created through the DocuSign workflow that is set up, it does not create the contract. Also, changing to after update messes up my test class as well, no coverage.

What am I missing?

Here is the original trigger that passes testing:

trigger CreateContractDocSignComp on dsfs__DocuSign_Status__c (after insert)
{
    List<Contract> ctr = new List<Contract>();
    
      for(dsfs__DocuSign_Status__c dsfs : Trigger.new)
      {
        if(dsfs.dsfs__Envelope_Status__c == 'Completed')
        {
             Contract c = new Contract(Name = dsfs.Name,
             Status = 'Draft',
             Total_Contract_Value__c =dsfs.Total_Contract_Value__c,
             StartDate = dsfs.Contract_Start_Date__c,
             Payment_Status__c = 'Ready to be Invoiced',
             AccountId = dsfs.dsfs__Company__c,
             Opportunity_Name__c = dsfs.dsfs__Opportunity__c);
             ctr.add(c);
         }
      }
      if(ctr.size() > 0)
      {
            System.debug('-ctr------->'+ctr.size());
            insert ctr;
      }     
}

Thanks for your help!

Shannon



 
This is my VF code displaying the records with checkbox at front. i need to display this list with radio/options so that user can select only option.how to do this??

<apex:pageBlockSection columns="2">
         <apex:pageBlockTable value="{!wrapcontactList}" var="waccl">
            
           <apex:column >
             <apex:facet name="header">
               <apex:inputCheckbox />
             </apex:facet>
            <apex:inputCheckbox value="{!waccl.isSelected}" id="InputId"/>
           </apex:column>
            
            <apex:column value="{!waccl.accn.name}"/>
            <apex:column value="{!waccl.accn.phone}"/>
           
         </apex:pageBlockTable>
Hello Friends.
The below is my wrapper class for one object(contact).but i want to get the same thing for one more object (basic__c) having fields(name,address1__c,state__c) within the same controller and this list i want to appear in same VF page.how to achieve this.??? 

public class Wrapcontactlist 
{
    public list<wrapcontact> wrapcontactList { get; set; }
    public list<contact> selectedContacts{get;set;}        
      public Wrapcontactlist ()
     {
          wrapcontactList =new list<wrapcontact>();
          for(contact a:[select id,name,phone from contact limit 10])
       {
           wrapcontactlist.add(new wrapcontact(a));
       }
  }
      
  //##THIS IS WRAPPER CLASS
   // contact and checkbox taken in wrapper class   
   public class wrapcontact
{    
    public contact accn{get;set;}
   // public boolean isSelected{get;set;}     
       public wrapcontact(contact a)
    {    
         accn=a;
         isselected=false;
       }
   }
}

I am attempting to use InboundEmailHandler to automatically create a new record (Vendor_Notes__c) from an email, associate the record with another record (Vendor_Profile__c) which is named in the Subject, and then take any attachment in the email and also associate it with that record Vendor_Profile__c record as well. 

I am able to create the new Vendor_Notes__c record and associate it with the Vendor_Profile__c. But I can't get the attachment to appear on the Vendor_Profile__c record. I don't know if the attachment portion of this class or if I need to set up something more for the Vendor_Profile__c object. I have a Notes & Attachments in it. I'm guessing that's all I would need.

Here is the class : 

 

global class VendorEmail implements 
        Messaging.InboundEmailHandler {

  
Vendor_Notes__c[] NewVendorNotes = new Vendor_Notes__c[0];

 global Messaging.InboundEmailResult handleInboundEmail(
  Messaging.InboundEmail email, 
  Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = 
        new Messaging.InboundEmailresult();
 
  // Captures email info
    
String emailAddress = envelope.fromAddress;
String fName = email.fromname.substring(
        0,email.fromname.indexOf(' '));
String lName = email.fromname.substring(
        email.fromname.indexOf(' '));
String[] emailBody = email.plainTextBody.split('\n', 0);
String phoneNumber = emailBody[0].substring(6);
       
//Associates email to proper Vendor Profile

Vendor_Profile__c venpro;
venpro = [select ID from Vendor_Profile__c where name =
             :email.subject limit 1];
    ID jobId = venpro.ID;
    

try
    {
      NewVendorNotes.add(new Vendor_Notes__c(Sender__c = emailAddress,
      Vendor__c = jobId,
      Routing_Number__c = lName,
     Account_Number__c = phoneNumber
      ));
 
      insert NewVendorNotes;
   }
    
   catch (System.DmlException e)   
   {
           

            //Save any Binary Attachment
            
            if (email.binaryAttachments != null)
                {
                    for(Messaging.Inboundemail.BinaryAttachment bAttachment : email.binaryAttachments) 
                    {
                        Attachment attachment = new Attachment();
        
                        attachment.Name = bAttachment.fileName;
                        attachment.Body = bAttachment.body;
                        attachment.ParentId = venpro.Id;
                        insert attachment;
                    }
               } 
}
return result;
       
    }
}



Thank you for your help.

  • September 01, 2015
  • Like
  • 0
I can't get my error message to display. I just keep getting the default error when no rows are returned.  Any help on what I am doing wrong would be appreciated. 
 
trigger AccountTeam on Account_Counselor__c (after insert, after update, before delete) {

                
    if(Trigger.IsInsert) {
        for (Account_Counselor__c ac : Trigger.new) {
        
        //Check that HUB exists
        List<BCS__c> bcscheck =  [SELECT User__c, Name FROM BCS__c WHERE id = :ac.Hub_Name__c LIMIT 1];

        if (bcscheck.size() > 0) {
        } else {
            ac.addError('No User linked to this Hub.');
        }
                BCS__c BCS = [SELECT User__c, Name FROM BCS__c WHERE id = :ac.Hub_Name__c LIMIT 1];
                Account Acc = [SELECT Name FROM Account WHERE Id = :ac.Account__c];
                
        //Check that public group exists
        List<Group> groupcheck = [SELECT Id from Group WHERE Name = :Acc.Name];

        if (groupcheck.size() > 0) {
        } else {
             ac.addError('No Public Group found for this account.');
        }
                Group GP = [SELECT Id from Group WHERE Name = :Acc.Name];
            
                //Put Names in variables
                string userID = BCS.User__c;
                string groupID = GP.Id;
                string accID = ac.Account__c;
                
            system.debug('UserID='+userId);
            system.debug('GroupID='+groupId);
            system.debug('AccountID='+ac.Account__c);     

//and so on and so on.......

 
There are specific data that needs to render in all caps in the VF email template. How do I write that into the VF email template?

This is section of code that needs be outputted in all caps. 
<th>CUSTOMER INFO</th><th> </th>
        <tr>
               <td><b>Company:</b></td>
           <td>{!relatedTo.Contact.Account.Name}</td>
            </tr>
           <tr>
               <td><b>Address:</b></td>
           <td>{!relatedTo.Contact.MailingStreet}</td>
            </tr>
       <tr>
               <td><b>City:</b></td>
           <td>{!relatedTo.Contact.MailingCity} </td>
            </tr> 
       <tr>
               <td><b>State:</b></td>
           <td>{!relatedTo.Contact.MailingState}</td>
           </tr>
           <tr>
               <td><b>Postal Code:</b></td>
           <td>{!relatedTo.Contact.MailingPostalCode}</td>
           </tr>
           <tr>
               <td><b>Country:</b></td>
           <td>{!relatedTo.Contact.MailingCountry}</td>
            </tr>
           <tr>
Here is the entire code of the VF email template:
<messaging:emailTemplate recipientType="Contact"
  relatedToType="Case"
  subject="RMA ON DEMAND - {!relatedTo.CaseNumber} - {!relatedTo.ThreadID__c}">
  <messaging:htmlEmailBody >
    <html>
     <table align="left" width="640px" border="0" cellspacing="0" cellpadding="0">
      <head>
      <apex:image id="Logo" value="https://c.cs16.content.force.com/servlet/servlet.ImageServer?id=015f0000000GJGr&oid=00Df0000003cHuJ&lastMod=1440092921000"/>
      </head>
      <body>
      <STYLE type="text/css">
          table {border-collapse:collapse; table-layout:fixed; width:600px;}
          table td {border:solid 1px #CCCCCC; width:100px; word-wrap:break-word;}
          H3 {color: #004488}
          TH {font-size: 14px; font-face: Tahoma; color: #004488; border: solid #CCCCCC; background: #dfdfdf;
               border-width: 1;  text-align: left } 
          TD  {font-size: 13px; font-face: Tahoma } /
          TABLE{border: solid #CCCCCC; border-width: 1}
          TR {border: solid #CCCCCC; border-width: 1}
        </STYLE>
        <font face="Tahoma" size="2">   
            <br></br>
            <div>Hi Gayle,</div> 
            <br></br>
            <div>Please process the following <b>RMA</b>. If there are any questions, please reply all.</div>
            <br></br>
          <table border="1" >
            <tr> 
               <th>RMA INFO</th><th> </th>
            <tr>    
               <td><b>RMA Type:</b></td>
           <td>{!relatedTo.RMA_Type__c}</td>
            </tr>
            <tr>    
               <td><b>Case Number:</b></td>
           <td>{!relatedTo.CaseNumber}</td>
           </tr>    
            <tr>
             <th>CUSTOMER INFO</th><th> </th>
        <tr>
               <td><b>Company:</b></td>
           <td>{!relatedTo.Contact.Account.Name}</td>
            </tr>
           <tr>
               <td><b>Address:</b></td>
           <td>{!relatedTo.Contact.MailingStreet}</td>
            </tr>
       <tr>
               <td><b>City:</b></td>
           <td>{!relatedTo.Contact.MailingCity} </td>
            </tr> 
       <tr>
               <td><b>State:</b></td>
           <td>{!relatedTo.Contact.MailingState}</td>
           </tr>
           <tr>
               <td><b>Postal Code:</b></td>
           <td>{!relatedTo.Contact.MailingPostalCode}</td>
           </tr>
           <tr>
               <td><b>Country:</b></td>
           <td>{!relatedTo.Contact.MailingCountry}</td>
            </tr>
           <tr>
               <td><b>Contact Name:</b></td>
           <td>{!relatedTo.Contact.Name}</td>
            </tr>
           <tr>
               <td><b>Contact Phone:</b></td>
           <td>{!relatedTo.Contact.Phone} </td>
            </tr>
           <tr>
               <td><b>Contact Email:</b></td>
           <td>{!relatedTo.Contact.Email}</td>
            </tr>
           <tr> 
               <th>PART INFO</th><th> </th>
            <tr>    
               <td><b>Model Number:</b></td>
           <td>{!relatedTo.Model_Number__c}</td>
            </tr>
           <tr>    
               <td><b>Outbound Part Number:</b></td>
           <td>{!relatedTo.Outgoing_Part__c}</td>
            </tr>
             <tr>    
               <td><b>Outbound Serial Number:</b></td>
           <td>{!relatedTo.Outgoing_Serial__c}</td>
           <tr>    
               <td><b>Inbound Part Number:</b></td>
           <td>{!relatedTo.Part_Number__c} {!relatedTo.Part_number_2__c} {!relatedTo.Part_number_3__c}</td>
            </tr>
           <tr>    
               <td><b>Inbound Part Serial Number:</b></td>
           <td>{!relatedTo.SN__c} {!relatedTo.Serial_number_2__c} {!relatedTo.Serial_number_3__c} {!relatedTo.Serial_number_4__c}</td>
            </tr>
            <tr>    
               <td><b>Chassis Serial Number:</b></td>
           <td>{!relatedTo.Chassis_Serial_Number_1__c} </td>
            </tr>
           <tr>    
               <td><b>Problem Description:</b></td>
           <td>{!relatedTo.Detailed_Problem_Description_1__c} </td>
            </tr>
         </tr>
      </tr>
     </tr>
     </tr>
    </table>
    <br></br>
    <div>Thanks,</div>
    <div>{!relatedTo.Owner.Name} </div>
   </font>
  </body>
  </table>
 </html>
</messaging:htmlEmailBody>  
</messaging:emailTemplate>

Thanks!

Beth
 
The criteria is :

Whenever Refills remaining field changed and if refill remaining is 1 or 0 i want a task alert for that rearrange this formula:

AND(ISCHANGE( Refills_Remaining__c ),((Refills_Remaining__c = 1)) OR
(Refills_Remaining__c = 0))))
Hello, 

I received the following error message. I believe it is coming from a trigger but I am not sure. Thanks for any help! 

Error Message: 

Developer script exception from E-Gains Distrubuting, LLC : geocodeAccountAddress : geocodeAccountAddress: execution of AfterUpdate caused by: System.AsyncException: Future method cannot be called from a future or batch method: AccountGeocodeAddress.geocodeAddress(Id) Class.AccountGeocodeAddress.DoAddressGeocode: line 17, column 1 Trigger.geocodeAccountAddress: line 34, column 1
Apex script unhandled trigger exception by user/organization: 005i0000005QIhN/00Di0000000i0Xa

geocodeAccountAddress: execution of AfterUpdate

caused by: System.AsyncException: Future method cannot be called from a future or batch method: AccountGeocodeAddress.geocodeAddress(Id)

Class.AccountGeocodeAddress.DoAddressGeocode: line 17, column 1
Trigger.geocodeAccountAddress: line 34, column 1
 
I created a visual email template that works with:
--a custom object called OT__c,
--a visualforce component called OTComponente, and
--an apex class called OTPresupuesto.

My problem is when I receive the email, it has some fields in blank, I think it has to do with the id of the custom object.
Specifically this part:
From OT__c Where Id=:System.currentPagereference().getParameters().get('Id')
when I put in my apex class just the "From OT__c" without specifying my Id, the email I recieve looks like this:
 
Nuestra Ref.:
Sucursal:
Fecha:24/08/2015

Total a Pagar:0,00
Saldo a Pagar:0,00 
Sub Total:0,00
Nombre:
RUC:
Name:

Gracias por elegir Maker!
Saludos Cordiales,
El equipo de Makerxmail


and when I put the "From OT__c Where Id=:System.currentPagereference().getParameters().get('Id')" the email looks like this (​the component doesn't even appear):
Nuestra Ref.:
Sucursal:
Fecha:24/08/2015 


Gracias por elegir Maker!
Saludos Cordiales,
El equipo de Makerxmail






this is my apex class OTPresupuesto
public with sharing class OTPresupuesto {

    public List<fact> factList{get;set;}
      
    //Constructor  
    public OTPresupuesto() {
        this.factList = new List<fact>();
        for(OT__c ot2 :[Select Name, Nombre_de_la_Cuenta__c, Sub_Total__c, RUC__c,
                        Total_a_Pagar__c,Saldo_a_Pagar__c
                        From OT__c Where Id=:System.currentPagereference().getParameters().get('Id')  LIMIT 1])
        {
            factList.add(new fact(ot2));
        }
        
    }       
    
    public class fact{                   
        public OT__c OT{get; set;}                  
        public string saldoPagar {get; set;}
        public string subTotal {get; set;}
        public string totalPagar {get; set;}
                   
        public fact(OT__c ot2){                           
            this.OT = ot2;                           
            this.saldoPagar= NumberToSpanishWords.convertToEU(ot2.Saldo_a_Pagar__c);  
            this.subTotal= NumberToSpanishWords.convertToEU(ot2.Sub_Total__c);
            this.totalPagar= NumberToSpanishWords.convertToEU(ot2.Total_a_Pagar__c);
        }   
    }     
}



and my visual component OTComponente
<apex:component controller="OTPresupuesto" access="global">
        
        <apex:repeat var="as" value="{!factList}">               
                Total a Pagar: <apex:outputText value="{!as.totalPagar}"/><br/>
                Saldo a Pagar: <apex:outputText value="{!as.saldoPagar}"/> <br/> 
                Sub Total: <apex:outputText value="{!as.subTotal}"/><br/> 
                Nombre: <apex:outputText value="{!as.OT.Nombre_de_la_Cuenta__c}"/><br/>
                RUC: <apex:outputText value="{!as.OT.RUC__c}"/>  <br/>
                Name: <apex:outputText value="{!as.OT.Name}"/>   <br/>   
        </apex:repeat>    
</apex:component>


this is my visual email template called EnvioPresupTemaplate
<messaging:emailTemplate subject="RE: {!relatedTo.Asunto_email__c}" recipientType="User" relatedToType="OT__c">
<messaging:htmlEmailBody >       
    <br/>
    <b>Nuestra Ref.:</b><apex:outputText value="{!relatedTo.Name}"/><br/>
    
    Sucursal:<apex:outputField value="{!relatedTo.Sucursal__c}"/><br/> 
    Fecha:<apex:outputField value="{!relatedTo.Fecha__c}"/><br/>
    
    <br/><c:OTComponente />
    <br/>
    <br/>
    Gracias por elegir Maker!<br/>
    Saludos Cordiales,<br/>
    El equipo de Makerxmail
</messaging:htmlEmailBody>
</messaging:emailTemplate>





 
Hi Everyone,

Implementing a basic email handler to email an attachement and have it save as an account attachment (in the notes and attachment related list). I am able to create a new account, but not match and update an existing and most importantly, the email attachment does not land on the account reocrd. I beleive my email services setting are OK (set to accept All attachements). Here is my class:
 
global class EmailToSalesForce implements Messaging.InboundEmailHandler {
  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, 
                                                         Messaging.Inboundenvelope envelope) {
  
Account account;
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();

try {



// Look for account whose name is the subject and create it if necessary
if ([select count() from Account where Name =:email.subject] == 0) {
  account = new Account();
  account.Name = email.subject;
  insert account;
} else {
  account = [select Id from Account where Name =:email.subject];
}



// Save attachments, if any
for (Messaging.Inboundemail.TextAttachment tAttachment : email.textAttachments) {
  Attachment attachment = new Attachment();
 
  attachment.Name = tAttachment.fileName;
  attachment.Body = Blob.valueOf(tAttachment.body);
  attachment.ParentId = account.Id;
  insert attachment;
}
for (Messaging.Inboundemail.BinaryAttachment bAttachment : email.binaryAttachments) {
  Attachment attachment = new Attachment();
 
  attachment.Name = bAttachment.fileName;
  attachment.Body = bAttachment.body;
  attachment.ParentId = account.Id;
  insert attachment;
}
      
      result.success = true;
      result.message = (email.subject + ' matched');
    } catch (Exception e) {
      result.success = false;
      result.message = 'Oops, I failed.';
    }
   
    return result;
  }
}

 
hello friends,
This is my controller code:
TableData=[select Code__c from verify__c where ID__c= :s];
 str=String.valueof(TableData);
str contains following value.
ID__c:{Code__c=841095, Id=a012800000703J9AAI}
i want to get only '841095'
how to get this???
Hi all ,

i am facting problem because i am not able to write a trigger for after insert after update after delete parent to child object

How to writa a Trigger on Parent Object  after insert ,after update,after delete trigger worked??

Thanks
aklkk
  • August 17, 2019
  • Like
  • 0
I want to move all the old leads from lead object and transfer it to any big object and after that I want to delete those records from lead object using batch apex.

Is it possible to do that?
Hello,

I have certain fields on my paglayout. X, Y, Z.

I want to ad a button on the page, say..Custom button.

When "Custom button" is clicked, i want to call a APEXclassName.FunctionName(Value of CustomField X, Value of CustomField Y, Z).

I want to execute like this.

How cani implement the same

Thank you in advance
  • January 29, 2019
  • Like
  • 0
Hi everyone,
I hope you can help me. I need to generate a JSON but the format i get it's not like I require.

I get:
"portalReformasNecesariasEdificio" : false,
"portalReformasNecesarias" : false,
"porcentajePropiedad" : 100.00,
"plazoContratoDatosOcupacionales" : null,
"plantas" : [ {
    "attributes" : {
      "type" : "HAY_Informe_Mediadores_Planta__c",
      "url" : "/services/data/v44.0/sobjects/HAY_Informe_Mediadores_Planta__c/a1G3E0000014zl0UAA"
    },
    "Id" : "a1G3E0000014zl0UAA",
    "HAY_Informe_Mediadores__c" : "a1i3E000000PvmrQAC",
    "HAY_Floor_Number__c" : 0,
    "HAY_Room_Type__c" : "01",
    "HAY_Room_Number__c" : 3
  }, {
    "attributes" : {
      "type" : "HAY_Informe_Mediadores_Planta__c",
      "url" : "/services/data/v44.0/sobjects/HAY_Informe_Mediadores_Planta__c/a1G3E0000014zl1UAA"
    },
    "Id" : "a1G3E0000014zl1UAA",
    "HAY_Informe_Mediadores__c" : "a1i3E000000PvmrQAC",
    "HAY_Floor_Number__c" : 0,
    "HAY_Room_Type__c" : "02",
    "HAY_Room_Number__c" : 1
  }],
//more fields

I need:
//fields
"plantas": [
        {
          "roomtype": "01",
          "roomnumber": "3",
          "floornumber": "0"
        },
        {
          "roomtype": "02",
          "roomnumber": "1",
          "floornumber": "0"
        },
        //etc
//more fields
I dont know how to get the result I need. I'm using a wrapper with the fields of the parent object and a list to save the child records and the JSON.SerializePretty method
class wrapper{
   //fields of the parent object {get; set;}
   List<Child__c> childs {get; set;}

   public wrapper(Parent__c parent, List<Child__c> listChilds){
     //parent fields = parent.field
     childs = listChilds
   }
}

class AnotherClass {
  //Logic to get parent data
  //Logic to get list of childs
  public method{
      String jsonBody = JSON.prettySerialize(new wrapper(parent, child),false);
  }
}

I hope you can help I'm not able to solve this.
Thanks in advance.
 
Hi All, Plz help me out. This is the test class code for a button to delete all the sub object records. while saving it is giving error as "Constructor not defined: [PhaseDeleteAllLinesExt].<Constructor>(ApexPages.StandardController)"

below is the test class
******

@isTest
public class PhaseDeleteAllLinesExtTest {
        
        static testMethod void MyTest()
        {       

            list<opportunity> opp = [select id, name from opportunity where id='0060h000010bfWz'];
            
            Project_Phase_Plan__c  plan = new Project_Phase_Plan__c ();
            plan.Phase_Plan_Description__c = 'Testing';

            insert plan;
            
            Project_Phase__c phase = new Project_Phase__c();
            phase.Project_Phase__c = 1;
            phase.Trade__c = 'Glazier';

            insert phase ;
                        
            PageReference pageRef = Page.ProjectPhaseDeleteAllLines;
            // VF Page name is 'ProjectPhaseDeleteAllLines'.
            pageRef.getparameters().put('Id', plan.id);
            Test.setCurrentPage(pageRef);

            Apexpages.StandardController sc = new Apexpages.StandardController(plan);
            PhaseDeleteAllLinesExt ext = new PhaseDeleteAllLinesExt(sc);
            ext.deleteAllLines();     

           ext.close();

        }
    
         static testMethod void MyTest2()
             {
                Project_Phase__c phase = new Project_Phase__c();
                phase.Project_Phase__c=1;

            insert phase ;

            Project_Phase_Plan__c  plan = new Project_Phase_Plan__c ();
            plan.Phase_Plan_Description__c = 'Testing';

            insert plan;
             
            PageReference pageRef = Page.ProjectPhaseDeleteAllLines;
            // VF Page name is 'ProjectPhaseDeleteAllLines'.
            Test.setCurrentPage(pageRef);

            Apexpages.StandardController sc = new Apexpages.StandardController(plan);
            PhaseDeleteAllLinesExt ext = new PhaseDeleteAllLinesExt(sc);        
            ext.deleteAllLines();     

           ext.close();

        }
    }


 
Hello,

I am making a SOQL quesry to object contact and lead.

From the values i get from the SOQL query, i will construct need to construct a JSON

I have multiple tree, like example below:
https://json.org/example.html
{
    "glossary": {
        "title": "example glossary",
		"GlossDiv": {
            "title": "S",
			"GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
					"SortAs": "SGML",
					"GlossTerm": "Standard Generalized Markup Language",
					"Acronym": "SGML",
					"Abbrev": "ISO 8879:1986",
					"GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
						"GlossSeeAlso": ["GML", "XML"]
                    },
					"GlossSee": "markup"
                }
            }
        }
    }
}

How can i construct a JSON from SOQL responce?
  • January 24, 2019
  • Like
  • 0
Hi,
I have created an EmailMessage, but I cannot fetch the name of the attachments through "EmailMessage.Attachments", so how? Any examples?

Hi,

 

I would like to create a VF page that has two pages/views combined on one page. For example,


VF page:

l       layer1            l      layer 2               l
l                            l                               l
l                            l                               l
l                            l                               l
l                            l                               l
l                            l                               l
l                            l                               l
l                            l                               l
l                            l                               l
l                            l                               l
l                            l                               l
l                            l                               l
l                            l                               l
l                            l                               l
 

The Left side of the view:


Layer 1 will have some kind of a text area for user to include their input. After user included their input, there will be a button to press for "Ok".. *I know how to make this page but I do not know how to make it in one side in this case on the left side of the view*

The right side of the view:

this will print all the values that inserted by user. *For printing, I think I know how to do but I do not know how to make it at the right side*

My question is how to make these two layers to be side by side and to have their own information.

We made a very minor change to the apex class where we included a field in the Email mathod in the class, however when we tried to deploy we get attempt to de-reference null object error.
Test class:
 
public static testMethod void testUpdateRegistration2(){

Course__c newCourse = new Course__c();
newCourse.Total_Sessions__c = 3;
newCourse.Session_No__c = 001;
newCourse.Registration_Time__c = '8:45AM';
newCourse.Number_of_Days__c = 1;
newCourse.Name = 'Apex Test Course';
newCourse.Minimum_Attendee__c = 5;
newCourse.Maximum_Attendee__c = 10;
newCourse.GST__c = 10;
newCourse.GST_Exempt_Course__c = false;
newCourse.Course_Type__c = 'Face to Face';
newCourse.Course_Start_Time__c = '9:00AM';
newCourse.Course_Number__c = 'C001';
newCourse.Course_End_Time__c = '5:00PM';
newCourse.Course_Classification__c = 'Public';
newCourse.ChargeID__c = 'PRC_999';
newCourse.Category__c = 'Food';
newCourse.Base_Price__c = 999;
insert newCourse;

datetime t = System.now();
date today = Date.newInstance(t.year(),t.month(),t.day());

Class__c newClass = new Class__c();
newClass.Name = 'Apex Test Class';
newClass.Minimim_Attendee__c = 9;
newClass.Maximum_Attendee__c = 99;
newClass.Course_Name__c = newCourse.Id;
newClass.Class_Location__c = 'Sydney';
newClass.Class_Begin_Date__c = today;
newClass.Class_End_Date__c = today;
newClass.Number_of_Confirmed_Attendees__c = 10;
newClass.Class_Status__c = 'Open';
insert newClass;

Account newAccount = new Account();
newAccount.Same_As_Address__c = 'true';
newAccount.Name = 'Apex Test';
//newAccount.ParentId = newAccountParent.Id;
newAccount.Mailing_Zip_Postal_Code__c = '2009'; 
newAccount.Mailing_Street__c = 'Fake Mailing Street';
newAccount.Mailing_State_Province__c = 'NSW';
newAccount.Mailing_Country__c = 'AUSTRALIA';
newAccount.Mailing_City__c = 'Sydney';
newAccount.CurrencyIsoCode = 'AUD';
newAccount.Business_Zip_Postal_Code__c = '1000'; 
newAccount.Business_Street__c = 'Fake Business Street';
newAccount.Business_State_Province__c = 'NSW';
newAccount.Business_Country__c = 'AUSTRALIA';
newAccount.Business_City__c = 'Sydney';
newAccount.Account_Classification__c = 'Business';
insert newAccount;

Account newVenueAccount = new Account();
newVenueAccount.Same_As_Address__c = 'true';
newVenueAccount.Name = 'Apex Venue Test';
newVenueAccount.Mailing_Zip_Postal_Code__c = '2009'; 
newVenueAccount.Mailing_Street__c = 'Fake Mailing Street';
newVenueAccount.Mailing_State_Province__c = 'NSW';
newVenueAccount.Mailing_Country__c = 'AUSTRALIA';
newVenueAccount.Mailing_City__c = 'Sydney';
newVenueAccount.CurrencyIsoCode = 'AUD';
newVenueAccount.Business_Zip_Postal_Code__c = '1000'; 
newVenueAccount.Business_Street__c = 'Fake Business Street';
newVenueAccount.Business_State_Province__c = 'NSW';
newVenueAccount.Business_Country__c = 'AUSTRALIA';
newVenueAccount.Business_City__c = 'Sydney';
newVenueAccount.Account_Classification__c = 'Business';
newVenueAccount.Type = 'Venue';
insert newVenueAccount;

Contact newContact = new Contact();
newContact.FirstName='John';
newContact.LastName='Doe';
newContact.Phone='0299998888';
newContact.Email = 'john.doe@fake.com';
newContact.AccountId = newAccount.Id;
newContact.Dietary_Requirements__c = 'ABC';
insert newContact;

Contact newContact1 = new Contact();
newContact1.LastName='Master';
newContact1.Email = 'a.master@fake.com';
newContact1.Phone = '0288889999';
newContact1.AccountId = newVenueAccount.Id;
insert newContact1;

Contact newContact2 = new Contact();
newContact2.Job_Title__c = 'National Manager';
newContact2.LastName='Master';
//newContact2.Email = 'a.master@fake.com';
newContact2.AccountId = newAccount.Id;
newContact2.MobilePhone = '0499999999';
insert newContact2;

Trainer_Approved_Course__c tac = new Trainer_Approved_Course__c();
tac.Name = 'Apex Trainer Approved Course';
tac.Trainer__c = newContact.Id;
tac.Expiration_Date__c = today + 100000;
tac.Course__c = newCourse.Id;
tac.Approved__c = true;
tac.CurrencyIsoCode = 'AUD';
insert tac;

Trainer_Approved_Course__c tac2 = new Trainer_Approved_Course__c();
tac2.Name = 'Apex Trainer Approved Course 2';
tac2.Trainer__c = newContact2.Id;
tac2.Expiration_Date__c = today + 100000;
tac2.Course__c = newCourse.Id;
tac2.Approved__c = true;
tac2.CurrencyIsoCode = 'AUD';
insert tac2;


Class__c newClass1 = new Class__c();
newClass1.Name = 'Apex Test Class';
newClass1.Minimim_Attendee__c = 9;
newClass1.Maximum_Attendee__c = 99;
newClass1.Course_Name__c = newCourse.Id;
newClass1.Class_Location__c = 'Sydney';
newClass1.Class_Begin_Date__c = today;
newClass1.Class_End_Date__c = today;
newClass1.Number_of_Confirmed_Attendees__c = 10;
newClass1.Class_Status__c = 'Open';
newClass1.Trainer_1__c = newContact.Id;
newClass1.Trainer_2__c = newContact1.Id;
newClass1.Venue__c = newVenueAccount.Id;
newClass1.Num_Material_Ordered__c = 10;
newClass1.Date_Material_Ordered__c = today;
newClass1.Num_in_Stock__c = 10;
newClass1.Num_Material_Printed__c = 5;
newClass1.Num_Standards_Out__c = 10;
newClass1.Num_Standards_In__c = 10;
newClass1.Boxes__c = 2;
newClass1.Job_Reference__c = 'N/A';
newClass1.Date_Material_Sent__c = today;
newClass1.Comments_Materials__c = 'N/A';
insert newClass1;

Id[] originalRegIds = new Id[0];
Registration__c newAttendee = new Registration__c();
newAttendee.Course_Name__c = newCourse.Id;
newAttendee.Attendee__c = newContact.Id;
newAttendee.Class_Name__c = newClass.Id;
newAttendee.Total_Amount__c = 999;
newAttendee.Status__c = 'Confirmed';
insert newAttendee;
originalRegIds.add(newAttendee.Id);

Registration__c newAttendee1 = new Registration__c();
newAttendee1.Course_Name__c = newCourse.Id;
newAttendee1.Attendee__c = newContact.Id;
insert newAttendee1;
originalRegIds.add(newAttendee1.Id);

Registration__c newAttendee2 = new Registration__c();
newAttendee2.Course_Name__c = newCourse.Id;
newAttendee2.Class_Name__c = newClass.Id;
newAttendee2.Attendee__c = newContact.Id;
newAttendee2.Status__c = 'Pended-SAI Cancellation';
insert newAttendee2;
originalRegIds.add(newAttendee2.Id);

Registration__c newAttendee3 = new Registration__c();
newAttendee3.Course_Name__c = newCourse.Id;
newAttendee3.Class_Name__c = newClass1.Id;
newAttendee3.Attendee__c = newContact1.Id;
newAttendee3.Status__c = 'Confirmed';
insert newAttendee3;

Registration__c newAttendee4 = new Registration__c();
newAttendee4.Course_Name__c = newCourse.Id;
newAttendee4.Class_Name__c = newClass1.Id;
newAttendee4.Attendee__c = newContact2.Id;
newAttendee4.Status__c = 'Confirmed';
insert newAttendee4;

Certificate_Template__c newCertificateTemplate = new Certificate_Template__c();
newCertificateTemplate.Name = 'Apex Test Certificate Template';
newCertificateTemplate.CurrencyIsoCode = 'AUD';
insert newCertificateTemplate;

Certificate_Type__c newCertificateType = new Certificate_Type__c();
newCertificateType.Name = 'Statement of Attendance';
newCertificateType.Course_Name__c = newCourse.Id;
newCertificateType.Certificate_Title__c = 'Statement of Attendance';
newCertificateType.Certificate_Template__c = newCertificateTemplate.Id;
newCertificateType.Certificate_Options__c = 'Always Issued';
insert newCertificateType;

// reset governor limit
Test.startTest();

Assessment__c newAssessment = new Assessment__c();
newAssessment.Name = 'Statement of Attendance';
newAssessment.Assessment_Title__c = newCertificateType.Id;
newAssessment.Assessment_Status__c = 'Competent';
newAssessment.Attendee_ID__c = newAttendee.Id;
newAssessment.Assessor__c = newContact.Id;
newAssessment.Received_from_Assessor__c = today;
insert newAssessment;

Assessment_Competency__c newAssessmentCompetency = new Assessment_Competency__c();
newAssessmentCompetency.Name = 'Apex Test Assessment Competency';
newAssessmentCompetency.CurrencyIsoCode = 'AUD';
newAssessmentCompetency.Competency_Code__c = 'ApexTest_9999';
newAssessmentCompetency.Assessment__c = newAssessment.Id;
insert newAssessmentCompetency;

Invoice_ENT__c newInvoiceENT = new Invoice_ENT__c();
newInvoiceENT.Registration__c = newAttendee.Id;
newInvoiceENT.CurrencyIsoCode = 'AUD';
newInvoiceENT.Base_Price__c = 998;
newInvoiceENT.Payment_Status__c = 'c';
newInvoiceENT.Invoice_Type__c = 'ACR';
newInvoiceENT.Bill_Type__c = 'EAR';
insert newInvoiceENT;

Invoice_ENT__c newInvoiceENT1 = new Invoice_ENT__c();
newInvoiceENT1.Registration__c = newAttendee.Id;
newInvoiceENT1.CurrencyIsoCode = 'AUD';
newInvoiceENT1.Base_Price__c = 998;
newInvoiceENT1.Payment_Status__c = 'c';
newInvoiceENT1.Invoice_Type__c = 'REG';
newInvoiceENT1.Bill_Type__c = 'PUB';
insert newInvoiceENT1;

 try{
    Integer processType = 1;
    ClassObj.classcancellation(newClass.Id, processType);
    ClassObj.sendAttendanceList(newClass1.Id);
    ClassObj.sendAttendanceList_TIS(newClass1.Id);
    //System.assertEquals(0, classObj.checkPendingRegos(newClass.Id));
} catch (System.EmailException e){
    System.debug('we caught a email exception: ' + e.getDmlMessage(0));
}

Test.stopTest();
From the above code bold syntax is the line number 1071

Please find the image below of the error I get during deployment.
User-added image
Class:
 
WebService static Id[] sendAttendanceList_TIS(Id ClassId) {

//Modified by sneh@sqwarepeg.com to include more venue and class material details
Class__c classObj = [Select Trainer_1__c, Trainer_1__r.Id, Trainer_1__r.Email,Trainer_1__r.EmailBouncedDate, 
Trainer_1__r.EmailBouncedReason,Trainer2__c, Trainer2__r.Id, Trainer2__r.Email, Trainer2__r.EmailBouncedDate, 
Trainer2__r.EmailBouncedReason, Trainer_2__c, Trainer_2__r.Id, Trainer_2__r.EmailBouncedDate, 
Trainer_2__r.EmailBouncedReason,Trainer_2__r.Email, Id, Venue__r.Id, Venue__r.Name, Venue__r.Business_Street__c, 
Venue__r.Business_City__c, Venue__r.Business_State_Province__c, Venue__r.Business_Zip_Postal_Code__c, 
Venue__r.Business_Country__c, Venue__r.Website, Venue__r.Phone, Venue__r.Internet_Email__c, Venue__r.Comments__c, 
Course_Name__r.Name, Class_Location__c, Class_End_Date__c, Class_Begin_Date__c, Num_in_Stock__c, 
Num_Standards_Out__c, Num_Standards_In__c, Num_Material_Printed__c, Num_Material_Ordered__c, Job_Reference__c, 
Date_Material_Sent__c, Date_Material_Ordered__c, Comments_Materials__c, Boxes__c 
From Class__c where Id =:ClassId];

//Modified by suzan@sqwarepeg.com, validation of the bounced emails
//Modified by sneh@sqwarepeg.com on 12/02/2009 to incorporate the Primary_Venue_Contact__c functionality
Contact[] conObj = [Select Id, Email, AccountId,EmailBouncedDate,EmailBouncedReason From Contact where AccountId =:classObj.Venue__r.Id and Primary_Venue_Contact__c = true];

//Contact[] conObj = [Select Id, Email, AccountId From Contact where AccountId =:classObj.Venue__r.Id];
//Query course field to add them in the Email template.
Course__c crs = [select id,Current_Revision__c from Course__c limit 1];
//if (classObj.Trainer_1__r.Email != null || classObj.Trainer_2__r.Email != null || conObj.Email != null) {
String jobTitle;
String email;
String phone;
String mobile;
String dietaryNeeds;
String accessNeeds;
String HTMLBody;

List<Id> RegIds = new List<Id>();
RegIds = getConfirmedIds(ClassId);

HTMLBody = 'Hi,<br><br>';
HTMLBody = HTMLBody + 'Please find attached the Attendance List for SAI Global\'s course.<br><br>';
HTMLBody = HTMLBody + 'Please print off a copy and hand to the Trainer on the morning of the course.<br><br>';
HTMLBody = HTMLBody + 'If you have any questions please don\'t hesitate to contact our Customer Service Team on 1-800-374-3818.<br><br>';
HTMLBody = HTMLBody + 'Kind Regards,<br>Training and Improvement Solutions<br><br>';
HTMLBody = HTMLBody + '<b><u>Course Information</u></b><br><br>';
if(classObj.Class_End_Date__c != null){
    HTMLBody = HTMLBody + 'Course Name: ' + classObj.Course_Name__r.Name + '<br>' + 'Current Revision:' + crs.Current_Revision__c.format() + '<br>' + 'Class Dates: ' + classObj.Class_Begin_Date__c.day() + '/' + classObj.Class_Begin_Date__c.month() + '/' + classObj.Class_Begin_Date__c.year() + ' - ' + classObj.Class_End_Date__c.day() + '/' + classObj.Class_End_Date__c.month() + '/' + classObj.Class_End_Date__c.year() + '<br>';
} else {
    HTMLBody = HTMLBody + 'Course Name: ' + classObj.Course_Name__r.Name + '<br>' + 'Current Revision:' + crs.Current_Revision__c.format() + '<br>' + 'Class Dates: ' + classObj.Class_Begin_Date__c.day() + '/' + classObj.Class_Begin_Date__c.month() + '/' + classObj.Class_Begin_Date__c.year() + ' - N/A<br>';
}
HTMLBody = HTMLBody + 'Class Location: ' + classObj.Class_Location__c + '<br><br>';

From the above code, The bold Syntax is line 429.

Please advise.

Thanks

 
Hello,

i have some trouble deploying a trigger and an approval process. The Process exists in an older version in the production environment.
The changeset includes the Trigger, Testclass and new version of approval process.
When i run the test-class in production, i am getting this error:
 
System.DmlException: Process failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Too many retries of batch save in the presence of Apex triggers with failures: when triggers are present partial save requires that some subset of rows save without any errors in order to avoid inconsistent side effects from those triggers. Number of retries: 2: [] 
Stack Trace: Class.TrgKnowledgeSendNotificationTest.test01: line 80, column 1

It runs in our sandbox without any errors.

Do i need to deploy the new version of approval process seperatly in advace of deploying the trigger?

thanks
PEter
Hi All,
      my requirement is  to Create a trigger that uses the From Address of the Email Message object on a new Case to update the Case Owner. The Case Owner will be the user that sent the email and will be identified by their email address as it corresponds to active users on the user table 

FromAddress = User.Email the assign CaseOwner = User.Id 
my triggerHelper class is as follow:-
public class EmailMessageTriggerHelper {
    
    public static List<EmailMessage> newEmailMessages = new List<EmailMessage>();
    public static List<EmailMessage> oldEmailMessages = new List<EmailMessage>();
    public static Map<Id, EmailMessage> newMapEmailMessages = new Map<Id, EmailMessage>();
    public static Map<Id, EmailMessage> oldMapEmailMessages = new Map<Id, EmailMessage>(); 
          
    public static void UpdateOwner(){
        set<Id> caseIds = new set<Id>();
        map<Id,string> case2OwnerValueMap = new map<Id,string>();
        for(EmailMessage message : newEmailMessages){
            if(message.Incoming == false){
                string OwnerValue;
                message.FromAddress = String.Valueof(User.Email);

            caseIds.add(message.ParentId);
            case2OwnerValueMap.put(message.ParentId, OwnerValue);
        }
    }
    list<Case> casesToUpdate = [Select Id, OwnerId   From Case Where Id in: caseIds];
    for(Case c : casesToUpdate){
        c.OwnerId = case2OwnerValueMap.get(c.Id);
    }

    update casesToUpdate;
        
     }    
}
Am i missing something?
guide me?
Any suggestions?
public with sharing class Account_manager{
    public Contact placeholderContact{get;set;}
    public List<Contact> accountContacts{get;set;}
    
    public Account_manager(){
    placeholderContact= new Contact();
    accountContacts= new List<Contact>();
    }
}
I wish to create radiobutton that could allow user to click on the correct output shown on vf page. 


Example, 

Output 1: Do Many things  *radiobutton*
Output 2: Do Nothing *radiobutton*
Output 3: Do something for myself *radiobutton*

When the user choose tick output 1 or any other output, these ticked outputs will be stored in task. 

My attempt for VF page:

                                        <apex:selectRadio id="subject" value="{!subject}" size="1" > 
                                        <apex:selectoption itemLabel="{!td}" itemValue="{!td}"></apex:selectoption>
                                        </apex:selectRadio>


My attempt for Apex controller:

String userId = UserInfo.getUserId();
    
    Task t = new Task();
    t.OwnerId = userId;
    t.Subject = subject;
    t.Status = 'Open';
    t.Priority = 'Normal';    
    insert t;
    
How should I modify my code in order for it to have the buttons that can be clicked and after clicking it, the value relevant to the output will be stored as our subject? 
I am writing a scheduled class for sending emails for user who have not logged in to salesforce for 30 days, Code is working fine but now I am confused how to write test classes for that, Because all of my conditions are based on Last Login Date which is Un-Editable. Can I take data from a existing user? If i take in such a way will it effect when i move my code to other sandbox/Production? If so how to solve this.

!! Please Help !!

Thanks & Regards
Harsha.