• edwin_beltran
  • NEWBIE
  • 25 Points
  • Member since 2011

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

Hi Guys,

 

I feel a bit daft as i just can't work out how to access related objects within the trigger.

 

My structure is something like this:

 

Rep < Account > Return

 

And i'd like to get information from REP to process the return.

 

trigger get_REP_Email on Return__c (before update) {
	
	Return__c myReturn = trigger.new[0];

}

 Above is all i've managed to get so far, and i've tried many things. What i'd like to do is on update, take the return object - Find the related Account Object - Find the related rep object and base a condition in the return object on the rep object?

 

Can this be done?

 

Can anybody point me in the right direction?

 

Kind Regards,

CP

Hi team,

 

I am trying to figure it out if this is possible?

 

WebService static string updateOpportunity(string oppId, string fieldName, string fieldValue)
        {
        	try
            {   
            	integer i = Database.countQuery('select count() from Opportunity where Id = :oppId');
            	if (i > 0) {
	        Opportunity o = [select :fieldName from Opportunity where Id = :oppId limit 1];
	        	o.fieldName = fieldValue;
	        	update o;
	        	return 'OK';
            	}	        		        
          	}	
           	catch (DmlException e) {                       
           		return string.valueof(e); 
           	}        
        }

 

someone gets the idea... is this possible?

 

please post or sms me.

 

Stragne:mansad:

 

any thing wrong in my code

 

list<Account> accts = new list<Account>{new Account(name='test account')};

or


Account[] newaccts =new Account[]{new Account(name='dev account')};

  • April 13, 2012
  • Like
  • 0

Hi team,

 

I am trying to figure it out if this is possible?

 

WebService static string updateOpportunity(string oppId, string fieldName, string fieldValue)
        {
        	try
            {   
            	integer i = Database.countQuery('select count() from Opportunity where Id = :oppId');
            	if (i > 0) {
	        Opportunity o = [select :fieldName from Opportunity where Id = :oppId limit 1];
	        	o.fieldName = fieldValue;
	        	update o;
	        	return 'OK';
            	}	        		        
          	}	
           	catch (DmlException e) {                       
           		return string.valueof(e); 
           	}        
        }

 

someone gets the idea... is this possible?

 

please post or sms me.

 

Hi Guys,

 

I feel a bit daft as i just can't work out how to access related objects within the trigger.

 

My structure is something like this:

 

Rep < Account > Return

 

And i'd like to get information from REP to process the return.

 

trigger get_REP_Email on Return__c (before update) {
	
	Return__c myReturn = trigger.new[0];

}

 Above is all i've managed to get so far, and i've tried many things. What i'd like to do is on update, take the return object - Find the related Account Object - Find the related rep object and base a condition in the return object on the rep object?

 

Can this be done?

 

Can anybody point me in the right direction?

 

Kind Regards,

CP

Hi,

    I have problem in Batch Apex Query.Below is My Query,

 

 

return DataBase.getQueryLocator('Select Id,Account.Annual_Account_Target_Number__c,Account.Target_for_Q1__c,Account.Target_for_Q2__c,Account.Target_for_Q3__c,Account.Target_for_Q4__c,Territory.Name,Account.Name,Opportunity__c,CloseDate,Projections__c,Closed_Won__c,AccountId,StageName,(Select Id, Name,Start_Date__c,End_Date__c,Opportunity__c,Resource_Amount__c,CreatedDate From OpportunityProducts__r where Start_Date__c >= '+g_StartDate+' AND End_Date__c <= '+ g_EndDate +') from Opportunity where (StageName!=\'Lead\' AND StageName!=\'Closed Lost\') AND (CloseDate >= '+g_StartDate+' AND CloseDate <= '+ g_EndDate +' )ORDER BY CloseDate');

 

 The error message is : System.QueryException: line 1:411 no viable alternative at character ' ' .

 

Please help me to get out from this bug.

 

Thanks! 

 

  • November 19, 2009
  • Like
  • 0