• nanduri
  • NEWBIE
  • 150 Points
  • Member since 2010

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 18
    Replies

Hi,

 

I have a date variable called start_date and I am trying to assign today's date to it like below in apex class:

 

start_date = today();

 

I am getting the below issue:

 

Error: Compile Error: Method does not exist or incorrect signature: today().

 

Please let me know what is the way to get this.

 

Thanks,

Jagadish.

  • May 17, 2012
  • Like
  • 0

Hello,

 

I have and Apex trigger that works fine but I need to make a change to it.......and I can't figure out how to do it.

The code works great when creating a new record.....I also need it to execute when an update it made.

 

The code gets the user's managers name and populates a field in the opportunity object.  I need it to update this field when the opportunity owner changes.  Any help would be most appreiciated.

 

Thanks.

 

******************************************************************************************

 

 

 

trigger Opp_Owner on Opportunity (before insert, before update ) {
/*****************************************************************************
Name     : Update Owner Manager on the opportunity from the User object

Purpose  : defaults the Owner Manager field of the opportunity from the User

******************************************************************************/
    
  //holds User Ids
  Set<Id> setUserIds = new Set<Id>();
 
  //holds a list of Users
  List<User> lstUser = new List<User>();
 
  //holds key value pairs of User Id and User Object
  Map<Id, User> mapUserObj = new Map<Id, User>();

  //holds User object
  User UserObj;
  
  //For each opportunity being inserted add User Id value in in Set of User Ids.
  for(Opportunity oppObj : Trigger.new){
    if(oppObj.OwnerId != null){
      setUserIds.add(oppObj.OwnerId);
    }
  }
 
  
  //Fetch all Users whose Id is in the Set.
  lstUser = [select Id, Name, Manager_Full_Name__c, ManagerId from User where Id in :setUserIds Limit 1000];
  if(lstUser.size() == 0){
    return; 
  }
 
  //Add these fetched Users in a Map <User Id, User object>
  for(User usrObj : lstUser){
    mapUserObj.put(usrObj.Id, usrObj); 
  }
 
  //for each opportunity being inserted get User from the map and update the field values
  for(Opportunity oppObj : Trigger.new){
    //get User object
    if(oppObj.OwnerId != null){
      if(mapUserObj.containsKey(oppObj.OwnerId)){
        UserObj = mapUserObj.get(oppObj.OwnerId);
        //map opportunity fields to User fields
        oppObj.Opportunity_Owner_s_Manager__c = UserObj.Manager_Full_Name__c;
      } 
    }
  }

 }

 

 

hi im having problems with a test class. everytime i run the test it gives me an error System.UnexpectedException No such column 'Name' on entity Asset__c. here is the code that givin me that error.

public static List<selectOption> manufactures(){  
   	  List<selectOption> allManufactures = new List<selectOption>();   
      Set<String> asset = new Set<String>();
      List<String> sorted = new List<String>();
     
     //query Manufacturer with no duplicates
     try{
      	for (Asset__c vAsset: [Select Name, Manufacturer__c from Asset__c] )
      	{ 
      		if (!asset.contains(vAsset.Manufacturer__c) && vAsset.Manufacturer__c != null)
      		{
      			asset.add(vAsset.Manufacturer__c);
      			sorted.add(vAsset.Manufacturer__c);
      		
      		}
      	}//end of for
     }
     catch(Exception e){
     	System.debug(e.getMessage());
     }
     
     
      //sort Manufactures in Ascending order
      sorted.sort();
      
      //add manufacturer selectOptions
      allManufactures.add(new selectOption('all','All Manufactures',false));
      for (String s:sorted)
      {
      	if (s != null)
      	allManufactures.add(new selectOption(s,s));
      	System.debug(s);
      }//end of for
      	
      
     
      return allManufactures;
   }
   

  can anyone help me?

I have a before trigger running on Cases where I am checking a few fields for changes, and notifying the Case Contact owner via email.

 

I am using trigger.new and grabbing the LastModifiedById from the record, but it seems to be the previous person who made the update (the old record value) not the person who just made the update (the new record value).

 

Is that field updated after the record is committed? And if so, how can I find out who made the changes to the record so I can include it in my notification? 

Hi all:

   I have the following, where I split the text area box with names but I do not know how to get the next value in that split... for example:

TextBox Area = X,Y,Z

3 Names
I use code to Split it based on comma (',')

but in a for loop do not know how to go to the next value...

 

            queryAttendeesLines(investor.id);           
            List<Investor_Feedback__c> sarq = new List<Investor_Feedback__c>(
            [Select Id,S_P_Attendees__c FROM Investor_Feedback__c
            where id=:investor.id] );   
            integer gone = -1;
            integer i = 0; 
            
            String filename;
            filename = sarq[0].S_P_Attendees__c; 
            List<string> my_list = new List<String>();
            for ( i=0; i< attendeeLineItems.size(); i++ ) {
            if(sarq[0].S_P_Attendees__c == null){
            sarq[0].S_P_Attendees__c = attendeeLineItems[i].Attendee_name__c; 
            }
            else {
                List<String> parts = filename.split(',');
                filename = parts[parts.size()-1];
                System.debug('-parts='+ parts + '-filename=' + filename + '-attendeeLineItems=' + attendeeLineItems[i].Attendee_name__c);
                System.debug('z1' + parts[i]);
                if(filename!=attendeeLineItems[i].Attendee_name__c){

                sarq[0].S_P_Attendees__c = sarq[0].S_P_Attendees__c = + ',' + attendeeLineItems[i].Attendee_name__c;                 
                }
            }
        }

 I tried Filename = parts.get(i) <== gave me error System.ListException: List index out of bounds: 1  ???

I have one task that is assigned to me i.e, Convert JSON data (JSON representation of an image) that is stored in Salesforce.com to an actual image and store it as an attachment to the same record.

 

I have the java code for this, but is there any way of doing this with salesforce.com directly, if yes, can anyone help me, giving some direction as what needs to done.
 
Data is being transmitted in JSON is not via base64
 
Example of the JSON data that is being stored in Salesforce.com 
 
[{"lx":12,"ly":15,"mx":12,"my":14},{"lx":13,"ly":14,"mx":12,"my":15},{"lx":14,"ly":14,"mx":13,"my":14},{"lx":14,"ly":15,"mx":14,"my":14},{"lx":15,"ly":15,"mx":14,"my":15},{"lx":16,"ly":15,"mx":15,"my":15},{"lx":17,"ly":15,"mx":16,"my":15},{"lx":18,"ly":16,"mx":17,"my":15},{"lx":19,"ly":17,"mx":18,"my":16},{"lx":20,"ly":17,"mx":19,"my":17},{"lx":21,"ly":17,"mx":20,"my":17},{"lx":22,"ly":18,"mx":21,"my":17},{"lx":23,"ly":18,"mx":22,"my":18},{"lx":24,"ly":18,"mx":23,"my":18},{"lx":25,"ly":18,"mx":24,"my":18},{"lx":26,"ly":18,"mx":25,"my":18},{"lx":26,"ly":19,"mx":26,"my":18},{"lx":27,"ly":20,"mx":26,"my":19},{"lx":28,"ly":20,"mx":27,"my":20},{"lx":29,"ly":20,"mx":28,"my":20},{"lx":30,"ly":20,"mx":29,"my":20},{"lx":30,"ly":21,"mx":30,"my":20},{"lx":31,"ly":21,"mx":30,"my":21},{"lx":32,"ly":21,"mx":31,"my":21}]
 
 
 
 
  • September 11, 2012
  • Like
  • 0

Hi, I am trying to find the available RecordTypes for a User or User's Profile from my APEX class. Any idea how can this be done?

I've lot of Visualforce pages developed, but I can't figure out how to keep the ability to "Add a Tag" to records.  Is there anyway to get the Tagging  functionality to work on visualforce page, or is there any visualforce tag or attribute for a tag that allows me to do so? Kindly please help.

I have to display Case as a related list to MyCustomObject.

Case has a lookup to MyCustomObject with child relation name as Cases

 

I have this line placed in my visualforce page 

 <apex:relatedList list="Cases__r"/> .

 

I don't get the error when I open the page as a system admin

but when I open it with different custom profile, it give me the error:

 

"'Cases__r' is not a valid child relationship name for entity MyCustomObject"


The custom profile in use  has "Modify all" permissions on cases

someone please help.


  • September 24, 2010
  • Like
  • 0

Hi,

 

I have a date variable called start_date and I am trying to assign today's date to it like below in apex class:

 

start_date = today();

 

I am getting the below issue:

 

Error: Compile Error: Method does not exist or incorrect signature: today().

 

Please let me know what is the way to get this.

 

Thanks,

Jagadish.

  • May 17, 2012
  • Like
  • 0

Hello,

 

I have and Apex trigger that works fine but I need to make a change to it.......and I can't figure out how to do it.

The code works great when creating a new record.....I also need it to execute when an update it made.

 

The code gets the user's managers name and populates a field in the opportunity object.  I need it to update this field when the opportunity owner changes.  Any help would be most appreiciated.

 

Thanks.

 

******************************************************************************************

 

 

 

trigger Opp_Owner on Opportunity (before insert, before update ) {
/*****************************************************************************
Name     : Update Owner Manager on the opportunity from the User object

Purpose  : defaults the Owner Manager field of the opportunity from the User

******************************************************************************/
    
  //holds User Ids
  Set<Id> setUserIds = new Set<Id>();
 
  //holds a list of Users
  List<User> lstUser = new List<User>();
 
  //holds key value pairs of User Id and User Object
  Map<Id, User> mapUserObj = new Map<Id, User>();

  //holds User object
  User UserObj;
  
  //For each opportunity being inserted add User Id value in in Set of User Ids.
  for(Opportunity oppObj : Trigger.new){
    if(oppObj.OwnerId != null){
      setUserIds.add(oppObj.OwnerId);
    }
  }
 
  
  //Fetch all Users whose Id is in the Set.
  lstUser = [select Id, Name, Manager_Full_Name__c, ManagerId from User where Id in :setUserIds Limit 1000];
  if(lstUser.size() == 0){
    return; 
  }
 
  //Add these fetched Users in a Map <User Id, User object>
  for(User usrObj : lstUser){
    mapUserObj.put(usrObj.Id, usrObj); 
  }
 
  //for each opportunity being inserted get User from the map and update the field values
  for(Opportunity oppObj : Trigger.new){
    //get User object
    if(oppObj.OwnerId != null){
      if(mapUserObj.containsKey(oppObj.OwnerId)){
        UserObj = mapUserObj.get(oppObj.OwnerId);
        //map opportunity fields to User fields
        oppObj.Opportunity_Owner_s_Manager__c = UserObj.Manager_Full_Name__c;
      } 
    }
  }

 }

 

 

How to display related list in the same VF page when clicked upon any record of an object present in pageblock table ?

 

Scenario:-

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

I have pageblock table with a list of filtered opportunity records, when i try to click on any record's Edit commandlink present in pageblock table , the page should display its corresponding "OpenActivities" relatedlist below the table. Is there any way to pass the clicked record id to the <apex:relatedlist> component , so that it can open the related list using this component.

 

 

 

Please help me with the code.

 

thanks,

Hi

 

I want to know whether the parent child relationship works the same way in case of an opportunity and a task as it works in case of an account and a contact. Because in the following query when I query fields of a task in sub query, nothing is  returned.

 

optylist = [select name,keycode__c,taskid__c,(select subject,status from Tasks) from Opportunity where name='Test'];

 

Please correct me where I am going wrong.

So I'm still learning VF/apex and I've run into an issue. I have a master detail relationship, similar to an invoice with line items. I'm passing the ID of the invoice to a new VF page, using that ID I want to pull all all list item IDs associated with it and save them to a list. How would I write this? I keep trying different ideas but I'm having a hard time working out the steps. Any suggestions would be appreciated.

 

Update: I came up with this and it seems to be working? But now I can't get movieList to display on the VF page using either a dataTable or apex:repeat. Any ideas? I tried moving the code block to a get method for movieLIst and  that didn't seem to work either.

I was able to come up with this, it appears to be working but now I'm not sure how to display it on the VF page. It doesn't seem to work as a value for an apex:dataTable

public class SuccessController {

    public List<Unit_Rental__c> movieList {get;set;}
    public string moviePrice;
    string rentalRecordId;

   public SuccessController() {
       List<Unit_Rental__c> movieList = new List<Unit_Rental__c>();
       rentalRecordId=ApexPages.currentPage().getParameters().get('id');
       movieList=[SELECT ID, Movie__r.name FROM Unit_Rental__c WHERE Rental__r.ID=:rentalRecordId];
       System.debug(movieList[0].Movie__r.name);
   }

}

 

 

Thanks!

 

hi im having problems with a test class. everytime i run the test it gives me an error System.UnexpectedException No such column 'Name' on entity Asset__c. here is the code that givin me that error.

public static List<selectOption> manufactures(){  
   	  List<selectOption> allManufactures = new List<selectOption>();   
      Set<String> asset = new Set<String>();
      List<String> sorted = new List<String>();
     
     //query Manufacturer with no duplicates
     try{
      	for (Asset__c vAsset: [Select Name, Manufacturer__c from Asset__c] )
      	{ 
      		if (!asset.contains(vAsset.Manufacturer__c) && vAsset.Manufacturer__c != null)
      		{
      			asset.add(vAsset.Manufacturer__c);
      			sorted.add(vAsset.Manufacturer__c);
      		
      		}
      	}//end of for
     }
     catch(Exception e){
     	System.debug(e.getMessage());
     }
     
     
      //sort Manufactures in Ascending order
      sorted.sort();
      
      //add manufacturer selectOptions
      allManufactures.add(new selectOption('all','All Manufactures',false));
      for (String s:sorted)
      {
      	if (s != null)
      	allManufactures.add(new selectOption(s,s));
      	System.debug(s);
      }//end of for
      	
      
     
      return allManufactures;
   }
   

  can anyone help me?

Hello

 

Sorry if this has been posted already but I am looking for the syntax to run a class from an anonymous block in the system log.

 

This is the class:

 

global class checkSupportDailyTarget implements Schedulable{
    
   global void execute(SchedulableContext sc) {

   //do some work  
}

 

I 've tried this:

 

checkSupportDailyTarget  a = new checkSupportDailyTarget ();
a.execute();

 

But I get the error 

Compile Error: line 2, column 1: Method does not exist or incorrect signature: [checkSupportDailyTarget].execute()

 

 

Thank you

Marc

  • August 24, 2011
  • Like
  • 0

I have a before trigger running on Cases where I am checking a few fields for changes, and notifying the Case Contact owner via email.

 

I am using trigger.new and grabbing the LastModifiedById from the record, but it seems to be the previous person who made the update (the old record value) not the person who just made the update (the new record value).

 

Is that field updated after the record is committed? And if so, how can I find out who made the changes to the record so I can include it in my notification? 

I have a situation where I'm trying to implement a synching of a set of information between Accounts and Contacts, regardless of which object level the information is updated. I have built out the custom code to synch Account information to all contacts when it's changed at the Account level but I'm running into weirdness in the Trigger and code when the Contact level information is updated. It should flow logically like this:

  1. Information is updated at one of the contact records
  2. The code updates the information ont he parent Account of that contact
  3. The code then queries all of the contacts related to that parentAccount and updates the information there as well

I want to prevent recursion so I need to somehow exclude the originating contact from the query in step 3.

 

Here is my trigger:

trigger ContactbeforeUpdateTrigger on Contact (before update) {
	
	List<Contact> changedContacts = new List<Contact>();
	
	for (Integer i = 0; i < Trigger.new.size(); i++) {	
			if( 
			(Trigger.old[i].Competitive_Owner__c != Trigger.new[i].Competitive_Owner__c)) {
				changedContacts.add(Trigger.new[i]);
			}
			
			if(!changedContacts.isEmpty()){
			
			ContactServices.syncContactsToAccountandRelatedContacts(changedContacts);
		}
	}
}

 

 

Here is my Apex Class and the method called from the Trigger:

public with sharing class ContactServices { 

Public static void syncContactsToAccountandRelatedContacts (List<Contact> changedContacts){
	List<Account> accountsToUpdate = new List<Account>();
	List<Contact> contactsToUpdate = new List<Contact>();
		
	for (Integer i = 0; i < changedContacts.size(); i++) {		        	
		changedContacts[i].Account.Competitive_Owner__c= changedContacts[i].Competitive_Owner__c;	  
            	accountsToUpdate.add(changedContacts[i].Account);
        }
        update accountsToUpdate;

		
	contactsToUpdate = [Select id, accountId, Competitive_Owner__c From Contact Where accountId in: 
						accountsToUpdate];
						
	for (Integer i = 0; i < contactsToUpdate.size(); i++){
	     contactstoUpdate[i]Competitive_Owner__c = contactstoUpdate[i].Account.Competitive_Owner__c ;	
	updatedContacts.add(c); 
	}
	update updatedContacts;
}

Hi all:

   I have the following, where I split the text area box with names but I do not know how to get the next value in that split... for example:

TextBox Area = X,Y,Z

3 Names
I use code to Split it based on comma (',')

but in a for loop do not know how to go to the next value...

 

            queryAttendeesLines(investor.id);           
            List<Investor_Feedback__c> sarq = new List<Investor_Feedback__c>(
            [Select Id,S_P_Attendees__c FROM Investor_Feedback__c
            where id=:investor.id] );   
            integer gone = -1;
            integer i = 0; 
            
            String filename;
            filename = sarq[0].S_P_Attendees__c; 
            List<string> my_list = new List<String>();
            for ( i=0; i< attendeeLineItems.size(); i++ ) {
            if(sarq[0].S_P_Attendees__c == null){
            sarq[0].S_P_Attendees__c = attendeeLineItems[i].Attendee_name__c; 
            }
            else {
                List<String> parts = filename.split(',');
                filename = parts[parts.size()-1];
                System.debug('-parts='+ parts + '-filename=' + filename + '-attendeeLineItems=' + attendeeLineItems[i].Attendee_name__c);
                System.debug('z1' + parts[i]);
                if(filename!=attendeeLineItems[i].Attendee_name__c){

                sarq[0].S_P_Attendees__c = sarq[0].S_P_Attendees__c = + ',' + attendeeLineItems[i].Attendee_name__c;                 
                }
            }
        }

 I tried Filename = parts.get(i) <== gave me error System.ListException: List index out of bounds: 1  ???

I wrote two very similar triggers, one of them works the other one does not. The triggers simply attempt to populate the account lookup field in Contacts by using an external id added to each account. The first trigger simple loops through all the accounts attempting to find one with a matching external id but that seemed to be inefficient and would eat up a look for script statements. So I decided to create a second similar trigger that would use maps.

 

//this one works fine
trigger FindAccount on Contact (before insert, before update){
    List<Account> AllAccounts = [Select Id, k_id__c from Account];
    
    for(Contact c: Trigger.new){
        for (Account acct : AllAccounts){
            if (acct.k_id__c == c.k_id__c){
                c.AccountId = acct.Id;
                break;
            }   
        }
    }
}

##################################################################

//this one does not
trigger FindAccount on Contact (before insert, before update){
    List<Account> AllAccounts = [Select Id, k_id__c from Account];
    Map<Decimal, Account> AccountMap = new Map<Decimal, Account>();
    
    for(Account a : AllAccounts){
    	AccountMap.put(a.k_id__c,a);
    }     
    
    for (Contact c : Trigger.new){
    	Account temp = AccountMap.get(c.k_id__c);
        if (temp != null)
    	     c.AccountId = temp.Id;
    }

}

 The problem is that the second trigger passes the same tests that I had initially wrote, however it doesn't work when I add or modify a contact through the browser or api. When I do 'Execute Anonymous' via the Salesforce API it seems work. Does anyone know what the problem is?

 

Execute Anonymous Output

Anonymous execution was successful.

20.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,INFO
Execute Anonymous: Contact test = new Contact (FirstName = 'test', LastName = 'test', k_id__c = 999, u_id__c = 90);
Execute Anonymous: Insert test;
Execute Anonymous:
Execute Anonymous: test = [select accountId from Contact where u_id__c = 90];
Execute Anonymous: system.debug ('test account lookup: ' + test.accountId);
15:56:58.033 (33252000)|EXECUTION_STARTED
15:56:58.033 (33295000)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
15:56:58.034 (34677000)|DML_BEGIN|[2]|Op:Insert|Type:Contact|Rows:1
15:56:58.063 (63635000)|CODE_UNIT_STARTED|[EXTERNAL]|01qK0000000Cd7P|FindAccount on Contact trigger event BeforeInsert for [new]
15:56:58.063 (63928000)|SOQL_EXECUTE_BEGIN|[2]|Aggregations:0|Select Id, k_id__c from Account
15:56:58.072 (72120000)|SOQL_EXECUTE_END|[2]|Rows:2

15:56:58.073 (73294000)|CODE_UNIT_FINISHED|FindAccount on Contact trigger event BeforeInsert for [new]
15:56:58.122 (122561000)|DML_END|[2]
15:56:58.122 (122817000)|SOQL_EXECUTE_BEGIN|[4]|Aggregations:0|select accountId from Contact where u_id__c = 90
15:56:58.128 (128040000)|SOQL_EXECUTE_END|[4]|Rows:1
15:56:58.128 (128267000)|USER_DEBUG|[5]|DEBUG|test account lookup: 001K0000005yGyMIAU

i need a trigger that updates a custom object record's Owner field to be the record's creator when the record is marked as "Payment Processed" in a custom picklist field called "Billing Status".  so basically whenever a record is updated to that value in that picklist field, the trigger should simply switch the owner back to record creator.  Is this possible?

I have to display Case as a related list to MyCustomObject.

Case has a lookup to MyCustomObject with child relation name as Cases

 

I have this line placed in my visualforce page 

 <apex:relatedList list="Cases__r"/> .

 

I don't get the error when I open the page as a system admin

but when I open it with different custom profile, it give me the error:

 

"'Cases__r' is not a valid child relationship name for entity MyCustomObject"


The custom profile in use  has "Modify all" permissions on cases

someone please help.


  • September 24, 2010
  • Like
  • 0

 

 I have a program feature that generates PDF documents via the standard Visual Force 'renderAs="PDF"' mechanism. This feature does not work reliably for 'larger' documents (i.e. 50 pages). By 'reliably' I mean that I can run PDF generation 10 times, and it will work successfully 3-5 times out of these 10. The rest of the time, after a 3+ min delay, I get the following error message:

"PDF generation couldn't complete because the request took too long. You are using components that are not fully supported by PDF generation, please consult the documentation for a list of unsupported components."

I've reviewed the page (it's a long and ugly beast, so am not posting it here), but am not seeing anything unsupported or suspicious.  This test can be run on the exact same object, with the exact same data, 10 times in a row, and the results are non-deterministic.   The fact that it works for some runs, but not others makes me suspect that this doesn't have to do with any specific page markup, but I could be wrong.

When I look at the system log output, I see that the controller code for this page is done after 12-15 sec. After that, there's a long delay--when the PDF is rendered successfully, the delay is about 30-40 sec. When it fails, as above, it is 3+ min.

It appears that something is making the PDF rendering engine go haywire, but I have not been able to figure out what it may be, and therefore, how to work around it.

If you have the system log open, you can see that the last statement from the controller (CODE_UNIT_FINISHED|StaticResourcePick <init>) is usually executed a long time before the CUMULATIVE_LIMIT_USAGE line. 

 

 

Does anyone have any ideas/suggestions?