• Gunwinder Singh 4
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 6
    Replies
I am new to APEX and would need some direction as where I am wrong. In the following I am just trying to update the description of the Opportunity when it is Closed Lost, Closed Won or when it is in any other status
trigger OpportunityTrigger on Opportunity (before insert,after insert) {
    
    if(trigger.isInsert){
        if(trigger.isBefore){
        OpportunityTriggerHandler.UpdateLatestOpportunityAmt(trigger.new);
        OpportunityTriggerHandler.UpdateDescriptionWhenOpenOrLost(trigger.new, null);
        }
    } 
    
    if(trigger.isUpdate){
        if(trigger.isbefore){
        OpportunityTriggerHandler.UpdateDescriptionWhenOpenOrLost(trigger.new, trigger.oldMap);
      }
    }

}
Trigger handler
 
public class OpportunityTriggerHandler {
    
    
    public static void UpdateLatestOpportunityAmt(list<opportunity> OppList){
        list<account> accListTemp = new list<account>();
        
        for(Opportunity Op : OppList){
            account acc = new account();
            acc.id=Op.AccountId;
            acc.Latest_Opportunity_Amount__c = Op.Amount;
            accListTemp.add(acc);
        }
        if(accListTemp!=null){
        update accListTemp;    
        }
        
    }//------ end 
    
    public static void UpdateDescriptionWhenOpenOrLost(list<opportunity> oppList, Map<id,Opportunity> oldMap){
        
        for(Opportunity opp:oppList){
            //if insert operation was done 
            if (oldMap ==null || opp.StageName != oldMap.get(opp.id).StageName){
                if(opp.StageName=='Closed Won'){
                    opp.Description ='Opportunity is Closed Won';
                    system.debug('Opportunity is Closed Won');
                
                } else if (opp.StageName=='Closed Lost'){
                    opp.Description ='Opportunity is Closed Lost';
                    system.debug('Opportunity is Closed Lost');
                
                }else{
                    opp.Description ='Opportunity is Open';
                    system.debug('Opportunity is open');
                }
            }
            
        }
        
    }

}

Thanks, 
Gunwinder
 
I need help with invocable apex class that takes collection (string) and formats it replacing the second last comma to an and:

Raw string : Amy, Rose, Gary
Formatted: Amy, Rose and Gary.

testing on anonymous code block, i get the desired output however when using it on a Apex class it fails.
 
Anoymous code block : 

string inputString = 'Amy, Rose,Mary';

integer indexOfSecondLastComma = inputString.lastIndexOf(',',
                                 inputString.lastIndexOf(','));

//replace 
string outputString = 
inputString.substring(0,indexOfSecondLastComma) + ' and '+
inputString.substring(indexOfSecondLastComma+1);

system.debug(outputString);
 
public class FormatSendersInv{
    
    @InvocableMethod(label='Format Contact Names'
                     description='Returns the string for sending email for deceased contacts'
                     category='WC_ApexActions')

    public static LIST<string> getString(LIST<string> StrCol){
            LIST<string> outputStrings = new LIST<string>(); 
    	    string inputString = '';
        
        for (string s:StrCol){
            inputString = inputString+s;
        }
        
        integer indexOfSecondLastComma = inputString.lastIndexOf(',',
                                                                 inputString.lastIndexOf(','));
        
        //replace 
        string outputString = 
            inputString.substring(0,indexOfSecondLastComma) + ' and '+
            inputString.substring(indexOfSecondLastComma+1);
        	outputStrings.add(outputString);
        	system.debug(outputString);
    return outputStrings;
    }
}

I am new to apex, please suggest what I am doing wrong here.
I am facing an issue with fetching the path of image stored in documents (available for external user). 

When the visualforce page is rendered the image shows broken upon inspecting the element it does not capture URL generated from String variable "imageURL". 

Here I am trying to adjust the URL based of image because of enhanced domains release update.

Please suggest as what I may be doing wrong. 

Class: 
public class BBH_Survey {
    public boolean hidecmtbtn{get;set;}
    public boolean modibtn {get;set;} //
    Public String CasId;
    Public String Survey_comments {get;set;} 
    public boolean flag{get;set;}
    public list<BBH_Surveys__c> lstbbhsury;
    public Decimal survyeExpired {get;set;}
    public String btncss{get;set;}
    public String ratingCss{get;set;}
   // Public New_Surveys__c surveyName {get;set;}//
   // public String modifySurvey{get;set;}//
    public string surveyId;
    public String imageURL{get;set;}//
    //public String modiRes {get;set;}//
        
    public BBH_Survey(apexPages.StandardController std) 
    {
        // fetch instance Id : NA169.. etc
        String instanceName = [select InstanceName from Organization limit 1].InstanceName; 
        hidecmtbtn=true;
        Survey_comments='';
        flag=false;
        CasId=ApexPages.currentPage().getParameters().get('CaId'); 
        surveyId = Apexpages.currentPage().getParameters().get('id');
        lstbbhsury=[select id from BBH_Surveys__c where CaseId__c =:CasId]; 
        
        List<New_Surveys__c> schoolsurvey =[select Rating_Css__c,Button_css__c,Survey_Expired__c,School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId]; 
        
        if(schoolsurvey.size()>0){      
       
       // String orgid='&oid=00Dd0000000dwdA';
         Organization organizationInfo = [Select id from Organization];
         string organizationId= organizationInfo.id; 
         String orgid='&oid='+organizationId;
            
         survyeExpired=schoolsurvey[0].Survey_Expired__c;
         btncss=schoolsurvey[0].Button_css__c;  
         ratingCss=schoolsurvey[0].Rating_Css__c;
         
         // fetch baseURL & convert to respect Enhanced domain changes
         
         string baseURL = URL.getSalesforceBaseUrl().toExternalForm() +'/'; 
         string baseimageURL;
         // target Sanbdbox envoirnment
         
         if (baseURL.contains('sandbox.my.salesforce.com')){
         baseURL=baseURL.replace('sandbox.my.salesforce.com', 'sandbox.my.salesforce-sites.com');
         baseimageURL=baseURL.replace('sandbox.my.salesforce-sites.com', 'sandbox.file.force.com');
        
         }
         
         // target Production envoirnment 
         
         else if (baseURL.contains('ceai.my.salesforce.com')){
         baseURL=baseURL.replace('ceai.my.salesforce.com', 'ceai.my.salesforce-sites.com');
         baseimageURL=baseURL.replace('ceai.my.salesforce-sites.com', 'ceai.file.force.com');
         }
         system.debug(' baseURL  :' +baseURL);
         system.debug(' imageURL  :' +baseimageURL);   
         
     // imageURL='Https://ceai--c.'+instanceName+'.content.force.com/servlet/servlet.ImageServer?id='+schoolsurvey[0].School_Logo__c+orgid;
        imageURL=baseimageURL+'/servlet/servlet.ImageServer?id='+schoolsurvey[0].School_Logo__c+orgid;
        } 
        else {
        system.debug('Error in fetching School survey record configuration, check if the New Survey record is created');
        }
        
            
     linkExpire();
    
    }  
    
    Public  PageReference survey_1(){
        
        try{ 
            
            List<case> lstCase=[select id,status ,Survey_fill__c from case where id =:CasId]; 
            List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];            string url=schoolsurvey[0].School_URL__c;
            PageReference myVFPage = new PageReference(url);
            BBH_Surveys__c bbh=new BBH_Surveys__c();
            
            if(lstCase.size()>0)
            {
            bbh.CaseId__c=lstCase[0].id;
            }
               bbh.Survey_Response__c= '1';
               bbh.Surveys_Name__c=surveyId;    
               bbh.Survey_Comments__c =Survey_comments;
        
              insert bbh;
             myVFPage.setRedirect(true);
              return myVFPage; 
        } 
        catch(Exception e)
        { return null; }
            
    }
        

    
Public  PageReference survey_2(){
    
  
    try{
    List<case> lstCase=[select id,status ,Survey_fill__c from case where id =:CasId];
    List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        
        string url=schoolsurvey[0].School_URL__c;
        PageReference myVFPage = new PageReference(url);
        BBH_Surveys__c bbh=new BBH_Surveys__c();
          if(lstCase.size()>0)
            {
            bbh.CaseId__c=lstCase[0].id;
            }
               bbh.Survey_Response__c= '2';
               bbh.Surveys_Name__c=surveyId;    
        	   bbh.Survey_Comments__c =Survey_comments;
        
              insert bbh;
              myVFPage.setRedirect(true);
              return myVFPage;
        } 
       catch(Exception e) {        
       return null;
        }
 }
        

    Public  PageReference survey_3(){
  
    try{
    List<case> lstCase=[select id,status ,Survey_fill__c from case where id =:CasId];
    List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        // PageReference myVFPage = page.Survey_saved;
        string url=schoolsurvey[0].School_URL__c;
        PageReference myVFPage = new PageReference(url);
              BBH_Surveys__c bbh=new BBH_Surveys__c();
               if(lstCase.size()>0)
            {
            bbh.CaseId__c=lstCase[0].id;
            }
               bbh.Survey_Response__c= '3';
               bbh.Surveys_Name__c=surveyId;    
               bbh.Survey_Comments__c =Survey_comments;
        
              insert bbh;
             myVFPage.setRedirect(true);
             return myVFPage;
        } 
        catch(Exception e) 
        {return null;}
            
    }
    

    
    Public  PageReference survey_4(){
      
    try{
    List<case> lstCase=[select id,status ,Survey_fill__c from case where id =:CasId];
    List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        // PageReference myVFPage = page.Survey_saved;
        string url=schoolsurvey[0].School_URL__c;
        PageReference myVFPage = new PageReference(url);
              BBH_Surveys__c bbh=new BBH_Surveys__c();
               if(lstCase.size()>0)
            {
            bbh.CaseId__c=lstCase[0].id;
            }
               bbh.Survey_Response__c= '4';
               bbh.Surveys_Name__c=surveyId;    
               bbh.Survey_Comments__c =Survey_comments;
      
              insert bbh;
                 
             myVFPage.setRedirect(true);
                   
              return myVFPage;
        } catch(Exception e) 
        { return null; }
            
    }
        
    public  PageReference survey_5()
    {
        
     try{
    List<case> lstCase=[select id,status ,Survey_fill__c from case where id =:CasId];
    List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        // PageReference myVFPage = page.Survey_saved;
        string url=schoolsurvey[0].School_URL__c;
        PageReference myVFPage = new PageReference(url);
              BBH_Surveys__c bbh=new BBH_Surveys__c();
               if(lstCase.size()>0)
            {
            bbh.CaseId__c=lstCase[0].id;
            }
               bbh.Survey_Response__c= '5';
               bbh.Surveys_Name__c=surveyId;    
               bbh.Survey_Comments__c =Survey_comments;
      
              insert bbh;
                 
             myVFPage.setRedirect(true);
                   
              return myVFPage;
        } catch(Exception e) 
        { return null; }
            
}
     
 
   public PageReference modifyResponce1() 
    {
     List<BBH_Surveys__c> BBHSurList =[select id,Survey_Response__c from BBH_Surveys__c where CaseId__c=:CasId limit 1];
         List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        // PageReference myVFPage = page.Survey_saved;
        string url=schoolsurvey[0].School_URL__c;   
       PageReference myVFPage = new PageReference(url);  
       BBH_Surveys__c bbt=new BBH_Surveys__c();
        if(BBHSurList.size()>0)
        {
        bbt.id=BBHSurList[0].id;
        }   
        bbt.Survey_Response__c='1';
        update bbt;
        myVFPage.setRedirect(true);
        return myVFPage;
    }
        
        public PageReference modifyResponce2() 
    {
     List<BBH_Surveys__c> BBHSurList =[select id,Survey_Response__c from BBH_Surveys__c where CaseId__c=:CasId limit 1];
         List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        // PageReference myVFPage = page.Survey_saved;
        string url=schoolsurvey[0].School_URL__c;   
       PageReference myVFPage = new PageReference(url);  
       BBH_Surveys__c bbt=new BBH_Surveys__c();
        if(BBHSurList.size()>0)
        {
        bbt.id=BBHSurList[0].id;
        }   
        bbt.Survey_Response__c='2';
        update bbt;
        myVFPage.setRedirect(true);
        return myVFPage;
    }
        
        public PageReference modifyResponce3() 
    {
     List<BBH_Surveys__c> BBHSurList =[select id,Survey_Response__c from BBH_Surveys__c where CaseId__c=:CasId limit 1];
         List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        // PageReference myVFPage = page.Survey_saved;
        string url=schoolsurvey[0].School_URL__c;   
       PageReference myVFPage = new PageReference(url);  
       BBH_Surveys__c bbt=new BBH_Surveys__c();
      if(BBHSurList.size()>0)
        {
        bbt.id=BBHSurList[0].id;
        }   
        bbt.Survey_Response__c='3';
        update bbt;
            myVFPage.setRedirect(true);
        
        return myVFPage;
    }
        
        public PageReference modifyResponce4() 
       {
     	 List<BBH_Surveys__c> BBHSurList =[select id,Survey_Response__c from BBH_Surveys__c where CaseId__c=:CasId limit 1];
         List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        
           // PageReference myVFPage = page.Survey_saved;
           string url=schoolsurvey[0].School_URL__c;   
           PageReference myVFPage = new PageReference(url);  
           BBH_Surveys__c bbt=new BBH_Surveys__c();
       
           if(BBHSurList.size()>0)
           {
             bbt.id=BBHSurList[0].id;
           }   
        bbt.Survey_Response__c='4';
        update bbt;
            myVFPage.setRedirect(true);
        
        return myVFPage;
    }
        
        public PageReference modifyResponce5() 
        {
         List<BBH_Surveys__c> BBHSurList =[select id,Survey_Response__c from BBH_Surveys__c where CaseId__c=:CasId limit 1];
         List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        // PageReference myVFPage = page.Survey_saved;
         string url=schoolsurvey[0].School_URL__c;   
          PageReference myVFPage = new PageReference(url);  
          BBH_Surveys__c bbt=new BBH_Surveys__c();
       
            if(BBHSurList.size()>0)
             {
              bbt.id=BBHSurList[0].id;
             }   
        bbt.Survey_Response__c='5';
        update bbt;
        myVFPage.setRedirect(true);
        
        return myVFPage;
    }
    
    
    public  void linkExpire()
    { 
         DateTime dT = System.now();
         Date myDate = date.newinstance(dT.year(), dT.month(), dT.day());
        
             for(case cs:[select ClosedDate from case where id=:casId])
             {
             if(cs.ClosedDate+survyeExpired<myDate)
               {
                 ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Survey link has been expired'));  
                 modibtn=false;
                 hidecmtbtn=false;
           
               }
     
          else if(lstbbhsury.size()>0)
           {
           ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'We see survey is already filled for the ticket. To modify responses, rate the call and click update survey'));
             modibtn=true;
             hidecmtbtn=false;
           }        
         }
    }   
}
Upon inspecting the element User-added image
 
Hi, 

I am trying to write a trigger that trims the number, removing brackets and dashes so that I can build a email address. For some reason the trigger is removing the first 3 characters and I am not able to understand the reason for this. Any pointers will be helpful.

trigger ContactMGT on Contact (before insert,before update) {
    for (contact s : trigger.new){
        string p1=s.Phone.replace('(','');
        string p2=s.Phone.replace(')','');
        string p3=s.Phone.replace('-','');
        
        if(s.Phone==NULL){ s.adderror('Phone can not be blank, please enter a valid number'); }
        if (s.Phone_Service__c=='Alltel'){ s.SMS_Link__c=p3+'@message.alltel.com'; }
        else if (s.Phone_Service__c=='AT&T'){ s.SMS_Link__c=p3+'@txt.att.net'; }
        else if (s.Phone_Service__c=='Boost Mobile'){ s.SMS_Link__c=p3+'sms.cricketwireless.net'; }
        else if (s.Phone_Service__c=='Cricket Wireless'){ s.SMS_Link__c=p3+'@msg.fi.google.com'; }
        else if (s.Phone_Service__c=='Project Fi'){ s.SMS_Link__c=p3+'@msg.fi.google.com'; }
        else if (s.Phone_Service__c=='Sprint'){ s.SMS_Link__c=p3+'@messaging.sprintpcs.com'; }
        else if (s.Phone_Service__c=='T-Mobile'){ s.SMS_Link__c=p3+'@tmomail.net'; }
        else if (s.Phone_Service__c=='Verizon'){ s.SMS_Link__c=p3+'@vtext.com'; }
        else if (s.Phone_Service__c=='Virgin Mobile'){ s.SMS_Link__c=p3+'@vmobl.co'; }
        else if (s.Phone_Service__c=='Republic Wireless'){ s.SMS_Link__c=p3+'@text.republicwireless.com'; } 
    }
}

Thanks.
Need Help.

I am working on a requirement, where when a ticket is lying in a queue and clicks a custom button "Completed" it changes the owner of the ticket to next working group (Queue). 

I have attempted with following code but it simply refreshes the page, please suggest as what is it that I am doing wrong.

/* Personal = 00Gd0000001xwdn */
/* Networking = 00Gd0000001y0e7 */
/* BlackBoard = 00Gd0000001xwe2 */
/* Technical  =00Gd0000001xwdx */


{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} 

var caseObj = new sforce.SObject("Case"); 
caseObj.Id = '{!Case.Id}'; 
if (caseObj.OwnerId ='00Gd0000001xwdn'){
caseObj.OwnerId = '00Gd0000001y0e7';}
 
else if(caseObj.OwnerId ='00Gd0000001y0e7'){
caseObj.OwnerId = '00Gd0000001xwe2';}
 
else if(caseObj.OwnerId ='00Gd0000001xwe2'){ 
caseObj.OwnerId = '00Gd0000001xwdx';}

else {alert("You can not use this button as the owner of ticket does not match the criteria defined");}

caseObj.Status = "Completed"; 
var result = sforce.connection.update([caseObj]); 
window.location.href=window.location.href;

Thanks,
Gary
Wonderful People,

I am new to Visualforce, i would need some direction as to how to create a dynamic email template. We provide support for more than 70 clients and for which we have created custom branded templates (HTML) and therefore need to use equallent workflows and have recently maxed out on 300 active workflows in our Org.

Therefore i want to create a custom dynamic visualforce template that could dynamically fetch the logo. For this i have:

1. Created a Rich Text feild and have added the logo of the institution.
2. Added the following string which gets me a broken image link instead of the image / logo.
<apex:image url="{URLFOR(!relatedTo.AccountLogo__c)}" /> 

Please suggest as what is it i am doing wrong, and if there is any better way to create a dynamic email template.

Thanks in advance,
 
This is in context to the Trail for Advanced Admin Advanced formula challenge:

https://developer.salesforce.com/trailhead/force_com_admin_advanced/advanced_formulas/text_formulas

It asks to sum up the values in the helper feild and i am unable to achieve it, please suggest as where i am missing, so far i have come up with

IF(ISBLANK(Email), 0,
IF(ISBLANK(Phone), 0,
IF(ISBLANK(Company), 0,
IF(ISBLANK(Title), 0,
IF(NOT(ISBLANK(Email)),1,
IF(AND((NOT(ISBLANK(Email))),(NOT(ISBLANK(Phone)))),2,
IF(AND((NOT(ISBLANK(Email))),(NOT(ISBLANK(Phone))),(NOT(ISBLANK(Company)))),3,
IF(AND((NOT(ISBLANK(Email))),(NOT(ISBLANK(Phone))),(NOT(ISBLANK(Company))),(NOT(ISBLANK(Title)))),4,
IF(AND((NOT(ISBLANK(Email))),(NOT(ISBLANK(Phone))),(NOT(ISBLANK(Company))),(NOT(ISBLANK(Title))),(NOT(ISBLANK( TEXT(Industry))))),5,NULL
)))))))))

Thank you in advance.
- Gary
I am new to APEX and would need some direction as where I am wrong. In the following I am just trying to update the description of the Opportunity when it is Closed Lost, Closed Won or when it is in any other status
trigger OpportunityTrigger on Opportunity (before insert,after insert) {
    
    if(trigger.isInsert){
        if(trigger.isBefore){
        OpportunityTriggerHandler.UpdateLatestOpportunityAmt(trigger.new);
        OpportunityTriggerHandler.UpdateDescriptionWhenOpenOrLost(trigger.new, null);
        }
    } 
    
    if(trigger.isUpdate){
        if(trigger.isbefore){
        OpportunityTriggerHandler.UpdateDescriptionWhenOpenOrLost(trigger.new, trigger.oldMap);
      }
    }

}
Trigger handler
 
public class OpportunityTriggerHandler {
    
    
    public static void UpdateLatestOpportunityAmt(list<opportunity> OppList){
        list<account> accListTemp = new list<account>();
        
        for(Opportunity Op : OppList){
            account acc = new account();
            acc.id=Op.AccountId;
            acc.Latest_Opportunity_Amount__c = Op.Amount;
            accListTemp.add(acc);
        }
        if(accListTemp!=null){
        update accListTemp;    
        }
        
    }//------ end 
    
    public static void UpdateDescriptionWhenOpenOrLost(list<opportunity> oppList, Map<id,Opportunity> oldMap){
        
        for(Opportunity opp:oppList){
            //if insert operation was done 
            if (oldMap ==null || opp.StageName != oldMap.get(opp.id).StageName){
                if(opp.StageName=='Closed Won'){
                    opp.Description ='Opportunity is Closed Won';
                    system.debug('Opportunity is Closed Won');
                
                } else if (opp.StageName=='Closed Lost'){
                    opp.Description ='Opportunity is Closed Lost';
                    system.debug('Opportunity is Closed Lost');
                
                }else{
                    opp.Description ='Opportunity is Open';
                    system.debug('Opportunity is open');
                }
            }
            
        }
        
    }

}

Thanks, 
Gunwinder
 
I need help with invocable apex class that takes collection (string) and formats it replacing the second last comma to an and:

Raw string : Amy, Rose, Gary
Formatted: Amy, Rose and Gary.

testing on anonymous code block, i get the desired output however when using it on a Apex class it fails.
 
Anoymous code block : 

string inputString = 'Amy, Rose,Mary';

integer indexOfSecondLastComma = inputString.lastIndexOf(',',
                                 inputString.lastIndexOf(','));

//replace 
string outputString = 
inputString.substring(0,indexOfSecondLastComma) + ' and '+
inputString.substring(indexOfSecondLastComma+1);

system.debug(outputString);
 
public class FormatSendersInv{
    
    @InvocableMethod(label='Format Contact Names'
                     description='Returns the string for sending email for deceased contacts'
                     category='WC_ApexActions')

    public static LIST<string> getString(LIST<string> StrCol){
            LIST<string> outputStrings = new LIST<string>(); 
    	    string inputString = '';
        
        for (string s:StrCol){
            inputString = inputString+s;
        }
        
        integer indexOfSecondLastComma = inputString.lastIndexOf(',',
                                                                 inputString.lastIndexOf(','));
        
        //replace 
        string outputString = 
            inputString.substring(0,indexOfSecondLastComma) + ' and '+
            inputString.substring(indexOfSecondLastComma+1);
        	outputStrings.add(outputString);
        	system.debug(outputString);
    return outputStrings;
    }
}

I am new to apex, please suggest what I am doing wrong here.
Need Help.

I am working on a requirement, where when a ticket is lying in a queue and clicks a custom button "Completed" it changes the owner of the ticket to next working group (Queue). 

I have attempted with following code but it simply refreshes the page, please suggest as what is it that I am doing wrong.

/* Personal = 00Gd0000001xwdn */
/* Networking = 00Gd0000001y0e7 */
/* BlackBoard = 00Gd0000001xwe2 */
/* Technical  =00Gd0000001xwdx */


{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} 

var caseObj = new sforce.SObject("Case"); 
caseObj.Id = '{!Case.Id}'; 
if (caseObj.OwnerId ='00Gd0000001xwdn'){
caseObj.OwnerId = '00Gd0000001y0e7';}
 
else if(caseObj.OwnerId ='00Gd0000001y0e7'){
caseObj.OwnerId = '00Gd0000001xwe2';}
 
else if(caseObj.OwnerId ='00Gd0000001xwe2'){ 
caseObj.OwnerId = '00Gd0000001xwdx';}

else {alert("You can not use this button as the owner of ticket does not match the criteria defined");}

caseObj.Status = "Completed"; 
var result = sforce.connection.update([caseObj]); 
window.location.href=window.location.href;

Thanks,
Gary
Wonderful People,

I am new to Visualforce, i would need some direction as to how to create a dynamic email template. We provide support for more than 70 clients and for which we have created custom branded templates (HTML) and therefore need to use equallent workflows and have recently maxed out on 300 active workflows in our Org.

Therefore i want to create a custom dynamic visualforce template that could dynamically fetch the logo. For this i have:

1. Created a Rich Text feild and have added the logo of the institution.
2. Added the following string which gets me a broken image link instead of the image / logo.
<apex:image url="{URLFOR(!relatedTo.AccountLogo__c)}" /> 

Please suggest as what is it i am doing wrong, and if there is any better way to create a dynamic email template.

Thanks in advance,