You need to sign in to do that
Don't have an account?
ECorona
Add the opportunity stage on Event
Greetings!
I'm trying to get the opp stage name into the Event and freeze the value, what i'm trying to do is to get a report of all activities of the opp by stage.
Is that possible?
Thank you.
Hello,
Create a report on report type "Activities with opportunities" and apply a filter on Oppotunity stage. Now access this report on visualforce page by Salesforce Analytics API.
Refer: http://blogs.developerforce.com/developer-relations/2013/09/using-the-salesforce-analytics-api-on-a-visualforce-page.html?app_data=%7B%22pi%22%3A%225249fadf7c959d0b42000002%22%2C%22pt%22%3A%22wall%22%7D
So, you can create a text field in Event object, and store the opportunity stage value in the event where the realted to field (what id) id is opportunityid.
And hide this field from event page layout. So, at the time of report generation, you can use that field value.
Hope this will help you...!
Please don't forget to give kudos by clicking on the Star icon and mark this as a solution, if this works out.
I add the text field but i don't know how to save the stage i was looking for the stagename field but i don't get the opp field list
Hi,
Now, I understood what you want. That was so simple, Opportunity Stage field should be refered by the Field API name as StageName
Example:
trigger UpdateStageVal on Task(before insert, before update){
for(Task t: trigger.new){
Opportunity opp = [select id,name,StageName from Opportunity where id =: t.whatID limit 1];
t.StageTextField__c = opp.StageName;
//your code continues here
}
}
Hope this will help you...!
Please don't forget to give kudos by clicking on the Star icon and mark this as a solution, if this works out.
Thank you.
Also, please mark this as a solution.
execution of BeforeInsert caused by: System.QueryException: List has no rows
Hi,
There should be a slight modification in your code. Try the following.
Example:
trigger UpdateStageVal on Task(before insert, before update){
for(Task t: trigger.new){
List<Opportunity> opp = [select id,name,StageName from Opportunity where id =: t.whatID];
if(opp.size() > 0){
for(Opportunity o : opp){
t.StageTextField__c = o.StageName;
//your code continues here
}
}
}
}
While using an object query, it will throw this error if there is no value exists. So, for this scenario always you need to use the List and check the size of the list before you do an operation.
Hope this will help you...!
Please don't forget to give kudos by clicking on the Star icon and mark this as a solution, if this works out.
That was very nice post but i was wondering what will happen if Opportunity is inserted in bulk, at that time there may be a chance of hitting the salesforce limit of soql queries, I am not an expert I have just started my carrer but I have learnt one thing so far that never fire soql query inside for loop as that's a very bad practice.
I have written a code, have a look at it and let me know if this solves your problem