function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PookyPooky 

using days of the week text in reporting

I have a user that wants his reports to reflect the number of opportunities created by day of week, but he wants the text ie Monday, Tuesday, Wed, to show in the report. Can anyone tell me who to do this?

 

Thanks

soofsoof

With the mindset of a developer, I would suggest that you create a custom text field and populate it with the Day of Week via a BEFORE INSERT trigger.  Do something like the following:

 

 

trigger on Opportunity (before insert) { for( Opportunity oppty : trigger.new ) { oppty.Created_Day_Of_Week__c = System.now().format('EEEE'); }}

 

This solution is based on the assumption that the user would be using the standard reports provided by Salesforce.com.  If that is not the case, then please explain the scenario a littl.

 

Hope this helps!

 

-soof 

 

PookyPooky
Thanks! I will give it a try.
PookyPooky

ok. I gave that a try but it didn't work. I created a text formula field in the opportunity and pasted what you have below as the formula and I am getting a syntax error on trigger.  Am I doing something wrong?

 

Thanks

soofsoof

Sorry - I see what I did wrong... I didn't put the name of the trigger!  Just typed the code here and didn't verify it.  Here's the fixed code:

 

trigger updateDayOfWeek on Opportunity (before insert) {
for( Opportunity oppty : trigger.new ) {
oppty.Created_Day_Of_Week__c = System.now().format('EEEE');
}
}

 

-----EDITING MESSAGE-----

Apologies... didn't read your reply attentively.  You don't need to create a custom "Formula" field - the code above is NOT formula code.  You simply need to create a custom Text field, which will be populated by this trigger, whenever an Opportunity is created.  Does that make sense?  Let me know if you need me to explain more.

 

-soof

 

 

Message Edited by soof on 07-14-2009 04:44 PM
PookyPooky
Thanks for your help with this. There doesn't seem to be an easy way to add the trigger from the UI in Professional. I will have to play around with sandbox and see if I can move the triger over that way. Thanks!
soofsoof

You'll need to create the trigger in Sandbox, then write a bit of Test Code that executes this trigger, and then deploy it to your Production instance.

 

-soof