• Khalid Abdullah
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 13
    Replies
Hello all,

We have an apex class which updates a field called "Next Meeting Date" on Contacts based on the activities related to contact records
The class updates this field with the Activity date of the meeting nearest in the future.

We also have a visualforce page which is pulling the next meeting date information from the activity records and providing the information from each activity in the future for that contact on the top of the contact's page.

However, when the "All Day Event" field is selected on the activity, the visualforce page is pulling the UTC date, which is resulting in the VF section showing the incorrect date while the "Next Meeting Date" field is showing correctly.

Tl;Dr - how do I adjust the visualforce page to pull the correct time zone date when the "All Day Event" field is selected? Or do I need to manipulate the logic directly in the apex class for this to work. We would need to add 1 day to the StartDateTime and EndDateTime fields.

VisualForce code: 
<apex:page standardController="Contact" extensions="UpcomingMeetings" sidebar="false" showHeader="false">
    <style type="text/css">
    .meetingToday {
//        font-weight:bold;
        font-style:italic
    }
    </style>

    <apex:pageMessage severity="INFO" strength="1" summary="{!summary}" escape="false">
        <apex:dataTable value="{!events}" var="e" width="100%" cellpadding="1" cellspacing="1" rows="3">
            <apex:column >
                <li/>
            </apex:column>
            <apex:column >
                <apex:outputLink value="/{!e.Id}" target="_blank" styleClass="{!IF(DATEVALUE(e.StartDateTime)<TODAY(),'meetingToday','')}"><apex:outputField value="{!e.Subject}"/></apex:outputLink>
            </apex:column>
            <apex:column styleClass="{!IF(DATEVALUE(e.StartDateTime)<TODAY(),'meetingToday','')}">
                <apex:outputText value="from"/>
            </apex:column>
            <apex:column styleClass="{!IF(DATEVALUE(e.StartDateTime)<TODAY(),'meetingToday','')}">
                <apex:outputField value="{!e.StartDateTime}"/>
            </apex:column>
            <apex:column styleClass="{!IF(DATEVALUE(e.StartDateTime)<TODAY(),'meetingToday','')}">
                <apex:outputText value="to"/>
            </apex:column>
            <apex:column styleClass="{!IF(DATEVALUE(e.StartDateTime)<TODAY(),'meetingToday','')}">
                <apex:outputField value="{!e.EndDateTime}"/>
            </apex:column>
        </apex:dataTable>
    </apex:pageMessage>
</apex:page>

Apex class used for VisualForce page:
 
public with sharing class UpcomingMeetings {
    public List<Event> events { get; private set; }    
    
    public String summary { get; private set; }
    public String riaAdvisor { get; private set; }
     
    public UpcomingMeetings(ApexPages.StandardController controller) {
        Id contactId = controller.getRecord().Id;   
       system.debug('Contact id ---'+ contactId);
 
       Contact c = [SELECT id,Is_RIA_Advisor__c,RIA_Wholesaler_Name__c from Contact where Id=:contactId];
        
       riaAdvisor='';
       if (c.Is_RIA_Advisor__c)
        {
          riaAdvisor = 'This is a RIA contact. Please direct all calls to '+c.RIA_Wholesaler_Name__c+'<br/>';
        }      
        

       
        events = new List<Event>();
        try {
            Set<Id> eventIds = new Set<Id>();
            for (EventRelation e : [SELECT EventId FROM EventRelation  WHERE RelationId =:contactId AND Status NOT IN ('Declined','Uninvited')]) {
                eventIds.add(e.EventId);
            }
            events = [SELECT Id, Subject, StartDateTime, EndDateTime FROM Event WHERE (WhoId=:contactId OR Id IN :eventIds) AND Event.Cancelled__c <> TRUE AND ActivityDate>=TODAY ORDER BY ActivityDate ASC];
            
            if (events.isEmpty()) {
                summary = riaAdvisor +'You have no upcoming meetings scheduled'; 
            } else {
                summary = riaAdvisor +'Upcoming meetings';
            }
        } catch (Exception e) {
        }
    }



 
Hello all!

I'm trying to create a trigger that updates a custom "IsFrozen" field when a user's record is frozen.

The User object field, IsFrozen__c is supposed to see if the UserLogin object's IsFrozen field is updated to a value of true, and if so, update the user's record to true. I think this will greatly help us with the userdeactivation process.

My code is as follows:
trigger UserIsFrozen on User (before update) {
    
    for(User U: Trigger.new) {
        User oldU = Trigger.oldMap.get(U.Id);
        
        
        if(oldU.IsActive = true) {
            List<UserLogin> ULog = [SELECT Id, IsFrozen from UserLogin where UserId = :U.Id];
            List<UserLogin> newids = new List<UserLogin>();
            
            for(Userlogin USLog : ULog) {
                if(USLog.IsFrozen = true) {
                    U.IsFrozen__c = true;
                    newids.add(USLog);
                }
            }    
            if(newids.isEmpty()== false) {
                update newids;
                update U;
            }
        }
    }
}

The trigger isn't working right now. What am I doing wrong?
Hello all!

I have the following sets of code intended to display any upcoming meetings directly on a contact's page:

Apex Class
public with sharing class UpcomingMeetings {
    public List<Event> events { get; private set; }
    public List<Event> evt {get; private set;}    
    public String StartDateVF1 {get; private set; }
    public String StartDateVF2 {get; private set; }
    public String summary { get; private set; }
    public String riaAdvisor { get; private set; }
    
     
    public UpcomingMeetings(ApexPages.StandardController controller) {
        Id contactId = controller.getRecord().Id;   
       system.debug('Contact id ---'+ contactId);
 
       Contact c = [SELECT id,Is_RIA_Advisor__c,RIA_Wholesaler_Name__c from Contact where Id=:contactId];
        
       riaAdvisor='';
       if (c.Is_RIA_Advisor__c)
        {
          riaAdvisor = 'This is a RIA contact. Please direct all calls to '+c.RIA_Wholesaler_Name__c+'<br/>';
        }      
        

       
        events = new List<Event>();
        try {
            
            Set<Id> eventIds = new Set<Id>();
            for (EventRelation e : [SELECT EventId FROM EventRelation  WHERE RelationId =:contactId AND Status NOT IN ('Declined','Uninvited')]) {
               eventIds.add(e.EventId);
            }
               events = [SELECT Id, Subject, StartDateTime, StartDateUTC__c, EndDateTime, IsAllDayEvent FROM Event WHERE (WhoId=:contactId OR Id IN :eventIds) AND Event.Cancelled__c <> TRUE AND ActivityDate>=TODAY ORDER BY ActivityDate ASC];             
            
            for(Event evt : events) {
                DateTime dt = DateTime.now();
                
                String StartDateVF1 = dt.format('MM/DD/YYYY');
                String StartDateVF2 = dt.format('MM/DD/YYYY HH:MM');
                if(evt.IsAllDayEvent == true) {
                    StartDateVF1 = evt.StartDateUTC__c;
                } else {
                    StartDateVF2 = evt.StartDateUTC__c;
                }
           }
VisualForce page:
<apex:page standardController="Contact" extensions="UpcomingMeetings" sidebar="false" showHeader="false">
    <style type="text/css">
    .meetingToday {
//        font-weight:bold;
        font-style:italic
    }
    </style>

    <apex:pageMessage severity="INFO" strength="1" summary="{!summary}" escape="false">
        <apex:dataTable value="{!events}" var="e" width="100%" cellpadding="1" cellspacing="1" rows="3">
            <apex:column >
                <li/>
            </apex:column>
            <apex:column >
                <apex:outputLink value="/{!e.Id}" target="_blank" styleClass="{!IF(DATEVALUE(e.StartDateTime)<TODAY(),'meetingToday','')}"><apex:outputField value="{!e.Subject}"/></apex:outputLink>
            </apex:column>
            <apex:column styleClass="{!IF(DATEVALUE(e.StartDateTime)<TODAY(),'meetingToday','')}">
                <apex:outputText value="from"/>
            </apex:column>
            <apex:column styleClass="{!IF(DATEVALUE(e.StartDateTime)<TODAY(),'meetingToday','')}">
                <apex:outputText value="{!IF(e.IsAllDayEvent == true, StartDateVF1, StartDateVF2)}"/>
            </apex:column>

The error message I'm getting is "Unknown Property 'ContactStandardController.StartDateVF1".

I know this means I haven't assigned the StartDateVF1 and StartDateVF2 variables to the contact relationship yet, but I'm not sure how to do this. Would anyone be able to help me?
Hello all,

my code is below:
 
events = new List<Event>();
      try {
           Set<Id> eventIds = new Set<Id>();
          for (EventRelation e : [SELECT EventId FROM EventRelation  WHERE RelationId =:contactId AND Status NOT IN ('Declined','Uninvited')]) {
              eventIds.add(e.EventId);
          }
          events = [SELECT Id, Subject, StartDateTime, StartDateUTC__c, EndDateTime, IsAllDayEvent 
          FROM Event WHERE (WhoId=:contactId OR Id IN :eventIds) AND Event.Cancelled__c <> TRUE AND ActivityDate>=TODAY ORDER BY ActivityDate ASC];
I want to create a String within the class which appends the appopriate date value based on the boolean "IsAllDayEvent" field.
When I try a "For" statement or an "If" statement, it won't let me perform the following:

String StartDateVF;
IF(events.IsAllDayEvent == true) {
StartDateVF = StartDateUTC__c
} else {
StartDateVF = StartDateTime;
}

The error that I'm getting is because the List "Events" can't grab the field "IsAllDayEvent" for some reason, even though a SOQL query has been run on the events list. I'm not sure why the list created in the first section of code won't let me grab the "IsAllDayEvent" field. Do I need to set this part up differently?
Hi all,

I'm looking to create a simple SOQL query which brings back all accounts based on whether or not the owner's record isfrozen.

I've been trying variations of the following SOQL: Select name from ACCOUNT where Account__r.owner in (select isfrozen from userlogin where isFrozen = true) 

So far I have had no luck. Would anyone be able to help me? I am relatively new to SOQL and would appreciate any help I can get :-)
My query is as follows:

query = 'SELECT Id' + getEditableFields(Schema.SObjectType.Order_Item__c.fields.getMap().values()) + ' FROM Order_Item__c WHERE Order__c=\'' + controller.getRecord().Id + '\'';
            List<Order_Item__c> lineItems = new List<Order_Item__c>();
            
            for (Order_Item__c li : Database.query(query)) {
                Order_Item__c liClone = new Order_Item__c(
                    Order__c = order.Id
                );
                If (li.Fulfillment_Status__c == 'Active' || li.In_Stock__c == 'Yes') {
                OrderItemNotification = 'One or more items from this order has been removed because it is either: 1. Out of Stock or 2. Inactive. Please make sure your order has all items necessary prior to submitting to fulfillment';
                DeliverErrorMessage = true;
                Order_Item__c removed = liClone.remove(removed);
                }

The error I'm getting is "Variable does not exist: removed" on the "Order_Item__c removed" line.

What I am trying to do is remove any items that meet either of the If statement conditions. Then I'll assign the OrderItemNotification to the updated order via visualforce.

Any help would be appreciated. Thanks!
My query is as follows:

query = 'SELECT Id' + getEditableFields(Schema.SObjectType.Order_Item__c.fields.getMap().values()) + ' FROM Order_Item__c WHERE Order__c=\'' + controller.getRecord().Id + '\'';
            List<Order_Item__c> lineItems = new List<Order_Item__c>();
            
            for (Order_Item__c li : Database.query(query)) {
                Order_Item__c liClone = new Order_Item__c(
                    Order__c = order.Id
                );
                If (li.Fulfillment_Status__c == 'Active' || li.In_Stock__c == 'Yes') {
                OrderItemNotification = 'One or more items from this order has been removed because it is either: 1. Out of Stock or 2. Inactive. Please make sure your order has all items necessary prior to submitting to fulfillment';
                DeliverErrorMessage = true;
                Order_Item__c removed = liClone.remove(removed);
                }

The error I'm getting is "Variable does not exist: removed" on the "Order_Item__c removed" line.

What I am trying to do is remove any items that meet either of the If statement conditions.
Hello all!

Novice question here: Trying to write a SOQL query which will compare the OwnerId of the Contact to the OwnerId of the Lookup Relationship Object and return only records where OwnerIds on both objects don't match.

The two objects are: 
1. Contacts (Main Object)
2. Lookup Relationship: Sub Zones (Zone__c) 

The Contacts object contains a field with a lookup relationship to the Sub Zones Object (Zone__c)

Both the Contact and the Sub Zone have an owner. We assign Sub Zones if the owners are both are identical.

How would I write a SOQL Query to find the records where they do not match?
Hello all!

I'm trying to create a trigger that updates a custom "IsFrozen" field when a user's record is frozen.

The User object field, IsFrozen__c is supposed to see if the UserLogin object's IsFrozen field is updated to a value of true, and if so, update the user's record to true. I think this will greatly help us with the userdeactivation process.

My code is as follows:
trigger UserIsFrozen on User (before update) {
    
    for(User U: Trigger.new) {
        User oldU = Trigger.oldMap.get(U.Id);
        
        
        if(oldU.IsActive = true) {
            List<UserLogin> ULog = [SELECT Id, IsFrozen from UserLogin where UserId = :U.Id];
            List<UserLogin> newids = new List<UserLogin>();
            
            for(Userlogin USLog : ULog) {
                if(USLog.IsFrozen = true) {
                    U.IsFrozen__c = true;
                    newids.add(USLog);
                }
            }    
            if(newids.isEmpty()== false) {
                update newids;
                update U;
            }
        }
    }
}

The trigger isn't working right now. What am I doing wrong?
Hello all!

I have the following sets of code intended to display any upcoming meetings directly on a contact's page:

Apex Class
public with sharing class UpcomingMeetings {
    public List<Event> events { get; private set; }
    public List<Event> evt {get; private set;}    
    public String StartDateVF1 {get; private set; }
    public String StartDateVF2 {get; private set; }
    public String summary { get; private set; }
    public String riaAdvisor { get; private set; }
    
     
    public UpcomingMeetings(ApexPages.StandardController controller) {
        Id contactId = controller.getRecord().Id;   
       system.debug('Contact id ---'+ contactId);
 
       Contact c = [SELECT id,Is_RIA_Advisor__c,RIA_Wholesaler_Name__c from Contact where Id=:contactId];
        
       riaAdvisor='';
       if (c.Is_RIA_Advisor__c)
        {
          riaAdvisor = 'This is a RIA contact. Please direct all calls to '+c.RIA_Wholesaler_Name__c+'<br/>';
        }      
        

       
        events = new List<Event>();
        try {
            
            Set<Id> eventIds = new Set<Id>();
            for (EventRelation e : [SELECT EventId FROM EventRelation  WHERE RelationId =:contactId AND Status NOT IN ('Declined','Uninvited')]) {
               eventIds.add(e.EventId);
            }
               events = [SELECT Id, Subject, StartDateTime, StartDateUTC__c, EndDateTime, IsAllDayEvent FROM Event WHERE (WhoId=:contactId OR Id IN :eventIds) AND Event.Cancelled__c <> TRUE AND ActivityDate>=TODAY ORDER BY ActivityDate ASC];             
            
            for(Event evt : events) {
                DateTime dt = DateTime.now();
                
                String StartDateVF1 = dt.format('MM/DD/YYYY');
                String StartDateVF2 = dt.format('MM/DD/YYYY HH:MM');
                if(evt.IsAllDayEvent == true) {
                    StartDateVF1 = evt.StartDateUTC__c;
                } else {
                    StartDateVF2 = evt.StartDateUTC__c;
                }
           }
VisualForce page:
<apex:page standardController="Contact" extensions="UpcomingMeetings" sidebar="false" showHeader="false">
    <style type="text/css">
    .meetingToday {
//        font-weight:bold;
        font-style:italic
    }
    </style>

    <apex:pageMessage severity="INFO" strength="1" summary="{!summary}" escape="false">
        <apex:dataTable value="{!events}" var="e" width="100%" cellpadding="1" cellspacing="1" rows="3">
            <apex:column >
                <li/>
            </apex:column>
            <apex:column >
                <apex:outputLink value="/{!e.Id}" target="_blank" styleClass="{!IF(DATEVALUE(e.StartDateTime)<TODAY(),'meetingToday','')}"><apex:outputField value="{!e.Subject}"/></apex:outputLink>
            </apex:column>
            <apex:column styleClass="{!IF(DATEVALUE(e.StartDateTime)<TODAY(),'meetingToday','')}">
                <apex:outputText value="from"/>
            </apex:column>
            <apex:column styleClass="{!IF(DATEVALUE(e.StartDateTime)<TODAY(),'meetingToday','')}">
                <apex:outputText value="{!IF(e.IsAllDayEvent == true, StartDateVF1, StartDateVF2)}"/>
            </apex:column>

The error message I'm getting is "Unknown Property 'ContactStandardController.StartDateVF1".

I know this means I haven't assigned the StartDateVF1 and StartDateVF2 variables to the contact relationship yet, but I'm not sure how to do this. Would anyone be able to help me?
Hello all,

my code is below:
 
events = new List<Event>();
      try {
           Set<Id> eventIds = new Set<Id>();
          for (EventRelation e : [SELECT EventId FROM EventRelation  WHERE RelationId =:contactId AND Status NOT IN ('Declined','Uninvited')]) {
              eventIds.add(e.EventId);
          }
          events = [SELECT Id, Subject, StartDateTime, StartDateUTC__c, EndDateTime, IsAllDayEvent 
          FROM Event WHERE (WhoId=:contactId OR Id IN :eventIds) AND Event.Cancelled__c <> TRUE AND ActivityDate>=TODAY ORDER BY ActivityDate ASC];
I want to create a String within the class which appends the appopriate date value based on the boolean "IsAllDayEvent" field.
When I try a "For" statement or an "If" statement, it won't let me perform the following:

String StartDateVF;
IF(events.IsAllDayEvent == true) {
StartDateVF = StartDateUTC__c
} else {
StartDateVF = StartDateTime;
}

The error that I'm getting is because the List "Events" can't grab the field "IsAllDayEvent" for some reason, even though a SOQL query has been run on the events list. I'm not sure why the list created in the first section of code won't let me grab the "IsAllDayEvent" field. Do I need to set this part up differently?
Hi all,

I'm looking to create a simple SOQL query which brings back all accounts based on whether or not the owner's record isfrozen.

I've been trying variations of the following SOQL: Select name from ACCOUNT where Account__r.owner in (select isfrozen from userlogin where isFrozen = true) 

So far I have had no luck. Would anyone be able to help me? I am relatively new to SOQL and would appreciate any help I can get :-)
Hello all!

Novice question here: Trying to write a SOQL query which will compare the OwnerId of the Contact to the OwnerId of the Lookup Relationship Object and return only records where OwnerIds on both objects don't match.

The two objects are: 
1. Contacts (Main Object)
2. Lookup Relationship: Sub Zones (Zone__c) 

The Contacts object contains a field with a lookup relationship to the Sub Zones Object (Zone__c)

Both the Contact and the Sub Zone have an owner. We assign Sub Zones if the owners are both are identical.

How would I write a SOQL Query to find the records where they do not match?