• Rajevls
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 17
    Replies

I want to update a field on account using a button.

If the field on account(Test) is Null then on click of the button the value should be : 600000

 

If another field on the account (Test2) has a value I have to update the value as 60000+Test2.

 

Please help in acheiving this .

 

I have written this piece of code in a class to use it in trigger :

 

----------------------------------------

public class ConversionHelper 

static boolean flagvalue = false;


    public static boolean hasAlreadyfired() {
        return flagvalue;
    }
    
    public static void setAlreadyfired() {
        flagvalue = true;
    }

}

------------------------------------------

 

In the test class to cover this part of the code :

 

--------------------------------------------

@isTest

private class ConversionHelper_TC {

 

Boolean hasfired = CurrencyConversionHelper.hasAlreadyfired();

 

CurrencyConversionHelper.setAlreadyfired();

 

}

--------------------------------------------

Getting the following errors :

 

For  - CurrencyConversionHelper.setAlreadyfired(); - Method must define a body at line 14 column 2

For - Boolean setfired = CurrencyConversionHelper.setAlreadyfired(); - Compile Error: Illegal assignment from void to Boolean at line 14 column 1

 

 

This is not getting covered in the class .

Plz help.

I want to make this part of the trigger run once 

 

------------------------------------------------------------------------------------------------

List<OAR_Member_Added__c> objList = new List<OAR_Member_Added__c>();
set<id> stypes = new set<id>();
for(recordtype objr : [Select Id From RecordType where sObjectType='Task' and developername = 'Renewals_Record_Type']){
 
     stypes.add(objr.id);
}
System.Debug('Stypes ------>' + stypes);
System.Debug('NEw trigger------>' +Trigger.new);
map<id,opportunity> opps = new map<id,opportunity>();
map<id,account> acc = new map<id,account>();
for(Task T: Trigger.new){
if((stypes.contains(T.RecordTypeId))&&(T.Status == 'Completed')){

OAR_Member_Added__c obj = new OAR_Member_Added__c();
obj.Text_1__c = T.Type__c;
obj.Text_2__c = T.Type_Detail__c;
obj.Text_3__c = T.Subject;
obj.Text_4__c = T.Description;

if(t.whatid!=null&&t.whatid.getsobjecttype()==opportunity.sobjecttype) {
    opps.put(t.whatid,null);
    }
opps.putAll([select id,Opportunity_Number__c from opportunity where id in :opps.keyset()]);
if(opps.containskey(t.whatid)) {
      String Oppnum = opps.get(t.whatid).Opportunity_Number__c;
      obj.Text_5__c = Oppnum;
   }
   
if(t.whatid!=null&&t.whatid.getsobjecttype()==account.sobjecttype) {
    opps.put(t.whatid,null);
    }
acc.putAll([select id,Name from account where id in :acc.keyset()]);
if(acc.containskey(t.whatid)) {
      String Accname = acc.get(t.whatid).Name;
      obj.Text_6__c = Accname;
   }   

String TempObj = Userinfo.getUserId();
System.Debug('Task Owner........' +TempObj);
if( t.ownerid.getsobjecttype() == user.sobjecttype ) {
  obj.user_1__c = t.ownerid;
}
System.Debug('Trigger.oldMap.get(T.Id).Owner....' + T.Owner);

String urlForObj= URL.getSalesforceBaseUrl().toExternalForm() + '/'+T.WhatId;
obj.Task_Related_To_URL__c = urlForObj;

String RelUrl = URL.getSalesforceBaseUrl().toExternalForm() + '/'+T.Id;
obj.Task_URL__c = RelUrl;

objList.add(obj);
}
}
if(!objList.isEmpty())

insert objList;
   }
}

----------------------------------------------------

 

Plz help

I want to fetch the username and id of the 'Assigned To' user(Owner) of the task  . This field is a Lookup(User,Calendar) field.

I want to extract the info so that i can insert the value into another User LookUp field.

 

Plz help.

 

 

I am using an after insert trigger on Task to insert a record into the custom object when Status = Completed

 

 if(trigger.isinsert)
    {
        List<OAR_Member_Added__c> objList = new List<OAR_Member_Added__c>();
        OAR_Member_Added__c obj = new OAR_Member_Added__c();
        for(Task T: Trigger.new){ 
            if(((T.RecordTypeId == '01270000000Q9KJ')||(T.RecordTypeId == '012S0000000DIPs')||(T.RecordTypeId == '012V0000000Co5k'))&&(T.Status == 'Completed')){


                obj.Text_1__c = T.Type__c;
                obj.Text_2__c = T.Type_Detail__c;
                obj.Text_3__c = T.Subject;
                obj.Text_4__c = T.Description;
                if((String.valueof(T.Owner)).substring(0,2)== '005'){
                obj.User_1__c = String.valueof(T.Owner);
                 }
                 String urlForObj= URL.getSalesforceBaseUrl().toExternalForm() + '/'+T.WhatId;
                obj.Task_Url__c = urlForObj; 
                objList.add(obj);
            }
        }
        insert objList;
    }

 

Please help .

if(System.Trigger.oldMap.get(T.Id).Task_Comments__c != T.Task_Comments__c ){
               
               T.Description += '\n'+ ' ' +Uname +':'+' '+ ModDate +':'+' '+ T.Task_Comments__c + '\n' + '\n';
                              
               }
If Task_Comments__c is Null  then Description is null

 

On 1st enrty  

-------------------
null
Rajeev: 2013-01-23 15:57:35: Test
--------------

Second entry

---------
null
Rajeev : 2013-01-23 15:57:35: Test
Rajeev : 2013-01-23 15:57:51: Test Data
----------

 

how can i remove this null from from getting populated?

I want to copy a text field data to another text field . Both the fields are on the same object Task.

 

I want to udpate a field on opportunity (Area) . Country is a field on account and related area is mapped in the custom setting (Area Mapping) . How can i use this custom setting to update the field on opportunity

I want to insert a record into a custom object when a TASK record is created.
Can we acheive this by a trigger ?

I want to maintain history tracking of a field on task .

When ever the field is edited or updated i want to add Date - Name - Comments on the newly created field .

 

Example :

 

Existing field   - Test -  Tesitng  -  17/12

New Field - Testing -  17/12 - Raj

 

Existing field   - Test -  Tesitng in Progress  -  18/12

 

New Field - Testing -  17/12 - Raj

 

                      Tesitng in Progress  -  18/12  - Sam

 

Existing field   - Test -  Tesitng Completed -  19/12

New Field - Testing -  17/12 - Raj 

                       Tesitng in Progress  -  18/12  - Sam

                       Testing -  Tesitng Completed -  19/12 - Raj

 

Can we have a custom email for tasks through triggers. 

 

Any code snipet will be very helpful

I want to update two formula fields based a value selected in a third field(picklist field)

 

 

1. Status is a picklist field ---  when status is selected as 'Done' 

2. Completed - Formula  Date field -  would have the value

3. Open date  - Formula number field -  when Completed has a value it would populate the no. of days between the created date and Completed date value .

 If completed date has no value then Open date will have value  - Today  - Created date .

 

I have written this formula :

 

1. For Completed : 

 

IF( ISPICKVAL(Status ,'DONE'), Today(), NULL)

 

It is populating the value but not stoppping . IT is crossing the date and updating current date . IT should popualte the dae when Status is selected as DONE .

 

2. For Open Date :

 

IF(
isnull(IF( ISPICKVAL(Status ,'DONE'), Today(), NULL)),
ROUND(NOW()-CreatedDate, 0),
ROUND(((IF( ISPICKVAL(Status ,'DONE'), Today(), NULL))-DATEVALUE(CreatedDate)),0)
)

 

i am using IF( ISPICKVAL(Status ,'DONE'), Today(), NULL) because one firmula field is not called in other .

 

Here the Open date keeps on populating data based on the created date .

 

EX : 

 

If the record is createOCT 20  , status is changed to DONE on oct 22 

 

So the completed field should have OCT 22 as the date and 

Open date should have 2 as the value

 

but it showing the calculation based on todays date (27th OCT)

 

completed has oct 27 as the value and Open date has 7 as the value .

 

PLZ help here

 

if(T.Completion_Date__c != NULL){
                   T.No_Of_Days_Open__c = T.Completion_Date__c - DATEVALUE(CreatedDate);
                }
Error :

 Error: Compile Error: Variable does not exist: CreatedDate at line 38 column 76
 if(T.Completion_Date__c != NULL){
                   T.No_Of_Days_Open__c = T.Completion_Date__c - DATEVALUE(T.CreatedDate);
                }
Error :

 Error: Compile Error: Method does not exist or incorrect signature: DATEVALUE(Datetime) at line 38 column 66

 

 

The Code :

 

trigger UpdateTypePicklist on Task(before update) {
            
            String Curr = Userinfo.getDefaultCurrency();
            
            for(Task T: Trigger.new){
              
            //Create an old and new map so that we can compare values  
              Task oldT = Trigger.oldMap.get(T.ID);    
              Task newT = Trigger.newMap.get(T.ID);
              
             //Retrieve the old and new Status Value   
              String OldStat = oldT.Status;
              String NewStat = newT.Status;
if((T.Type__c != NULL)&& (T.RecordTypeId == '012S0000000DIPs'))
                 {                  
                  T.Type = T.Type__c;
                 }
                
                if(OldStat!= NewStat){
                      
               T.Status_Update_Date_Time__c = DateTime.now();
               
                 if(T.Status == 'Completed'){
                   T.Completion_Date__c = Date.Today();
               
               }
               
               if(T.Completion_Date__c != NULL){
                   T.No_Of_Days_Open__c = T.Completion_Date__c - DATEVALUE(T.CreatedDate);
                }
               
               }
               
               
               If((T.CurrencyIsoCode!= Curr)&&((T.Type__c!='Estimate')&&(T.Type__c!='Quote'))){
                   T.adderror('Activity Currency Should not be updated');
                 
               }
                
   }
}


I want to update a field on account using a button.

If the field on account(Test) is Null then on click of the button the value should be : 600000

 

If another field on the account (Test2) has a value I have to update the value as 60000+Test2.

 

Please help in acheiving this .

 

I want to make this part of the trigger run once 

 

------------------------------------------------------------------------------------------------

List<OAR_Member_Added__c> objList = new List<OAR_Member_Added__c>();
set<id> stypes = new set<id>();
for(recordtype objr : [Select Id From RecordType where sObjectType='Task' and developername = 'Renewals_Record_Type']){
 
     stypes.add(objr.id);
}
System.Debug('Stypes ------>' + stypes);
System.Debug('NEw trigger------>' +Trigger.new);
map<id,opportunity> opps = new map<id,opportunity>();
map<id,account> acc = new map<id,account>();
for(Task T: Trigger.new){
if((stypes.contains(T.RecordTypeId))&&(T.Status == 'Completed')){

OAR_Member_Added__c obj = new OAR_Member_Added__c();
obj.Text_1__c = T.Type__c;
obj.Text_2__c = T.Type_Detail__c;
obj.Text_3__c = T.Subject;
obj.Text_4__c = T.Description;

if(t.whatid!=null&&t.whatid.getsobjecttype()==opportunity.sobjecttype) {
    opps.put(t.whatid,null);
    }
opps.putAll([select id,Opportunity_Number__c from opportunity where id in :opps.keyset()]);
if(opps.containskey(t.whatid)) {
      String Oppnum = opps.get(t.whatid).Opportunity_Number__c;
      obj.Text_5__c = Oppnum;
   }
   
if(t.whatid!=null&&t.whatid.getsobjecttype()==account.sobjecttype) {
    opps.put(t.whatid,null);
    }
acc.putAll([select id,Name from account where id in :acc.keyset()]);
if(acc.containskey(t.whatid)) {
      String Accname = acc.get(t.whatid).Name;
      obj.Text_6__c = Accname;
   }   

String TempObj = Userinfo.getUserId();
System.Debug('Task Owner........' +TempObj);
if( t.ownerid.getsobjecttype() == user.sobjecttype ) {
  obj.user_1__c = t.ownerid;
}
System.Debug('Trigger.oldMap.get(T.Id).Owner....' + T.Owner);

String urlForObj= URL.getSalesforceBaseUrl().toExternalForm() + '/'+T.WhatId;
obj.Task_Related_To_URL__c = urlForObj;

String RelUrl = URL.getSalesforceBaseUrl().toExternalForm() + '/'+T.Id;
obj.Task_URL__c = RelUrl;

objList.add(obj);
}
}
if(!objList.isEmpty())

insert objList;
   }
}

----------------------------------------------------

 

Plz help

I want to fetch the username and id of the 'Assigned To' user(Owner) of the task  . This field is a Lookup(User,Calendar) field.

I want to extract the info so that i can insert the value into another User LookUp field.

 

Plz help.

 

 

I am using an after insert trigger on Task to insert a record into the custom object when Status = Completed

 

 if(trigger.isinsert)
    {
        List<OAR_Member_Added__c> objList = new List<OAR_Member_Added__c>();
        OAR_Member_Added__c obj = new OAR_Member_Added__c();
        for(Task T: Trigger.new){ 
            if(((T.RecordTypeId == '01270000000Q9KJ')||(T.RecordTypeId == '012S0000000DIPs')||(T.RecordTypeId == '012V0000000Co5k'))&&(T.Status == 'Completed')){


                obj.Text_1__c = T.Type__c;
                obj.Text_2__c = T.Type_Detail__c;
                obj.Text_3__c = T.Subject;
                obj.Text_4__c = T.Description;
                if((String.valueof(T.Owner)).substring(0,2)== '005'){
                obj.User_1__c = String.valueof(T.Owner);
                 }
                 String urlForObj= URL.getSalesforceBaseUrl().toExternalForm() + '/'+T.WhatId;
                obj.Task_Url__c = urlForObj; 
                objList.add(obj);
            }
        }
        insert objList;
    }

 

Please help .

if(System.Trigger.oldMap.get(T.Id).Task_Comments__c != T.Task_Comments__c ){
               
               T.Description += '\n'+ ' ' +Uname +':'+' '+ ModDate +':'+' '+ T.Task_Comments__c + '\n' + '\n';
                              
               }
If Task_Comments__c is Null  then Description is null

 

On 1st enrty  

-------------------
null
Rajeev: 2013-01-23 15:57:35: Test
--------------

Second entry

---------
null
Rajeev : 2013-01-23 15:57:35: Test
Rajeev : 2013-01-23 15:57:51: Test Data
----------

 

how can i remove this null from from getting populated?

I want to copy a text field data to another text field . Both the fields are on the same object Task.

 

I want to udpate a field on opportunity (Area) . Country is a field on account and related area is mapped in the custom setting (Area Mapping) . How can i use this custom setting to update the field on opportunity

I want to insert a record into a custom object when a TASK record is created.
Can we acheive this by a trigger ?

I want to update two formula fields based a value selected in a third field(picklist field)

 

 

1. Status is a picklist field ---  when status is selected as 'Done' 

2. Completed - Formula  Date field -  would have the value

3. Open date  - Formula number field -  when Completed has a value it would populate the no. of days between the created date and Completed date value .

 If completed date has no value then Open date will have value  - Today  - Created date .

 

I have written this formula :

 

1. For Completed : 

 

IF( ISPICKVAL(Status ,'DONE'), Today(), NULL)

 

It is populating the value but not stoppping . IT is crossing the date and updating current date . IT should popualte the dae when Status is selected as DONE .

 

2. For Open Date :

 

IF(
isnull(IF( ISPICKVAL(Status ,'DONE'), Today(), NULL)),
ROUND(NOW()-CreatedDate, 0),
ROUND(((IF( ISPICKVAL(Status ,'DONE'), Today(), NULL))-DATEVALUE(CreatedDate)),0)
)

 

i am using IF( ISPICKVAL(Status ,'DONE'), Today(), NULL) because one firmula field is not called in other .

 

Here the Open date keeps on populating data based on the created date .

 

EX : 

 

If the record is createOCT 20  , status is changed to DONE on oct 22 

 

So the completed field should have OCT 22 as the date and 

Open date should have 2 as the value

 

but it showing the calculation based on todays date (27th OCT)

 

completed has oct 27 as the value and Open date has 7 as the value .

 

PLZ help here

 

if(T.Completion_Date__c != NULL){
                   T.No_Of_Days_Open__c = T.Completion_Date__c - DATEVALUE(CreatedDate);
                }
Error :

 Error: Compile Error: Variable does not exist: CreatedDate at line 38 column 76
 if(T.Completion_Date__c != NULL){
                   T.No_Of_Days_Open__c = T.Completion_Date__c - DATEVALUE(T.CreatedDate);
                }
Error :

 Error: Compile Error: Method does not exist or incorrect signature: DATEVALUE(Datetime) at line 38 column 66

 

 

The Code :

 

trigger UpdateTypePicklist on Task(before update) {
            
            String Curr = Userinfo.getDefaultCurrency();
            
            for(Task T: Trigger.new){
              
            //Create an old and new map so that we can compare values  
              Task oldT = Trigger.oldMap.get(T.ID);    
              Task newT = Trigger.newMap.get(T.ID);
              
             //Retrieve the old and new Status Value   
              String OldStat = oldT.Status;
              String NewStat = newT.Status;
if((T.Type__c != NULL)&& (T.RecordTypeId == '012S0000000DIPs'))
                 {                  
                  T.Type = T.Type__c;
                 }
                
                if(OldStat!= NewStat){
                      
               T.Status_Update_Date_Time__c = DateTime.now();
               
                 if(T.Status == 'Completed'){
                   T.Completion_Date__c = Date.Today();
               
               }
               
               if(T.Completion_Date__c != NULL){
                   T.No_Of_Days_Open__c = T.Completion_Date__c - DATEVALUE(T.CreatedDate);
                }
               
               }
               
               
               If((T.CurrencyIsoCode!= Curr)&&((T.Type__c!='Estimate')&&(T.Type__c!='Quote'))){
                   T.adderror('Activity Currency Should not be updated');
                 
               }
                
   }
}