• leva
  • NEWBIE
  • 135 Points
  • Member since 2011

  • Chatter
    Feed
  • 3
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 47
    Replies

I have this:

PageReference retPage = new PageReference('/' + changeID + '/e?00Na000000BA4Ip=Rejected&00Na000000BA4IU=True&00Na000000BA4IW=UserInfo.getName()&00Na000000BA4IV=');

 This needs to equal the current date and time.  How do I accomplish that?

00Na000000BA4IV=
  • August 30, 2013
  • Like
  • 0

I frequently have a requirement to list rows and a add field(s) to each row on the page which are not in the underlying table. I always end up adding "dummy" fields to the table so that I can use them in the UI. 

 

Is there a better, more elegant way of doing this?

 

Happy to provide examples if it helps

 

NB: I run up against the same problem when I want to render/disable a button or link for each row in a list based on the row's status etc.

 

I am attempting to create my own custom date fields to use with events and tasks. When my method is called, it should determine whether it is an event or task and use some logic to set the date. I will be using this method in a query to filter my table. for example

String qry = select [datefilter(event, allOpen), status from Task]; 

 I'm hoping this will return all open tasks/events. Pretty much same plan for all other picklist values

 

Here is the picklist which is inside a list called dateList

   All Open

   All Past 

   Next 7 days.

 

Anyone know how I can go about this? potentially using Date methods? Thanks for your time

 

public void datefilter(String taskOrEvent, string date){

 if (taskOrEvent =='task' && date = 'allOpen'){
   //do logic
   }

  if (taskOrEvent =='task' && date = 'all past'){
   //do logic
   }

if (taskOrEvent =='task' && date = 'Next 7 days'){
   //do logic
   }

 if (taskOrEvent =='event' && date = 'allOpen'){
   //do logic
   }

  if (taskOrEvent =='event' && date = 'all past'){
   //do logic
   }

if (taskOrEvent =='event' && date = 'Next 7 days'){
   //do logic
   }

}

 

  • August 27, 2013
  • Like
  • 0
Hi,

I need to send out a calendar invite (ics) from APEX. I can genrated and send out the invite but for some reason cannot customize subject.. Here is what I am doing

String ics = 'BEGIN:VCALENDAR\n' ... +'SUMMARY;LANGUAGE=en-us:'+subject+'\n' ...  +'END:VCALENDAR\n';
Blob.valueOf(ics)

Attaching the blob. ALL the custom fields I set in the invite - times, location, etc work fine. But   the subject is alwaty - "Sandbox:"

Thank you
  • January 06, 2014
  • Like
  • 1

Hi,

 

I am trying to make a post call to rest service in SalesFroce using jersey library.  I want to post a JSON "HashMap" to SF. I want the structure to look something like this:

 

{
    "Id1": ["email1", "email2" ... "emailX"]
    "Id2": ["email1", "email2" ... "emailX"] 
...
}

 

 

 

I have a custom rest service, @HttpPost method has this signiture

 

@HttpPost
global static void doPost(Map<String, String[]> args)

 on the Java end I have:

MultivaluedMap<String, String> params = new MultivaluedMapImpl();

 

Am I taking a right aproach? What need to happen with MultivaluedMap, it only accepts <String, String> type parameters? If any knows any coding examples integrating jesey, salesforce REST API that would really help

 

Thank you, in advance for taking the time!

 

 

  • November 27, 2013
  • Like
  • 0

Hi,

 

Does any one know how to get code coverage using ant? I'd like to know exact coverage after successful deployment. Also is there a way to get coverage percentage per class using ant, similar to running test in browser? 

 

Thank you

  • August 13, 2013
  • Like
  • 1
Hi, I need to some validation on ContentDocumentLink but triggers are not allowed on that object. Does anyone know I good way to add trigger-like behavior (check the data before insert/update, throw an error if data invalid) without actually having a trigger ? Thank you
  • June 20, 2013
  • Like
  • 0

I need to create a KnowledgeArticle object for my test class. but there no DML operations allowed on KnowledgeArticle. 

Any idea how I could bypass this?

 

Thank you  

 

  • November 14, 2012
  • Like
  • 0

Am trying to run a scheduled job using @future. The job sits in the Apex Job queue with "Processing" status. How can I debug what's going on. I do not get debug log out. The job is trying update ~1000 records

 

 

Thank you

  • June 06, 2012
  • Like
  • 0

How could I get the list of all job scheduled to run (from APEX)

 

Thank you

  • March 22, 2012
  • Like
  • 0

Hi,

 

I have a custom visualforce that uses a standard controller and I need to add a “Save & New” button. What is the action name for the method?

 

Thank you

 

  • February 17, 2012
  • Like
  • 0

 

Hi,

 

I am sending email via Apex (Messaging.SingleEmailMessage) and need to set sender’s address to different emails based on business logic.  I am using setSenderDisplayName to change the label. Is there a way to set the actual address?

 

Thank you

  • January 11, 2012
  • Like
  • 0

Hi,

I am attempting to send email from apex class using a template. How can I pass values into the merge fields?

 

Thank you, appreciate the help  

  • December 23, 2011
  • Like
  • 0

Hello we installed managed Chatter Unfollow application and it causes issues when moving code/objects to production. UnfollowTests class methods fail and deployment is aborted 

 

Here is the ant  error log:

 

Test failure, method: chttrunfollow.UnfollowTests.testRemoveDelayBatchJobFromQueue 
-- System.AssertException: Assertion Failed: Expected: 0, Actual: 4 stack (chttrunfollow)External entry point

Test failure, method: chttrunfollow.UnfollowTests.verifyDelayScheduler 
-- System.StringException: Invalid parameter value for parameter "id". stack (chttrunfollow) External entry point

Test failure, method: chttrunfollow.UnfollowTests.verifyUnfollowQueueEmptiesProperly 
-- System.AssertException: Assertion Failed: Expected: 0, Actual: 2 stack (chttrunfollow) External entry point

Test failure, method: chttrunfollow.UnfollowTests2.verifyReportingJobDetailsDelay 
-- System.AssertException: Assertion Failed: Expected: 0, Actual: 2 stack (chttrunfollow) External entry point

 

 

  • October 06, 2011
  • Like
  • 0

 

We installed Chatter Unfollow app and it’s started to cause issues. Test classes fail and block us from deploying  changes to production. Here is the ant error output

 

Test failure, method: chttrunfollow.UnfollowTests.testRemoveDelayBatchJobFromQueue 
-- System.AssertException: Assertion Failed: Expected: 0, Actual: 4 stack (chttrunfollow)External entry point Test failure, method: chttrunfollow.UnfollowTests.verifyDelayScheduler
-- System.StringException: Invalid parameter value for parameter "id". stack (chttrunfollow) External entry point Test failure, method: chttrunfollow.UnfollowTests.verifyUnfollowQueueEmptiesProperly
-- System.AssertException: Assertion Failed: Expected: 0, Actual: 2 stack (chttrunfollow) External entry point Test failure, method: chttrunfollow.UnfollowTests2.verifyReportingJobDetailsDelay
-- System.AssertException: Assertion Failed: Expected: 0, Actual: 2 stack (chttrunfollow) External entry point

 

 

Any ideas?

Thank you

 



  • October 06, 2011
  • Like
  • 0
Hi, Newbie question. I have created a custom VF page to replace default editIdea.apexp page. Where do I need to make the substitution? I looked in set up > develop > page but there is no editIdea page there Thank you
  • September 14, 2011
  • Like
  • 0
Hi,

I need to send out a calendar invite (ics) from APEX. I can genrated and send out the invite but for some reason cannot customize subject.. Here is what I am doing

String ics = 'BEGIN:VCALENDAR\n' ... +'SUMMARY;LANGUAGE=en-us:'+subject+'\n' ...  +'END:VCALENDAR\n';
Blob.valueOf(ics)

Attaching the blob. ALL the custom fields I set in the invite - times, location, etc work fine. But   the subject is alwaty - "Sandbox:"

Thank you
  • January 06, 2014
  • Like
  • 1

Hi,

 

Does any one know how to get code coverage using ant? I'd like to know exact coverage after successful deployment. Also is there a way to get coverage percentage per class using ant, similar to running test in browser? 

 

Thank you

  • August 13, 2013
  • Like
  • 1
Hi,

I need to send out a calendar invite (ics) from APEX. I can genrated and send out the invite but for some reason cannot customize subject.. Here is what I am doing

String ics = 'BEGIN:VCALENDAR\n' ... +'SUMMARY;LANGUAGE=en-us:'+subject+'\n' ...  +'END:VCALENDAR\n';
Blob.valueOf(ics)

Attaching the blob. ALL the custom fields I set in the invite - times, location, etc work fine. But   the subject is alwaty - "Sandbox:"

Thank you
  • January 06, 2014
  • Like
  • 1

Hi All,

 

Everything is working fine in Sandbox. I am getting erro in Production while validating. Below is the error :

 

================================================================

TestoppTrigger.testpreventoppdelete() Class 35 1 
 Message: "System.AssertException: Assertion Failed: Expected: false, Actual: true",
 Failure Stack Trace: "Class.TestoppTrigger.testpreventoppdelete: line 35, column 1"

================================================================

 

This is the simple trigger and test class:

 

trigger PreventOppDeletion on Opportunity (before delete) {
   
        String UserId = UserInfo.getuserId();
        user userRec =  [Select id from user where id = '005000000079xyz' limit 1];  
       
              for(opportunity  opp : trigger.old)
              {
              if (UserId != userRec.Id && opp.StageName == 'Closed Won' && opp.New_Type__c.startswith('Renewal')) {Opp.addError('You are not authorised to delete this Opportunity.');
              }
             
             }
   
    }

 

================================

@isTest(SeeAllData=true)
   
     private class TestPreventOppTrigger
    {
    static testMethod void testPreventOppDeletion(){
          
           Profile p = [select id from profile where name='Standard User'];
           User u = new User(alias = 'standt', email='standarduser@testorg.com',
                             emailencodingkey='UTF-8', lastname='Testing',
                             languagelocalekey='en_US',localesidkey='en_US',
                             profileid = p.Id,timezonesidkey='America/Los_Angeles',
                             username='teststandarduser@testorg.com');
  
  
           System.runAs(u){
          
                Opportunity o = new Opportunity();
                o.name='Opp1';
                o.stageName='Open';
                o.CloseDate=Date.today();
                o.Type='New Customer';
                o.amount=100.00;
                o.ContractReceived__c=Date.today();
                 insert o;
                 try{
                     delete o;
                 }catch(Exception ex){
                        Boolean Message = false;         
                        if(ex.getMessage().contains('You are not authorised to delete this Opportunity')){
                             Message = true;     
                        }else{
                             Message = false;     
                        }
                        system.debug('########Message : '+Message);
                       
                        System.AssertEquals(Message, true);
                 }
        }
  }


}

================================ 

 

Please suggest. I would appreciate your feedback.

 

Thanks,

 

OK...I have my classes and trigger working in my sandbox; how do I get them created in my prod org? I do not have an Add button in Prod like I did in the sandbox.

I have this:

PageReference retPage = new PageReference('/' + changeID + '/e?00Na000000BA4Ip=Rejected&00Na000000BA4IU=True&00Na000000BA4IW=UserInfo.getName()&00Na000000BA4IV=');

 This needs to equal the current date and time.  How do I accomplish that?

00Na000000BA4IV=
  • August 30, 2013
  • Like
  • 0

Hi All, 

 

This is driving me nuts. I can understand how to write a test class for 'customer' inbound message handlers but how do I start off righting a test method and creating a inbound test message for testing the standard Email-To-Case service that salesforce provides???

 

I'm sure it is bluntly obviously but can not figure it out!

 

Actually.... thinking about it, is creating a Case the same as testing inbound email-to-case so therefore I wouldn't need to create any such test method other than a new case?

 

Thanks.

REgards,

Joey.

I need to be able to display a message based on some condition after adding  a member to a compaign.

 

I tried to addError in the trigger, but that prevents a user from adding that contact to the compaign. Is there anyway of adding messages without create a custom page?

 

thanks

 

John

Hi,

 

Can anybody help me to write the test coding for the following email inbound handler?

 

global class CaseEmailInBoundHandler implements Messaging.InboundEmailHandler {

    global Messaging.InboundEmailResult handleInboundEmail(
       Messaging.InboundEmail email,
       Messaging.InboundEnvelope envelope) {

 CaseEmailInBoundUtilities handler = new CaseEmailInBoundUtilities();
        Messaging.InboundEmailResult result = handler.processInboundEmail(email);
        return result;        
    }
}

 Thanks and Regards.,

Ambiga

Hi Vicky,

 

Can anybody explain me about @Readonly annotation and what is use of this annotation?Which scenarion we will this annotations?How many Records we can display in Vf page while using this annotatios?

 

 

Thanks,

 

Vicky

I have a custom object Project_Milestone1__c, I want to trigger a new Project when an Opportunity custom field picklist - Start_Project_Site_Id_Stage__c  = Yes, I can't get my test to pass?  Here id my TRIGGER and TEST

 

CODE

 

trigger CreateM1Project on Opportunity (after insert, after update) {
    
    
   List<Milestone1_Project__c> NewProjects = new List<Milestone1_Project__c>();

    for (Opportunity opp: trigger.new)  {
        
        if (opp.Start_Project_Site_Id_Stage__c == 'Yes') {
        
            Milestone1_Project__c freshProject = new Milestone1_Project__c();
            freshProject.Name = opp.Name;
            freshProject.Opportunity__c = opp.Id;
        }
    }
    insert NewProjects;
        
   }

 

 

TEST

 

@IsTest(SeeAllData=false)
public class CreateM1Project_test{

static testMethod void myTestMethod() {

Opportunity opp =new Opportunity(Name='Test',StageNAme='Closed Won',CloseDate=system.today(),Start_Project_Site_Id_Stage__c='Yes');

insert opp;


}
}

 

So I got this trigger working (with the help of some nice members of this board!!!) but now, in production, I'm running into a System.LimitException error.  I believe my problem is with the section where I'm pulling all of the Task IDs into a set (starts at row 5).  However, I'm having trouble figuring out how to correct the problem.  After much googling and trolling on the boards, it seems like I need to create a map first (?) but I'm getting lost when I try to modify my code to do so.  

 

Thanks in advance for any help you can offer!!

 

trigger OppCloseDate on Opportunity (after update) {

Set<Id> oppIds = new Set<Id>();
Set<Id> taskIds = new Set<Id>();{
for(Task t:[select Id, WhatID from Task where Role_AM__c = 'TRUE']){
        String wId = t.WhatId;
        if(wId!=null && wId.startsWith('006')){
            taskids.add(t.WhatId);
for(Opportunity to:[select Id from Opportunity where Id in :taskIds]){
        oppIds.add(to.ID);
    }
    Set<Id> oppstoupdate = new Set<Id>();
    for(Integer i=0;i<trigger.new.size();i++){
        if(oppIds.contains(trigger.new[i].Id)){
            oppstoupdate.add(Trigger.new[i].id);

if(oppstoupdate.size() > 0){

   List<Opportunity> oList = [select Id, CloseDate from Opportunity where Id in :oppstoupdate];
    
   List<Task> taskstoupdate = new List<Task>();{
   for(Task tsk : [select Id, Opportunity_Close_Date__c from Task where WhatId in :oppstoupdate]){
   tsk.Opportunity_Close_Date__c = oList[0].CloseDate;
   taskstoupdate.add(tsk);
            }
        }
             if(!taskstoupdate.isEmpty()){
            update taskstoupdate;
        }
        }
        }
        }
        }
        }
        }
        }

 

 

I frequently have a requirement to list rows and a add field(s) to each row on the page which are not in the underlying table. I always end up adding "dummy" fields to the table so that I can use them in the UI. 

 

Is there a better, more elegant way of doing this?

 

Happy to provide examples if it helps

 

NB: I run up against the same problem when I want to render/disable a button or link for each row in a list based on the row's status etc.

 

I am attempting to create my own custom date fields to use with events and tasks. When my method is called, it should determine whether it is an event or task and use some logic to set the date. I will be using this method in a query to filter my table. for example

String qry = select [datefilter(event, allOpen), status from Task]; 

 I'm hoping this will return all open tasks/events. Pretty much same plan for all other picklist values

 

Here is the picklist which is inside a list called dateList

   All Open

   All Past 

   Next 7 days.

 

Anyone know how I can go about this? potentially using Date methods? Thanks for your time

 

public void datefilter(String taskOrEvent, string date){

 if (taskOrEvent =='task' && date = 'allOpen'){
   //do logic
   }

  if (taskOrEvent =='task' && date = 'all past'){
   //do logic
   }

if (taskOrEvent =='task' && date = 'Next 7 days'){
   //do logic
   }

 if (taskOrEvent =='event' && date = 'allOpen'){
   //do logic
   }

  if (taskOrEvent =='event' && date = 'all past'){
   //do logic
   }

if (taskOrEvent =='event' && date = 'Next 7 days'){
   //do logic
   }

}

 

  • August 27, 2013
  • Like
  • 0

I need to have a date/time field populated with the date/time of now when the class is called.  How do I accomplish this?

  • August 27, 2013
  • Like
  • 0

Hi,

This is my first post on the board and am hoping someone can help!

I created a trigger to populate a custom Task field (Opportunity_Close_Date__c) with the Opportunity Close Date. 

Below please find my trigger and the test class I wrote.

 

The problem is that I'm getting 100% code coverage but the test is failing (Error Message: System.AssertException: Assertion Failed).

 

Any ideas or help would be greatly appreciated!!

Thanks!

 

Here's the trigger:

 

trigger OppCloseDate on Opportunity (after insert, after update) {

Set<Id> oppIds = new Set<Id>();
Set<Id> taskIds = new Set<Id>();{
for(Task t:[select Id, WhatID from Task]){
        String wId = t.WhatId;
        if(wId!=null && wId.startsWith('006')){
            taskids.add(t.WhatId);
for(Opportunity to:[select Id from Opportunity where Id in :taskIds]){
        oppIds.add(to.ID);
    }
    Set<Id> oppstoupdate = new Set<Id>();
    for(Integer i=0;i<trigger.new.size();i++){
        if(oppIds.contains(trigger.new[i].Id)){
            oppstoupdate.add(Trigger.new[i].id);

if(oppstoupdate.size() > 0){

   List<Opportunity> oList = [select Id, CloseDate from Opportunity where Id in :oppstoupdate];
    
   List<Task> taskstoupdate = new List<Task>();{
   for(Task tsk : [select Id, Opportunity_Close_Date__c from Task where WhatId in :oppstoupdate]){
   tsk.Opportunity_Close_Date__c = oList[0].CloseDate;
   taskstoupdate.add(tsk);
            }
        }
             if(!taskstoupdate.isEmpty()){
            update taskstoupdate;
        }
        }
        }
        }
        }
        }
        }
        }

 

And here's the test class:

 

@isTest

private class Test_OppCloseDate {
  
    public static testMethod void myUnitTest(){

 List<Opportunity> opp1 = new List<Opportunity>{ new Opportunity(
        Name = 'Test Opp1',
        StageName = 'Closed Won',
        Type = 'New Business',
        CloseDate = Date.today()+7,
        Demo_ID__c = NULL,
        LicenseType__c = 'Enterprise')};                                
       
    insert opp1;
 
List<Opportunity> opp2 = new List<Opportunity>{ new Opportunity(
        Name = 'Test Opp2',
        StageName = 'Closed Won',
        Type = 'New Business',
        CloseDate = Date.today()+2,
        LicenseType__c = 'Enterprise')};                                
       
    insert opp2;

List<Task> tsk1 = new List<Task>{ new Task(
    WhatId = opp1[0].id,
    Subject = 'Task 2',
    Status = 'Not Started',
    Priority = 'Normal',
    Type = 'Demonstration - In Person')};                                
        
    insert tsk1;
    
  
List<Task> tsk2 = new List<Task>{ new Task(
    WhatId = NULL,
    Subject = 'Task 2',
    Status = 'Not Started',
    Priority = 'Normal',
    Type = 'Demonstration - Web/Phone')};                                
        
    insert tsk2;
    
List<Opportunity> oppstoupdate1 = New List<Opportunity>{ [select id from Opportunity where id in :opp1]};
    for(Opportunity oOP:oppstoupdate1)
    oOP.CloseDate = Date.today();
        Update oppstoupdate1;

List<Task> taskstoupdate2 = New List<Task>{ [select id from task where id in :tsk2]};
    for(task tOK:taskstoupdate2)
    tOK.WhatId = opp2[0].id;
        Update taskstoupdate2;


Task [] tasks1 = [select ID, Opportunity_Close_Date__c from Task where ID in :tsk1];
    System.assert(tasks1[0].Opportunity_Close_Date__c == (opp1[0].CloseDate));

Task [] tasks2 = [select ID, Opportunity_Close_Date__c from Task where ID in :tsk2];
    System.assert(tasks2[0].Opportunity_Close_Date__c == (opp2[0].CloseDate));  
 }
 }

 

 

I have recently changed a class to dynamic apex in order to cut down on the number of scriprt statements when executed. My old test class in enormous (about 650 lines). When a class is changed to dynamic apex, can the test class be cut down substantially as well, or is it about the same? I'm having trouble actually creating a test class.

 

Here is my class:

public class Account_RollupTrades {
    public Static Account_Setting__c setting = Account_Setting__c.getInstance();
    public Static boolean inprog = false;
    
    public static void execute (Set<Id> accountIds, List<Account> accountsList) {
        Map<Id, Account> accounts = new Map<Id, Account> (AccountsList);
        system.debug ('execute');
        if(setting.Disable_RollupTrades__c != true) {
            //Map<Id, Account> accounts = new Map<Id, Account>();
            for(Id accountId:accountIds) {
                system.debug(accountid);
                accounts.put(accountId,
                   new Account(
                       Id=accountId,
                       YTD_NIOR_I_Sales__c = 0,         YTD_NIOR_I_Shares__c = 0,         QTD_NIOR_I_Sales__c = 0,         QTD_NIOR_I_Shares__c = 0,
                       MTD_NIOR_I_Sales__c = 0,         MTD_NIOR_I_Shares__c = 0,         PY_NIOR_I_Sales__c = 0,          PY_NIOR_I_Shares__c = 0,
                       Total_NIOR_I_Sales__c = 0,       Total_NIOR_I_Shares__c = 0,       YTD_NS_Income_Sales__c = 0,      YTD_NS_Income_Shares__c = 0,
                       QTD_NS_Income_Sales__c = 0,      QTD_NS_Income_Shares__c = 0,      MTD_NS_Income_Sales__c = 0,      MTD_NS_Income_Shares__c = 0,
                       PY_NS_Income_Sales__c = 0,       PY_NS_Income_Shares__c = 0,       Total_NS_Income_Sales__c = 0,    Total_NS_Income_Shares__c = 0,
                       Total_NS_HIT_Sales__c = 0,       Total_NS_HIT_Shares__c = 0,       YTD_NS_HIT_Sales__c = 0,         YTD_NS_HIT_Shares__c = 0,
                       QTD_NS_HIT_Sales__c = 0,         QTD_NS_HIT_Shares__c = 0,         MTD_NS_HIT_Sales__c = 0,         MTD_NS_HIT_Shares__c = 0,
                       PY_NS_HIT_Sales__c = 0,          PY_NS_HIT_Shares__c = 0,          Total_NS_Income_II_Sales__c = 0, Total_NS_Income_II_Shares__c = 0,
                       YTD_NS_Income_II_Sales__c = 0,   YTD_NS_Income_II_Shares__c = 0,   QTD_NS_Income_II_Sales__c = 0,   QTD_NS_Income_II_Shares__c = 0,
                       MTD_NS_Income_II_Sales__c = 0,   MTD_NS_Income_II_Shares__c = 0,   PY_NS_Income_II_Sales__c = 0,    PY_NS_Income_II_Shares__c = 0,
                       Rollup_Trades__c = DateTime.now()
                   )
                            );
            }
            
        // Roll up the trades based on the Resolved Firm Trading ID field
        Trades__c[] tradesList = [
            select Dollar_Amount_of_the_transaction__c, Fund_Number__c, Number_of_Shares_of_the_transaction__c,
                Resolved_to_Rep_Trading_ID__c, Resolved_Firm_Trading_ID__c, Resolved_Firm_Trading_IDs__c,
            	Trade_Date__c
              from Trades__c
             where Resolved_Firm_Trading_ID__c in :accountIds
               and Fund_Number__c in ('3910', '3911', '3912', '3915')       // NIOR I; NS Income; NS HIT; NS Income II
               and Dollar_Amount_of_the_transaction__c != null      // prevents null pointers below
               and Number_of_Shares_of_the_transaction__c != null   // prevents null pointers below
               and Trade_Date__c != null                            // prevents null pointers below
               // Negative values are ignored for roll-up purposes
               and Dollar_Amount_of_the_transaction__c >= 0
               and Number_of_Shares_of_the_transaction__c >= 0
        ];
            
            Map<String, SObjectField[]>
                ytd = new map<string, sobjectfield[]> {
                    '3910' => new sobjectfield[] { account.YTD_NIOR_I_Sales__c , account.YTD_NIOR_I_Shares__c},
                    '3911' => new sobjectfield[] { account.YTD_NS_Income_Sales__c , account.YTD_NS_Income_Shares__c },
                    '3912' => new sobjectfield[] { account.YTD_NS_HIT_Sales__c , account.YTD_NS_HIT_Shares__c },
                    '3915' => new sobjectfield[] { account.YTD_NS_Income_II_Sales__c , account.YTD_NS_Income_II_Shares__c }    
                },
                qtd = new map<string, sobjectfield[]> {
                    '3910' => new sobjectfield[] { account.QTD_NIOR_I_Sales__c , account.QTD_NIOR_I_Shares__c},
                    '3911' => new sobjectfield[] { account.QTD_NS_Income_Sales__c , account.QTD_NS_Income_Shares__c },
                    '3912' => new sobjectfield[] { account.QTD_NS_HIT_Sales__c , account.QTD_NS_HIT_Shares__c },
                    '3915' => new sobjectfield[] { account.QTD_NS_Income_II_Sales__c , account.QTD_NS_Income_II_Shares__c }
                },
                mtd = new map<string, sobjectfield[]> {
                    '3910' => new sobjectfield[] { account.MTD_NIOR_I_Sales__c , account.MTD_NIOR_I_Shares__c},
                    '3911' => new sobjectfield[] { account.MTD_NS_Income_Sales__c , account.MTD_NS_Income_Shares__c },
                    '3912' => new sobjectfield[] { account.MTD_NS_HIT_Sales__c , account.MTD_NS_HIT_Shares__c },
                    '3915' => new sobjectfield[] { account.MTD_NS_Income_II_Sales__c , account.MTD_NS_Income_II_Shares__c }
                },
                py = new map<string, sobjectfield[]> {
                    '3910' => new sobjectfield[] { account.PY_NIOR_I_Sales__c , account.PY_NIOR_I_Shares__c},
                    '3911' => new sobjectfield[] { account.PY_NS_Income_Sales__c , account.PY_NS_Income_Shares__c },
                    '3912' => new sobjectfield[] { account.PY_NS_HIT_Sales__c , account.PY_NS_HIT_Shares__c },
                    '3915' => new sobjectfield[] { account.PY_NS_Income_II_Sales__c , account.PY_NS_Income_II_Shares__c }
                },
                total = new map<string, sobjectfield[]> {
                    '3910' => new sobjectfield[] { account.Total_NIOR_I_Sales__c , account.Total_NIOR_I_Shares__c},
                    '3911' => new sobjectfield[] { account.Total_NS_Income_Sales__c , account.Total_NS_Income_Shares__c },
                    '3912' => new sobjectfield[] { account.Total_NS_HIT_Sales__c , account.Total_NS_HIT_Shares__c },
                    '3915' => new sobjectfield[] { account.Total_NS_Income_II_Sales__c , account.Total_NS_Income_II_Shares__c }
                };

            for(trades__c trade:tradesList) {
                    system.debug(trade);
					system.debug(accounts.get(trade.Resolved_Firm_Trading_ID__c));
                    system.debug(ytd.get(trade.fund_number__c));
                if(date.today().year() == trade.trade_date__c.year()) {
                    accounts.get(trade.Resolved_Firm_Trading_ID__c).put(ytd.get(trade.fund_number__c)[0], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(ytd.get(trade.fund_number__c)[0]))+trade.Dollar_Amount_of_The_Transaction__c);
                    accounts.get(trade.Resolved_Firm_Trading_ID__c).put(ytd.get(trade.fund_number__c)[1], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(ytd.get(trade.fund_number__c)[1]))+trade.Number_of_Shares_of_the_transaction__c);

                    if( (Decimal.ValueOf(date.today().month()).divide(3, 0) == Decimal.ValueOf(trade.trade_date__c.month()).divide(3, 0)) )   {
                        accounts.get(trade.Resolved_Firm_Trading_ID__c).put(qtd.get(trade.fund_number__c)[0], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(qtd.get(trade.fund_number__c)[0]))+trade.Dollar_Amount_of_The_Transaction__c);
                        accounts.get(trade.Resolved_Firm_Trading_ID__c).put(qtd.get(trade.fund_number__c)[1], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(qtd.get(trade.fund_number__c)[1]))+trade.Number_of_Shares_of_the_transaction__c);

                        if(date.today().month()==trade.trade_date__c.month()) {
                            accounts.get(trade.Resolved_Firm_Trading_ID__c).put(mtd.get(trade.fund_number__c)[0], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(mtd.get(trade.fund_number__c)[0]))+trade.Dollar_Amount_of_The_Transaction__c);
                            accounts.get(trade.Resolved_Firm_Trading_ID__c).put(mtd.get(trade.fund_number__c)[1], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(mtd.get(trade.fund_number__c)[1]))+trade.Number_of_Shares_of_the_transaction__c);
                        }
                    }
                } else if(date.today().year()-1==trade.trade_date__c.year()) {
                    accounts.get(trade.Resolved_Firm_Trading_ID__c).put(py.get(trade.fund_number__c)[0], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(py.get(trade.fund_number__c)[0]))+trade.Dollar_Amount_of_The_Transaction__c);
                    accounts.get(trade.Resolved_Firm_Trading_ID__c).put(py.get(trade.fund_number__c)[1], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(py.get(trade.fund_number__c)[1]))+trade.Number_of_Shares_of_the_transaction__c);
                }
                accounts.get(trade.Resolved_Firm_Trading_ID__c).put(total.get(trade.fund_number__c)[0], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(total.get(trade.fund_number__c)[0]))+trade.Dollar_Amount_of_The_Transaction__c);
                accounts.get(trade.Resolved_Firm_Trading_ID__c).put(total.get(trade.fund_number__c)[1], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(total.get(trade.fund_number__c)[1]))+trade.Number_of_Shares_of_the_transaction__c);
            }
        }
     inprog = true;
     update accounts.values();
     inprog = false;
    }
}

 I can post my original test class if needed, but it's quite large.

Hi,

 

I want to convert datetime value

 

i.e. currently I am getting value "Mon Aug 26 11:49:39 GMT 2013" and I want to convert it to "26-Aug-13 11:49 PM"

 

Any Ideas?

 

I want to apply formatting on standard "CreatedDateTime" field.