• *rdinakaran*
  • NEWBIE
  • 90 Points
  • Member since 2012

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 18
    Replies

Hi I need little bit help for Test My TaskListview Controller

 

public class TaskListViewController { 
     
    public String objectId {get; set;}
    public Integer numLeft {get; set;}
    public Integer total {get; set;}    
    private Integer startNdx = 0;
    private static Integer PAGESIZE = 8;
    private List<Task> fullTaskList = new List<Task>();
    private List<Task> displayedTaskList = new List<Task>();
    
    
    public TaskListViewController() {

    }
    
    public PageReference refreshPage() {
        return null;
    }
   
    public List<Task> getTasks() {
        String ownerId = UserInfo.getUserId();
        if (fullTaskList.isEmpty())
        {
            fullTaskList = [SELECT Id, WhatId, WhoId, ActivityDate, subject,Activity_Type__c ,status, priority, Description,  ReminderDateTime, IsReminderSet,isClosed 
                            FROM Task 
                            WHERE isClosed = false 
                            AND OwnerId = :ownerId];
            numLeft = fullTaskList.size();
            total = numLeft;
            if(numLeft <> 0)
                this.objectId = ((Task) fullTaskList[0]).id;
         }
        
        displayedTaskList.clear();
        if(numLeft <> 0)
        {
        Integer endNdx = startNdx + PAGESIZE;
        if (endNdx > total)
            endNdx = total;
            
        for (Integer i=startNdx; i<endNdx; i++)
            displayedTaskList.add(fullTaskList.get(i));
         }           
        return displayedTaskList;
    }
 
    private void updateTaskStatus() {
        System.debug('before : ' + fullTaskList);
        Integer i = 0;
        for (i=0; i<fullTaskList.size(); i++) {
            Task t = fullTaskList.get(i);
            if (this.objectId.equals(t.id)) {
                System.debug('updating status of ' + t);                                
                Task tmp = [SELECT Id, WhatId, WhoId, ActivityDate, subject, status, priority, Description, ReminderDateTime, IsReminderSet, isClosed 
                            FROM Task 
                            WHERE id = :t.id];
                fullTaskList.set(i, tmp);
                System.debug('updated to ' + tmp);
                //this.updatedItemStatus = tmp.status;
                break;
            }
        }
        
        System.debug('after : ' + fullTaskList);               
    }
    
    private void nextTask() {
        for (Task t : fullTaskList) {
            if (!t.isClosed) {
                System.debug('found non-closed object with id ' + t.id);
                this.objectId = t.id;
                break;
            }
        }
    }
  

    public void previous() {
        startNdx -= PAGESIZE;
    }
    
    public void next() {
        startNdx += PAGESIZE;
    }    
    
    public void refreshNumbers() {
        updateTaskStatus();
        nextTask();
        this.numLeft = 0;
        for (Task t : fullTaskList) {
            if (!t.isClosed) {
                this.numLeft++;
            }
        }        
      }
    
    public Boolean getHasNext() {
        return total > (startNdx + PAGESIZE);
    }
    
    public Boolean getHasPrevious() {
        return startNdx > 0;
    }    

    public Integer getNum() {
        return total;
    } 
    public PageReference Cancel() {
    PageReference Activitiespage = Page.Activities;
           Activitiespage.setRedirect(true);
           return Activitiespage;
        return null;
    }
    public PageReference save(){       
        for (Task t : fullTaskList) {
           update t;
           PageReference Activitiespage = Page.Activities;
           Activitiespage.setRedirect(true);
           return Activitiespage;
        }
        return null;    
    }
    }

 

@isTest
 Private Class TestTaskListViewController{
 
 static testMethod void testTaskListViewController() {
                
        TaskListViewController t = new TaskListViewController();        
        t.getTasks();    
        t.refreshPage();
        t.previous();
        t.next();
        t.refreshNumbers();
        t.getHasNext();
        t.getHasPrevious();
        t.save();
        t.getNum();
        t.Cancel();
        
                             
    }   
 }

 Getting Around 68% Coverage.

 

I am thinking that if i create a other task and update the status i think my update thing will cover, how would i cover previuos and next page and the page refrence.

 

Thanks

 

hi..

 

   i need a trigger for sending an mails

Hello Guys,

 

I Need your help in writing a test case for TaskCreate trigger


My trigger works this way. 

 

For any Task created, an Interaction record is automatically created ... The Interaction Object is a custom Object.

 

I will like to create a test case for this trigger .. PlEASE HELP, I have tried the Salesforce test case example but to no avail.

 

 

Thanks in Advance...

 

Here is the Code below

 

 

trigger TaskCreate on Task (after Insert) 
{
List<Interaction__c> INTA = new List<Interaction__c>();

ID RecordTypeofInteraction=[SELECT Id,Name FROM RecordType WHERE Name LIKE '07-Sales Process'].id;
for(Task TC :Trigger.new)



INTA.add(new Interaction__c (Subject__c=TC.subject,
Contact__c=TC.whoID,
status__c=TC.Status,
// Adviser__c=TC.WhoID,
//Dealer_Group__c=TC.WhoID,
Log_Interaction_Details__c=TC.description,

Interaction_Type__c='General Information',


recordTypeID = '012Q00000000TqN'));

}

Insert INTA;

}

 

 

 


 

 

 

 

Hi Devs,

 

I want to connect with my localhost .for that i use "http:localhost:9000" in htpprequest in apex. It shows service unavailable error.

Apex is run in salesforce server ,so it doesnt any response to me.

 

Is there any other way to do this.

 

Please help regarding this.

 

 

//My Http request 

Http http  = new Http(); 
        HttpRequest req = new HttpRequest(); 
        req.setEndpoint('http://localhost:9000'); 
        req.setMethod('GET');
        req.setTimeout(50000);
        req.setbody(xmlStringxmlRD);
        HttpResponse res = http.send(req); 
        system.debug('&&&&res'+res);

 

my Debug log show as

 

&&&&resSystem.HttpResponse[Status=Service Unavailable, StatusCode=503]

 

 


This is my controller here i got the error system null pointer exception. any body give your suggestion how to solve this error.


public with sharing class AssignWorklistController

{
string subject;
        string description;
        string EmailList;

    public static Events__c Event {
        get {
            if (Event == Null || Event !=Null)
            {
               //String EventId  =ApexPages.currentPage().getParameters().get('EventId');
               //if(ApexPages.currentPage().getParameters().get('EventId') != null){
                 String EventId =String.escapeSingleQuotes(EncodingUtil.urlDecode(ApexPages.currentPage().getParameters().get('EventId'), 'UTF-8'));
                            
                if(EventId != '' && EventId != null )
                {
                  try
                   {
                     Event=[Select Events__c.Name, Assigned_to__c,Event_Type__r.CatalogType__c, Assigned_to__r.Name, Description__c  From Events__c  WHERE  Id=:EventId limit 1];
                     Event.Assigned_To__c=null;
                     //Event.Description__c=Null;
                   }
                
                  catch(exception e)
                  {
                   ApexPages.addMessages(e);
                  }
               }
               //}
            }
           
            return Event;
           
        }
       
        set;
    }
   
    public AssignWorklistController ()
    {
    }

    public PageReference AssignEvent ()
    {
        if(Event!=null)
        {
                
            try {
              
               Update Event;
               system.debug('Event Updated==');
               system.debug('Event Updated=='+Event.Assigned_to__c);
              // User u = [select Id,email from User where Id=: Event.Assigned_to__c];
               Staff__c s =[select Id, Email_Id__c from Staff__c  where Relatedstaff__c =:Event.Assigned_to__c];
               system.debug('s.Email======'+s.Email_Id__c );
               system.debug('s.Id======'+s.Id);
               system.debug('UserInfo.getUserEmail()======'+UserInfo.getUserEmail());
               if(s.Email_Id__c != null){
               EmailList ='email-list\nsagarcloudcrm@gmail.com\n'+UserInfo.getUserEmail()+'\n'+s.Email_Id__c;
                             
               system.debug('EmailList=='+EmailList);
                subject = Event.Event_Type__r.CatalogType__c;
                      subject = subject+string.valueof(system.now());
               system.debug('subject =='+subject );
               if(Event.End_Date_Time__c != null){
               description ='You had Assigned with an Event Named '+Event.Event_Type__r.CatalogType__c+'  '+'Your End Date on Task is on'+Event.End_Date_Time__c ;
             }else{
                 description ='You had Assigned with an Event Named '+Event.Event_Type__r.CatalogType__c;
             }
             // string Response = VerticalResponseAPIClient.SendVREmail(subject, EmailList, subject, UserInfo.getUserEmail(), description);
             //  system.debug('Response ==='+Response );
                 }
               System.debug('vent.Assigned_to__r.Name========'+Event.Assigned_to__r.Name);
               if(ApexPages.currentPage().getParameters().get('EventId') != null){
             
              String EventId =String.escapeSingleQuotes(EncodingUtil.urlDecode(ApexPages.currentPage().getParameters().get('EventId'), 'UTF-8'));

                if(EventId != '' && EventId != null)
                {
                 Events__c E = [Select Events__c.Name, Assigned_to__c,Event_Type__r.CatalogType__c, Assigned_to__r.Name, Description__c  From Events__c  WHERE  Id=:EventId limit 1];
                 System.debug('vent.Assigned_to__r.Name========'+E.Assigned_to__r.Name);  
               Task_List__c TL = new Task_List__c();
               TL.Assigned_To__c = E.Assigned_to__r.Name;
               TL.Created_By__c = UserInfo.getName();
               TL.Description__c = E.Description__c;
               TL.Status__c ='Pending';
               TL.Subject__c = E.Event_Type__r.CatalogType__c ;
               TL.Assigned_Date__c = DateTime.Now();
               TL.UniqueKey__c = String.valueof(TL.Assigned_To__c+TL.Created_By__c +TL.Assigned_Date__c);
             
               Insert TL;
              
               Event.Task_UniqueKey__c = TL.UniqueKey__c;
               Update Event;
                 System.debug('vent.Assigned_to__r.Name========'+E.Assigned_to__r.Name);
           
               }
              }
           }
           catch (Exception e)
            {
                ApexPages.addMessages(e);
            } 
             
        }   
       
         //SendMail();
       return null;
      
    }
   
     public PageReference SendMail()
    {
   
    system.debug('subject===='+subject);
    system.debug('EmailList===='+EmailList);
    system.debug('description===='+description);
    if(subject != null && EmailList!=null && description != null){
   
     string Response = VerticalResponseAPIClient.SendVREmail(subject, EmailList, subject, UserInfo.getUserEmail(), description);
               system.debug('Response ==='+Response );
               }
     PageReference pageRef = new PageReference('/apex/WorkListView');
        return pageRef;
    }
    public PageReference Cancel()
    {
        PageReference pageRef = new PageReference('/apex/WorkListView');
        return pageRef;
    }
}


Advance Thanks
Maheswar

Here is a trigger I wrote. I understand that I need to get the conversion rate SOQL query out of the for statement:

trigger OpportunityBeforeInsertUpdate on Opportunity (before insert, before update) {


for(Opportunity opp : Trigger.new) {
    if (opp.Total_Amount__c > 0) {
        opp.Amount = opp.Total_Amount__c;
        system.debug('opp amount is ' + opp.Amount);
        } 
    
    
     if(Trigger.isInsert 
     || 
     ((opp.Amount != Trigger.oldMap.get(opp.Id).Amount || opp.CurrencyIsoCode != Trigger.oldMap.get(opp.Id).CurrencyIsoCode)
     &&
     (!opp.IsClosed || (opp.IsClosed && !Trigger.oldMap.get(opp.Id).IsClosed)))
     ||
     (!opp.IsClosed && Trigger.oldMap.get(opp.Id).IsClosed)
     ) 
         {
   double conversionrate = [select conversionrate from CurrencyType where IsoCode = :opp.CurrencyIsoCode];
            opp.Amount_USD__c = opp.Amount/ ConversionRate ;
        }
}
}

 so I wrote the following but still get the Too many SOQL queries error when running a test where 200 opps are inserted:

trigger OpportunityBeforeInsertUpdate on Opportunity (before insert, before update) {

List<CurrencyType> currs = new List<CurrencyType>
([select id, IsoCode, ConversionRate from CurrencyType where IsActive=true limit 200]);

Map<String, Decimal> ConversionRates = new Map<String, Decimal>();

for(integer i=0; i<currs.size(); i++){
ConversionRates.put(currs[i].IsoCode, currs[i].ConversionRate);
}


for(Opportunity opp : Trigger.new) {
    if (opp.Total_Amount__c > 0) {
        opp.Amount = opp.Total_Amount__c;
        system.debug('opp amount is ' + opp.Amount);
        } 
    
    
     if(Trigger.isInsert 
     || 
     ((opp.Amount != Trigger.oldMap.get(opp.Id).Amount || opp.CurrencyIsoCode != Trigger.oldMap.get(opp.Id).CurrencyIsoCode)
     &&
     (!opp.IsClosed || (opp.IsClosed && !Trigger.oldMap.get(opp.Id).IsClosed)))
     ||
     (!opp.IsClosed && Trigger.oldMap.get(opp.Id).IsClosed)
     ) 
         {
            opp.Amount_USD__c = opp.Amount/ ConversionRates.get(opp.CurrencyIsoCode) ;
        }
}
}

 

  • July 04, 2013
  • Like
  • 0

Hi I need little bit help for Test My TaskListview Controller

 

public class TaskListViewController { 
     
    public String objectId {get; set;}
    public Integer numLeft {get; set;}
    public Integer total {get; set;}    
    private Integer startNdx = 0;
    private static Integer PAGESIZE = 8;
    private List<Task> fullTaskList = new List<Task>();
    private List<Task> displayedTaskList = new List<Task>();
    
    
    public TaskListViewController() {

    }
    
    public PageReference refreshPage() {
        return null;
    }
   
    public List<Task> getTasks() {
        String ownerId = UserInfo.getUserId();
        if (fullTaskList.isEmpty())
        {
            fullTaskList = [SELECT Id, WhatId, WhoId, ActivityDate, subject,Activity_Type__c ,status, priority, Description,  ReminderDateTime, IsReminderSet,isClosed 
                            FROM Task 
                            WHERE isClosed = false 
                            AND OwnerId = :ownerId];
            numLeft = fullTaskList.size();
            total = numLeft;
            if(numLeft <> 0)
                this.objectId = ((Task) fullTaskList[0]).id;
         }
        
        displayedTaskList.clear();
        if(numLeft <> 0)
        {
        Integer endNdx = startNdx + PAGESIZE;
        if (endNdx > total)
            endNdx = total;
            
        for (Integer i=startNdx; i<endNdx; i++)
            displayedTaskList.add(fullTaskList.get(i));
         }           
        return displayedTaskList;
    }
 
    private void updateTaskStatus() {
        System.debug('before : ' + fullTaskList);
        Integer i = 0;
        for (i=0; i<fullTaskList.size(); i++) {
            Task t = fullTaskList.get(i);
            if (this.objectId.equals(t.id)) {
                System.debug('updating status of ' + t);                                
                Task tmp = [SELECT Id, WhatId, WhoId, ActivityDate, subject, status, priority, Description, ReminderDateTime, IsReminderSet, isClosed 
                            FROM Task 
                            WHERE id = :t.id];
                fullTaskList.set(i, tmp);
                System.debug('updated to ' + tmp);
                //this.updatedItemStatus = tmp.status;
                break;
            }
        }
        
        System.debug('after : ' + fullTaskList);               
    }
    
    private void nextTask() {
        for (Task t : fullTaskList) {
            if (!t.isClosed) {
                System.debug('found non-closed object with id ' + t.id);
                this.objectId = t.id;
                break;
            }
        }
    }
  

    public void previous() {
        startNdx -= PAGESIZE;
    }
    
    public void next() {
        startNdx += PAGESIZE;
    }    
    
    public void refreshNumbers() {
        updateTaskStatus();
        nextTask();
        this.numLeft = 0;
        for (Task t : fullTaskList) {
            if (!t.isClosed) {
                this.numLeft++;
            }
        }        
      }
    
    public Boolean getHasNext() {
        return total > (startNdx + PAGESIZE);
    }
    
    public Boolean getHasPrevious() {
        return startNdx > 0;
    }    

    public Integer getNum() {
        return total;
    } 
    public PageReference Cancel() {
    PageReference Activitiespage = Page.Activities;
           Activitiespage.setRedirect(true);
           return Activitiespage;
        return null;
    }
    public PageReference save(){       
        for (Task t : fullTaskList) {
           update t;
           PageReference Activitiespage = Page.Activities;
           Activitiespage.setRedirect(true);
           return Activitiespage;
        }
        return null;    
    }
    }

 

@isTest
 Private Class TestTaskListViewController{
 
 static testMethod void testTaskListViewController() {
                
        TaskListViewController t = new TaskListViewController();        
        t.getTasks();    
        t.refreshPage();
        t.previous();
        t.next();
        t.refreshNumbers();
        t.getHasNext();
        t.getHasPrevious();
        t.save();
        t.getNum();
        t.Cancel();
        
                             
    }   
 }

 Getting Around 68% Coverage.

 

I am thinking that if i create a other task and update the status i think my update thing will cover, how would i cover previuos and next page and the page refrence.

 

Thanks

 

Hiii.....how to write a SOQL query where we don't know the value of "WHERE" condition..

  Thank you

Hi,

 

Any one can help how to retrieve customobject attachments using soql query

 

My requirement is

 

Name   Exp  technology  viewAttachment Downloadattachment

xxxx   2yrs    Salesforce  VIEWFILE      document.doc
yyyy   6 yrs    oracle     VIEWFILE      DOC.xlsx  

 

 

Thank you

hi..

 

   i need a trigger for sending an mails

Hi,

 

      How to create automatically change owners.  In my project have 3 users, when 1st user click done button for 2nd user automatically owner change to 2nd owner name and 2nd owner click done button automatically change to 3rd owner name.

 

Thanks

Gopi

How do I capture the duration of the status for reporting purposes? 

 

Ex:

 

A lead has open, working, closed status.  It's opened on Sept 1st  for 10 days switchs to working for 8, than closed till now. How do I track and record the duration of each status?

 

Is this achievable in Salesforce, if so do i need a formula?

 

-Hkp716

  • October 01, 2012
  • Like
  • 0

Hi,

I wrote a webservice which uses RestRequest to recieve the xml, however I am not able to convert the recieved request into xml i.e Dom.document or xmlstreamreader, below is the webservice I wrote, I able to see the xml in the log System.debug('--->RestContext.request'+req); but How do I convert RestContext.request to dom or xmlstreamreader, as I need to parse and create record from the data??, Thanks a lot

 

@RestResource(urlMapping='/CandExpJobPost_Router/v1/*')
global with sharing class CandExpJobPost_RouterV1 {

static boolean LogEvent = false;

CandExpJobPost_RouterV1(){System.debug('----->ssip');}


@HttpPost
global static String doRecieve( ) {
mydef doc3;
createjobpostfromxml parse=new createjobpostfromxml();
//System.debug('Recieved xml -->'+doc3);
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String xml = req.requestBody.toString().trim();
System.debug('--->RestContext.request'+req);

System.debug('--->xml'+xml);
//res.addHeader('Content-Type', 'text/xml');
testdomjobpost testdoc = new testdomjobpost();
String x=String.Valueof(req);

 

}

Hi,

 

At Object Creation after the label and plural label (in summer12) we can see a new picklist field with the name "Gender" with values (neuter and common). 

 

Why salesforce has this field? what is the purpose of this field?

 

 

Hello Guys,

 

I Need your help in writing a test case for TaskCreate trigger


My trigger works this way. 

 

For any Task created, an Interaction record is automatically created ... The Interaction Object is a custom Object.

 

I will like to create a test case for this trigger .. PlEASE HELP, I have tried the Salesforce test case example but to no avail.

 

 

Thanks in Advance...

 

Here is the Code below

 

 

trigger TaskCreate on Task (after Insert) 
{
List<Interaction__c> INTA = new List<Interaction__c>();

ID RecordTypeofInteraction=[SELECT Id,Name FROM RecordType WHERE Name LIKE '07-Sales Process'].id;
for(Task TC :Trigger.new)



INTA.add(new Interaction__c (Subject__c=TC.subject,
Contact__c=TC.whoID,
status__c=TC.Status,
// Adviser__c=TC.WhoID,
//Dealer_Group__c=TC.WhoID,
Log_Interaction_Details__c=TC.description,

Interaction_Type__c='General Information',


recordTypeID = '012Q00000000TqN'));

}

Insert INTA;

}

 

 

 


 

 

 

 

hi!!!

i need a validation rule for an field that does not begin with a capital letter!!!

i write this

NOT  BEGINS( Name ,"A") but i can t add the other letters

thanks for help!!

 I have report with the logic as shown below,

Filtered BY: (1 AND ((2 AND 4) or (3 and 5))) AND 6

1. Field1__c equals 2
2. Field2_Date__c less than LAST 30 DAYS
3  Field3_Date__c less than LAST 30 DAYS
4. Field4__c equals 2
5. Field5__c equals 2
6. Field6__c equals Active,Probation

 

I am trying to use the same logic  to populate a number field with a value of 2

 

(IF(Field1__c = 2) &&  ((IF( TODAY() + 30 >  Field2_Date__c) && IF (Field4__c  =2))|| (IF( TODAY() + 30 >  Field3_Date__c) && IF ( Field5__c =2)) )) && IF ( Field6__c IN('Active','Probation'), 2,0)

 

However I am getting an error: Syntax error extra ','

 

Any suggestions will be appreciated.

  • April 30, 2012
  • Like
  • 0

How to call inputfield value which is in page block from javascript.

 

function test()

{

var end_date=document.getElementById(ttt);

}

 

 

<apex:column headerValue="Value1" id="e">

<apex:inputfield id="ttt" value="{!Is_rate}" >
</apex:inputfield>

  • April 11, 2012
  • Like
  • 0

Hi 

Am doing salesforce to amazon integration 

when i upload data in salesforce it will store in amazon

for UI purpose what ever we are storing we are dispalying the uploaded file in salesforce visual force page and one down link

 

in the click of the download button we have to save the file in my system.

but now with my code when i click its opening in new window i can i save that file

 

am using these reference can any tel me where am missing

 

<a class="button Download chat" href="{!obj.objectURL}" target="_blank"  onclick='window.location.href="{!obj.objectURL}";return false;' ><span>Download &nbsp;</span></a>

 

 

regards

venkatesh