• yervandy
  • NEWBIE
  • 0 Points
  • Member since 2011

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

I have a trigger that works fine, but I have a SOQL query within a for loop. I know this is not a good idea because of APEX governer limits but I can't figure out what the syntax will be if I move it outside of the loop. Sales_Person_On_Record__c is a user lookup field. 

 

Within the for loop I am able to use op.field_name, and I'm not sure how I would use that outside the for loop. Any help would be appreciated. 

 

trigger SalesPersonOnRecord on Opportunity (before insert, before update) {
	
	for( Opportunity op : Trigger.new ) {
		String spadName; //Sales Person Associated with Deal
		String ownerName; //Name of the Opportunity Owner
		
                spadName = [select id, name from user where id = :op.Sales_Person_Associated_with_Deal__c limit 1].name;
		
		//Get the name of the opportunity owner
		ownerName = [select id, name from user where id = :op.ownerid limit 1].name;

                //Rest of the code is excluded since I only need help with the queries
      }
}

 

I am trying to build a Visualforce page for submitting a new Case for one specific record type. I want the user to bypass picking a Record Type. When they click on a link, it will take them to this visualforce page, and I'd like my picklists in this page to display values compatible with a Record Type. Do I have to create a custom controller to handle the Record Type?

I would like help on writing a trigger on Account before update that gets the related contacts, then inserts that list of contacts in an account text area field.

 

The text area will contain:

contact name 1\n

contact name 2\n

etc...

 

I'm not an apex developer so I'm not sure where to begin, so any sample code for doing something like that would be a great help.

 

Thanks.

I have a trigger that works fine, but I have a SOQL query within a for loop. I know this is not a good idea because of APEX governer limits but I can't figure out what the syntax will be if I move it outside of the loop. Sales_Person_On_Record__c is a user lookup field. 

 

Within the for loop I am able to use op.field_name, and I'm not sure how I would use that outside the for loop. Any help would be appreciated. 

 

trigger SalesPersonOnRecord on Opportunity (before insert, before update) {
	
	for( Opportunity op : Trigger.new ) {
		String spadName; //Sales Person Associated with Deal
		String ownerName; //Name of the Opportunity Owner
		
                spadName = [select id, name from user where id = :op.Sales_Person_Associated_with_Deal__c limit 1].name;
		
		//Get the name of the opportunity owner
		ownerName = [select id, name from user where id = :op.ownerid limit 1].name;

                //Rest of the code is excluded since I only need help with the queries
      }
}

 

I am trying to build a Visualforce page for submitting a new Case for one specific record type. I want the user to bypass picking a Record Type. When they click on a link, it will take them to this visualforce page, and I'd like my picklists in this page to display values compatible with a Record Type. Do I have to create a custom controller to handle the Record Type?

I would like help on writing a trigger on Account before update that gets the related contacts, then inserts that list of contacts in an account text area field.

 

The text area will contain:

contact name 1\n

contact name 2\n

etc...

 

I'm not an apex developer so I'm not sure where to begin, so any sample code for doing something like that would be a great help.

 

Thanks.