• Devendra_07
  • NEWBIE
  • 15 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
Hello,

I have created a custom site for guest users, and I'm displaying a VF page. On that VF page, I'm doing a conversion of different timezones on the basis of selected timezone. Ex: Org follows Asia/Kolkata timezone, on the UI I'm displaying all the timezones. So, when a customer selects the date and timezone, it is converting the org timezone to the selected timezone. The problem I'm facing is: It is working fine when VF page is previewed but doesn't work on a custom site. Time is not converted as expected.
Ex: On VF page :
Date selected --> 10 June 2020
Time Zone selected --> Asia/Tokyo.
After conversion --> 8AM (IST) is converted to 11:30 (Asia/Tokyo).

But on the custom site:
Date selected --> 10 June 2020
Time Zone selected --> Asia/Tokyo.
After conversion --> 8AM (IST) is converted to 13:30(Asia/Tokyo).

P.S - I have given all the required permissions to the guest user profile.

Snippet used:
BusinessHours bh = [SELECT ID,SundayStartTime,SundayEndTime FROM BusinessHours WHERE IsDefault = TRUE LIMIT 1];
Date dt = Date.newInstance(year,month,datez);
Timezone tz = Timezone.getTimeZone(selectedtimezone);
Datetime gmt = DateTime.newInstance(dt,bh.SundayStartTime);
Datetime convertedTime = gmt.addSeconds(tz.getOffset(gmt)/1000);


Please let me know the reason/explanation.

Thanks.
Hello Everyone,

I have a situation where i'm using the email-to-case. The scenerio is : 
1. If i use email-to -case then i'm not able to fetch the attachments from Case object
query --> SELECT CaseNumber, (Select Name from Attachments) from Case
This doesn't return any attachment.
2. If i use custom apex class :- inboundemailhandler class, I'm receiving the attachments from email and also able to fetch the attachments using the same query mentioned above..

Code --> global class GetEmailToSalesForce implements Messaging.InboundEmailHandler {   
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.Inboundenvelope envelope) {    
        Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
        Case newCase = new Case();
        newCase.SuppliedName = email.plainTextBody;
        newCase.SuppliedEmail = envelope.fromAddress;
        newCase.Subject = email.subject;
        newCase.Status = 'New';
        newCase.Origin = 'Email';
        try{
        insert newCase;
            System.debug('New Case is  created:'+newCase.Id);
        }catch(Exception e){
            system.debug('Got an exception:'+e);
        }
        if (email.binaryAttachments != null && email.binaryAttachments.size() > 0) {
            for (integer i = 0 ; i < email.binaryAttachments.size() ; i++) {
                Attachment attachment = new Attachment();
                //attachment.ParentId = contact.Id;
                attachment.ParentId = newCase.Id;
                attachment.Name = email.binaryAttachments[i].filename;
                attachment.Body = email.binaryAttachments[i].body;
                insert attachment;
            }
        }
        
        return result;
    }
}

Can someone please let me know the reason.

Thanks.
Hello,

I have created a custom site for guest users, and I'm displaying a VF page. On that VF page, I'm doing a conversion of different timezones on the basis of selected timezone. Ex: Org follows Asia/Kolkata timezone, on the UI I'm displaying all the timezones. So, when a customer selects the date and timezone, it is converting the org timezone to the selected timezone. The problem I'm facing is: It is working fine when VF page is previewed but doesn't work on a custom site. Time is not converted as expected.
Ex: On VF page :
Date selected --> 10 June 2020
Time Zone selected --> Asia/Tokyo.
After conversion --> 8AM (IST) is converted to 11:30 (Asia/Tokyo).

But on the custom site:
Date selected --> 10 June 2020
Time Zone selected --> Asia/Tokyo.
After conversion --> 8AM (IST) is converted to 13:30(Asia/Tokyo).

P.S - I have given all the required permissions to the guest user profile.

Snippet used:
BusinessHours bh = [SELECT ID,SundayStartTime,SundayEndTime FROM BusinessHours WHERE IsDefault = TRUE LIMIT 1];
Date dt = Date.newInstance(year,month,datez);
Timezone tz = Timezone.getTimeZone(selectedtimezone);
Datetime gmt = DateTime.newInstance(dt,bh.SundayStartTime);
Datetime convertedTime = gmt.addSeconds(tz.getOffset(gmt)/1000);


Please let me know the reason/explanation.

Thanks.
Hello Everyone,

I have a situation where i'm using the email-to-case. The scenerio is : 
1. If i use email-to -case then i'm not able to fetch the attachments from Case object
query --> SELECT CaseNumber, (Select Name from Attachments) from Case
This doesn't return any attachment.
2. If i use custom apex class :- inboundemailhandler class, I'm receiving the attachments from email and also able to fetch the attachments using the same query mentioned above..

Code --> global class GetEmailToSalesForce implements Messaging.InboundEmailHandler {   
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.Inboundenvelope envelope) {    
        Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
        Case newCase = new Case();
        newCase.SuppliedName = email.plainTextBody;
        newCase.SuppliedEmail = envelope.fromAddress;
        newCase.Subject = email.subject;
        newCase.Status = 'New';
        newCase.Origin = 'Email';
        try{
        insert newCase;
            System.debug('New Case is  created:'+newCase.Id);
        }catch(Exception e){
            system.debug('Got an exception:'+e);
        }
        if (email.binaryAttachments != null && email.binaryAttachments.size() > 0) {
            for (integer i = 0 ; i < email.binaryAttachments.size() ; i++) {
                Attachment attachment = new Attachment();
                //attachment.ParentId = contact.Id;
                attachment.ParentId = newCase.Id;
                attachment.Name = email.binaryAttachments[i].filename;
                attachment.Body = email.binaryAttachments[i].body;
                insert attachment;
            }
        }
        
        return result;
    }
}

Can someone please let me know the reason.

Thanks.
Hi,
I have created an EmailMessage, but I cannot fetch the name of the attachments through "EmailMessage.Attachments", so how? Any examples?

Hi All,

I am trying to retrieve Case attachments along with case records as part of my client requirement. But i am getting an error like Binary fields cannot be selected in join queries. Is there any way to get Case and related attachments within a single query . Below is my query

[SELECT Status,casenumber,(SELECT id,name,Body FROM Attachments)  FROM Case]

Note: "Body" is must in attachments.

Thanks in Advance!!
Sravan.