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
DavserDavser 

Business Hours

Hey all,
Try to compile the following in an APEX controller class for a VF page:
 
Code:
BusinessHours bh = [Select b.FridayEnd from BusinessHours b where b.Id='01m0000000000GLAAY'];

 This query works in the Apex Explorer no problem. When I try to compile it in APEX it gives me the following error:
 
Error: Compile Error: No such column 'FridayEnd' on entity 'BusinessHours'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names
So is there an issue with the BusinessHours table in APEX???
 
Any help or insight would be much appreciated!
Thanks
Dave
TehNrdTehNrd
Try:

b.FridayEndTime

Also in APEx there is no need to use the letter dot notation. I feel it just clogs up the code.

Select FridayEndTime from BusinessHours where Id='01m0000000000GLAAY'



Message Edited by TehNrd on 09-03-2008 10:44 AM
DavserDavser

Thanks a million for the reply, greatly appreciated BUT (and there's always a but!)

I added Time to the end of it, and it compiled, which brought me on to the next problem. I tried to assign the value to a string but got an error saying: "Data type not supported."

I looked up the Enterprise WSDL then, as I assume that is where you got the fact that the field is called FridayEndTime. I see that the data type is actually something called "Time", which is also a listed primitive for apex. So now I have this in the code:

Code:
BusinessHours bh = [Select b.FridayEndTime from BusinessHours b where b.Id='01m0000000000GLAAY'];
Time timeSample = bh.FridayEndTime;


 This still throws the "Data type not supported" error.

Bottom line here is that it doesn't seem that APEX supports this? Any further ideas?

 

TehNrdTehNrd

Davser wrote:

Thanks a million for the reply, greatly appreciated BUT (and there's always a but!)

I added Time to the end of it, and it compiled, which brought me on to the next problem. I tried to assign the value to a string but got an error saying: "Data type not supported."

I looked up the Enterprise WSDL then, as I assume that is where you got the fact that the field is called FridayEndTime. I see that the data type is actually something called "Time", which is also a listed primitive for apex. So now I have this in the code:

Code:
BusinessHours bh = [Select b.FridayEndTime from BusinessHours b where b.Id='01m0000000000GLAAY'];
Time timeSample = bh.FridayEndTime;


 This still throws the "Data type not supported" error.

Bottom line here is that it doesn't seem that APEX supports this? Any further ideas?

 




Your right in the Time is a little unique. When you tried to convert it to a string was this your syntax:

String timeValue = String.valueOf(bh.FridayEndTime);
DavserDavser

Well, I was actually trying to display it on screen via an outputField element.

However I tried to use your suggested String.valueOf syntax, with no luck. Still getting the Data type not supported error!

As soon as i try to reference that field from the businesshours object the error is thrown.

TehNrdTehNrd
Hmm.... I think you may be right that it is not supported in Apex which is weird. In the documation there are time methods but  with these I even get the "Data type not supported" error:

Integer hour = bh.FridayEndTime.hour();

I would take this up with salesforce.com support if you can.



Message Edited by TehNrd on 09-03-2008 11:52 AM
DavserDavser
Well thank you very much for giving this a look over. I'll post any replies I get from SFDC.