You need to sign in to do that
Don't have an account?
Ludivine
ActiveTrigger doesn't make any shifts in Opportunity Object
Hello,
I have made a trigger to update records from account to Opportunity but it doesn't work.
I think there is a problem in the mapping... I have looked into salesforce Force.com Apex code Developer Guide but I make no success..
Here is my trigger, hope someone can tell me how to correct it.. thanks
trigger UpdateAccountToOppty on Account (Before Insert, Before Update) { List<Account> accountWithOpptys = [SELECT id,Industry__c,Segment__c,Sub_Segment__c, (select id,accountId,RecordTypeId, Industry__c,Segment__c,Sub_Segment__c from Opportunities where accountId IN :Trigger.newMap.keySet() AND Business_group__c='Amcor Flexibles Europe & Americas' ) from Account where Id IN :Trigger.newMap.keySet()]; //Loop through Accounts only once for(Account a : accountWithOpptys){ //Loop through related Opportunities only once for(Opportunity o: a.Opportunities){ if(o.RecordTypeId != '012200000002HdgAAE'){ o.industry__c = a.industry__c; o.segment__c = a.segment__c; o.sub_segment__c = a.sub_segment__c; } } } }
Hi,
As per your words,
There is trigger, but it is not working as expected (not updating something rit?)
To debug this use System.debug statement in the trigger to know whether the data is coming or not properly and
The functionality is working as expected or not.
To do this I can suggest how to use debug logs
For example
Here you will expect that the list contain 10 records.
But to confirm this you can follow this
System.debug(‘@@@@’+ lstacc.size());
This will give the size of the list at run time.
From above you can understand that System.debug will give the values of runtime and which will be available in debug logs.
Debug logs is for debugging something.
If you execute some code at back end the values will be passed at run time rit. To know the values of run time Debug Logs will be useful.
First you need to Enable debug logs for your user
Setup -> Monitoring -> debug Logs
Click new and select your username and click save and now debug logs for your user is activated.
Now execute the trigger by updating some record like that and refresh the debug logs.
Now fresh logs will be available for you.
Now come to your trigger place the Debug logs like below
By placing the Debug's like above you can find the problem.
All Answers
Hi,
You can use debug Logs to solve your problem by yourself.
Place System.debug(); statement everywhere and try to find where the data is coming or not.
Here Debug logs is the best way for this as per my idea.
Hi HariDinesh,
Sorry for my lack of knowledge but I am willing to learn! Could you tell me how I can acess to the Debug Log?
Must be very useful to have this but I have tried to paste my trigger in the Developer Console and it seems not to accept any trigger syntaxe..
In the meanwhile, I have find the Solution to my issue:
And now I would like to know where I could test this with System.Debug and see My selection acct.
Thanks a lot for your help.
Hi,
As per your words,
There is trigger, but it is not working as expected (not updating something rit?)
To debug this use System.debug statement in the trigger to know whether the data is coming or not properly and
The functionality is working as expected or not.
To do this I can suggest how to use debug logs
For example
Here you will expect that the list contain 10 records.
But to confirm this you can follow this
System.debug(‘@@@@’+ lstacc.size());
This will give the size of the list at run time.
From above you can understand that System.debug will give the values of runtime and which will be available in debug logs.
Debug logs is for debugging something.
If you execute some code at back end the values will be passed at run time rit. To know the values of run time Debug Logs will be useful.
First you need to Enable debug logs for your user
Setup -> Monitoring -> debug Logs
Click new and select your username and click save and now debug logs for your user is activated.
Now execute the trigger by updating some record like that and refresh the debug logs.
Now fresh logs will be available for you.
Now come to your trigger place the Debug logs like below
By placing the Debug's like above you can find the problem.