• Sanjay.George
  • NEWBIE
  • 80 Points
  • Member since 2015

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 23
    Replies
Is there a way to create a new child record for each selection in a multi-select picklist?
Hi All,
I have a question regarding the trigger below. I would like to update the price of a new order when created, ideally from a relationship field.
In the below code, first,  I tried to set the price to 10. If I use the below code, I don't receive an error, however when creating a new order, the price is filled with zero.
However if I don't use the below SOQL query, just write the "for" cycle for the "neworder" list, then it fills the price as expected.
I would like to use the relationship price, though, for which I suspect I need the SOQL query.
Could someone help how to achieve this?

Thanks,
Csaba


trigger setPrice on Order__c (before insert) {
       Order__c[] neworder = Trigger.new;
       for (Order__c ord :[SELECT Order__c.Name, Order__c.Unit_Price__c, Order__c.Product_Name__r.Name ,    Order__c.Product_Name__r.Unit_Price__c
                           FROM Order__c
                           WHERE Order__c.Id IN :neworder]) {

           ord.Unit_Price__c = 10;
                        
       }
    }

 
Hi Expert,

In my trigger below, new Account is created when trigger happens on Appointment__c object:
if(Trigger.isInsert){
            for(Appointment__c newRec : Trigger.new) {
                    Account converted = new Account(
                    LastName =  UserInfo.getLastName(),
                    FirstName = UserInfo.getFirstName(),
                    ABN_ACN__c = newRec.ABN__c,
                    Entity_Name__c = newRec.Legal_Entity_Name__c,
                    Trading_Name__c = newRec.Business_Trading_Name__c,
                    Owners__c = newRec.Owner_s__c,
           
                    );
                System.debug('long converted.Name' + converted.Name);
                newRec.Legal_Entity_Name__c = converted.Name;
                lstAccounts.add(converted);
            }
            upsert lstAccounts;
    }
This problem is that converted.Name is Null. As i know, when First Name and Last name are populated for an Account then Account.Name should be populated also. Pls show me the way to fix this issue?

 
I have been tasked with trying to figure out how to link a case (Created via API) to an already existing Opportunity.

I tried via web-to-case, creates new case but does not fill out lookup field. (Found that this will not auto populate Lookup Field) so had to ditch that attempt.

Now I have the Opportunity ID being saved in a hidden field on the case, then I tried a WFR. Which again is not going to do this for me, so I am stuck with writting a trigger (I think this is my only option) where it will take the ID from the Hidden Field and push it into the lookup (Lookups work on ID's if I am not mistaken)

My issue is, I am not super good at the whole trigger writing as I am just getting into more of the dev side now.

I have this as my trigger so far and was wondering if someone would be able to suggest or point out what I am doing wrong.

trigger OpportunityLookupSet on Case (before insert) {
    for(Case c : Trigger.new){
        if(c.Origin = 'ICE Cloud'&& c.MVDev__Opportunity_ID__c != null)}{
           c.MVDev__Opportunity_ID__c = c.MVDev__Linked_Opportunity__c;
        }
    }

}

WIth this one I get an error saying "AND operator can only be applied to Boolean expressions"  However I need to make sure that the origin is ICE Cloud (Hardcoded) and the Opportunity_ID__c is not blank.

Any help would be great.

Thanks in advance.

Mark
Is there a way to create a new child record for each selection in a multi-select picklist?
Hi Guys,

I want to fetch out picklist field values on visualforce page. These picklist values are already defined at object level. So for ex: I have an object called custom__c and field over it is permission__c(Picklist field) with values [Read;Write;No Access].
Now without using controller, can I print these 3 values on visualforce page?

Thanks!
Hi folks, 

I have a quick request. How would I go about chaning a record type of a child object depending on what the value of a picklist field on a parent object. 

This should be done by Visualforce page because I'm trying to overwrite the New button on the child object. So that users won't have to sleect the record type. 

Please help, this is a little urgent. 
I keep on getting this error when trying to upload: Description Resource Path Location Type System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, npsp.TDTM_Contact: execution of BeforeInsert caused by: System.AssertException: Assertion Failed: Expected: null, Actual: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [First_Name__c, Last_Name__c, Street_Address__c, City__c, Zip__c]: [First_Name__c, Last_Name__c, Street_Address__c, City__c, Zip__c] (npsp) : [] MyProfilePageControllerTest.cls /MySFTest/src/classes line 34 Force.com run test failure

Does anyone have a work around?
I have a local system which is integrated to salesforce. I am passing the user name & pw through the URL for the users to get in to login to salesforce directly. But, I want them to directly access a Case# in salesforce, how can I pass teh case# through auto login/SSo?
I am trying to get some related contact information from a SOQL query but have run into the error "SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object."

Here is my relationships; Activity_List__c <-- Activity_List_Contacts__c --> Contact (Junction Object)

Activities can have Sub Activities (Only one Level) Multiple contacts can be assigned to each activity.

Here is my sample SOQL query :

select id, Name, (select id, Name, (SELECT Id, Contact_Name__r.FirstName, Contact_Name__r.LastName FROM Activity_List_Contacts__r) from Activity_Lists__r limit 50000), (SELECT Id, Contact_Name__r.FirstName, Contact_Name__r.LastName FROM Activity_List_Contacts__r) from Activity_List__c where Campaign__c ='701M0000000O7Ic' limit 50000

I know I need to use a map from reading the boards but am not sure how / what I need to do to accomplish it.

Thanks Colsie
Hi all,

Where can i find the AJAX Toolkit in salesforce.
Whether i have to download form external source or else its already available tool in salesforce

Thanks
Hi All,
I have a question regarding the trigger below. I would like to update the price of a new order when created, ideally from a relationship field.
In the below code, first,  I tried to set the price to 10. If I use the below code, I don't receive an error, however when creating a new order, the price is filled with zero.
However if I don't use the below SOQL query, just write the "for" cycle for the "neworder" list, then it fills the price as expected.
I would like to use the relationship price, though, for which I suspect I need the SOQL query.
Could someone help how to achieve this?

Thanks,
Csaba


trigger setPrice on Order__c (before insert) {
       Order__c[] neworder = Trigger.new;
       for (Order__c ord :[SELECT Order__c.Name, Order__c.Unit_Price__c, Order__c.Product_Name__r.Name ,    Order__c.Product_Name__r.Unit_Price__c
                           FROM Order__c
                           WHERE Order__c.Id IN :neworder]) {

           ord.Unit_Price__c = 10;
                        
       }
    }

 
Global Class WL_ValidationProcess1Batch implements Database.Batchable<SObject>{
    String usrId = 'xxxxxxxxxxxxxxxxxx';
    global final String Query = 'select id, Account__c, Contract__c, Contract_Area__c, Customer_Type__c, StartDate__c from WL_CustomerJourney__c ' +
                                        'where Status__c =\''+System.Label.WL_Picklist_Active +'\'' + ' and OwnerId !=\''+ System.Label.WL_WorkingLinkQueue +'\'' +
                                         'and CreatedByid =\''+usrId+'\'';
       
    /*global WL_ValidationProcess2Batch(String strQuery){
        Query = strQuery;
    }*/
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        system.debug('==============='+Query);
        return Database.getQueryLocator(Query);
    }

    global void execute(Database.BatchableContext BC, List<WL_CustomerJourney__c> scope){
        Set<Id> custIds = (new Map<Id, WL_CustomerJourney__c>(scope)).keySet();
        List<WL_SubContractorPayment__c> insertSubContractorPayemnt = new List<WL_SubContractorPayment__c>();
        Map<id, WL_CustomerAchievement__c> mapCustAhievement = new Map<id, WL_CustomerAchievement__c>();
        List<WL_Validation__c> lstUpdateValidation =  new List<WL_Validation__c>();
        List<WL_Validation__c> lstValidations = [select Customer_Journey__c, Job_ID__c, Customer__c, Customer_Qualification__c,
                                                 Job_ID__r.Organisation__c, Job_ID__r.EmploymentStartDate__c,Customer_Journey__r.StartDate__c,
                                                 Customer_Journey__r.Completer_date__c,Customer_Journey_Start_date__c, Customer_Qualification__r.Qualification__c,
                                                 Customer_Qualification__r.Validated__c, Customer_Qualification__r.Qualification__r.Qualification__c
                                                 from  WL_Validation__c where Validation_Candidate__c=false and
                                                 Customer_Journey__c !=: null and Customer_Journey__c in: custIds];
                                                 
        List<WL_Milestone__c> lstMilestones = new List<WL_Milestone__c>([select id, Name, Milestone_Type__c, Validation_Required__c,                        
                                                        Contract__c, Funder_Milestone__c, Sub_contractor_Milestone__c from WL_Milestone__c]);                                        
        
        Map<String, WL_Milestone__c> mapMilestones = new Map<String, WL_Milestone__c> ();

        for(WL_Milestone__c milestone : lstMilestones){
            mapMilestones.put(milestone.Name, milestone);
        }       
        System.debug('****List Validations='+lstValidations);
        
        Set<Id> accIds = new Set<Id>();
        
        for(WL_CustomerJourney__c custJourney : scope){
            for(WL_Validation__c validation : lstValidations){
                if(validation.Job_ID__r.Organisation__c != null)
                    accIds.add(validation.Job_ID__r.Organisation__c);       
            }
        }
        
        // get contact based on account
        Set<Contact> setContact = new Set<Contact>();
        setContact.addAll((new Map<Id, Contact>([select id, AccountId from contact where AccountId in : accIds])).Values());
        Map<Id, Integer> mapContactCount = new Map<Id, Integer>();
        
        // get contac count for each account
        for(Id accId : accIds){
            Integer count = 0;
            for(Contact contact : setContact){
                if(accId == contact.AccountId)
                    count += 1;
            }
            mapContactCount.put(accId, count);
        }
           
        for(WL_Validation__c validation : lstValidations){
            //  is attachment milestone achieved
            system.debug('===============27'+validation);
            if(WL_MilestonesUtils.isAttachementMilestone(validation)){
                System.debug('===inside if****'+validation);
                WL_MilestonesUtils.processValidations(validation, true, lstUpdateValidation, insertSubContractorPayemnt, 
                mapCustAhievement, mapMilestones.get(System.Label.WL_milestone_Attachment), null, null, null);
            }
            //  is Qualification milestone achieved
            if(WL_MilestonesUtils.isQualificationMilestone(validation)){
                WL_MilestonesUtils.processValidations(validation, true, lstUpdateValidation, insertSubContractorPayemnt, 
                mapCustAhievement, mapMilestones.get(System.Label.WL_milestone_Qualification), null, null, null);
            }
            //  is Sub-Contractor milestone achieved
            if(WL_MilestonesUtils.isSubContractorMilestone(validation, mapContactCount)){
                WL_MilestonesUtils.processValidations(validation, true, lstUpdateValidation, insertSubContractorPayemnt, 
                mapCustAhievement, mapMilestones.get(System.Label.WL_milestone_SubContractor), null, null, null);
            }
            // get the no of days for customer to worked for a organization
            if(WL_MilestonesUtils.isValidJob(validation, mapContactCount)){
                WL_MilestonesUtils.processValidations(validation, true, lstUpdateValidation, insertSubContractorPayemnt, 
                mapCustAhievement, mapMilestones.get(System.Label.WL_milestone_13WeeksInJob), null, null, null);
            }
        }
        
        // set validation candidate flag to true on Validation object records from First batch execution.
        //update Customer achievement ID from newly created customer achievement on Validation object records from Second batch execution.
        if(lstUpdateValidation.size() >=1) {
            System.debug('===============27'+lstValidations);
            Set<WL_Validation__c> validationSet = new Set<WL_Validation__c>();
            List<WL_Validation__c> validationList=new List<WL_Validation__c>();
            validationSet.addAll(lstUpdateValidation);
            validationList.addAll(validationSet);
            update validationList;
        }    
    }
    //finish method of batch
    global void finish(Database.BatchableContext bc){
    // write logic which required after completing batch
    }   
}
I create a form in visualforce page and create force.com website. At force.com submit button is showing but input filed not showing. please provide me solution
I work at a non-profit camp for people with disabilities and during the camp season I have to match up campers with counselors 1 on 1. I have to constantly switch people around and can be very stressful. I'm looking for a way to build an app that allows me to have a vertical list of all the counselors in a coulmn and next to that have a list of all the campers with the ability to drag-and-drop the campers up and down to matchup with other counselors. Also if its posible to have the ability to have 2 campers matched up to 1 counselor, and finally if we can export the final product as a .CSV

Hii, I have a page and class.I have the field location of geolocation type.I want to show the location on GMAP when i search for a particular thing.Like when i select 'India', i am getting the records of having address in India But not getting their location on GMAP. My code is: 
Page:
 <apex:page controller="tourmapController1" tabStyle="Accomodation__c" action="{!find}" id="page">  
  <head>      
  <style>       
      div #map_canvas { height: 400px; }      
  </style>     
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"></script>  
  </head>   
  <apex:sectionHeader title="Hello StackOverflow!" subtitle="Accomodation full text search + Google Maps integration" />  
  <apex:pageMessages /> 
    <apex:form id="form">       
  <apex:pageBlock id="searchBlock">       
      <apex:inputText value="{!searchText}" />    
        <apex:commandButton value="Search" action="{!find}"/>    
        <p>Examples: <a href="/apex/{!$CurrentPage.Name}?q=USA">"USA"</a>, "Singapore", "Uni", "(336) 222-7000". If it works in the global search box, it will work here.</p>    
    </apex:pageBlock>     
    <apex:pageBlock title="Found {!accod.size} Accomodation__c..." rendered="{!NOT(ISNULL(accod)) && accod.size > 0}" id="resultsBlock">             <apex:pageBlockButtons location="top">    
            <apex:commandButton value="Clear cached locations" title="Click if you want to set 'null' as geolocation info for all these accomodations" action="{!clearGeocodedData}" />   
          </apex:pageBlockButtons>        
    <apex:pageBlockTable value="{!accod}" var="a" id="accod">    
            <apex:column headerValue="{!$ObjectType.Accomodation__c.fields.Name.label}">         
            <apex:outputLink value="../{!a.Id}">{!a.Name}</apex:outputLink>    
            </apex:column>                 
<apex:column headerValue="Address">           
          {!a.Street_Address__c} {!a.City__c} {!a.Country__c}      
          </apex:column>               
  <apex:column value="{!a.Accomodation_Name__c}"/>             
    <apex:column headerValue="Location (retrieved from DB or geocoded server-side)">       
              {!a.Location__Latitude__s}, {!a.Location__Longitude__s}           
      </apex:column>            
</apex:pageBlockTable>           
  <apex:pageBlockSection columns="1" id="mapSection">       
          <div id="map_canvas" />         
    </apex:pageBlockSection>            
<apex:pageBlockSection title="Click to show/hide what was geocoded server-side and passed to JS for further manipulation" columns="1" id="debugSection">       
         1 {!debugAccomodationJson}        
    </apex:pageBlockSection>            1      
    </apex:pageBlock>   
  </apex:form>    
<script type="text/javascript">   
  twistSection(document.getElementById('page:form:resultsBlock:debugSection').childNodes[0].childNodes[0]); // initially hide the debug section     var accod = {!accodJson};  
      var coords = [];                
    var requestCounter = 0;    
var markers = [];                  // Red things we pin to the map.  
  var balloon = new google.maps.InfoWindow();   
  function geocodeClientSide() {    
    for(var i = 0; i < accod.length; i++) {       
      if(accod[i].Location__Latitude__s != null && accod[i].Location__Longitude__s != null) {     
            coords.push(new google.maps.LatLng(accod[i].Location__Latitude__s, accod[i].Location__Longitude__s));      
      } 
else {             
    ++requestCounter;              
  var address = accod[i].Street_Address__c + ' ' + accod[i].City__c + ' ' + accod[i].Country__c;    
            var geocoder = new google.maps.Geocoder();    
            if (geocoder) {        
            geocoder.geocode({'address':address},
function (results, status) {        
                if (status == google.maps.GeocoderStatus.OK) {         
                    coords.push(results[0].geometry.location);            
            } 
else {                          
  var pTag = document.createElement("p");           
                  pTag.innerHTML = status;            
                document.getElementById('log').appendChild(pTag);       
                  }                      
  if(--requestCounter == 0) {                     
        drawMap();                
        }              
      });            
    }       
      }    
    }            
    if(requestCounter == 0) {      
      drawMap();     
    }   
  }    
function drawMap(){  
      var mapOptions = {        center: coords[0],            zoom: 3,             mapTypeId: google.maps.MapTypeId.ROADMAP         };   
     var map = new google.maps.Map(document.getElementById("map_canvas"),  mapOptions);   
      for(var i = 0; i < coords.length; ++i){      
      var marker = new google.maps.Marker({map: map, position: coords[i], title:accod[i].Name, zIndex:i});    
        google.maps.event.addListener(marker, 'click', function() {            
    var index = this.zIndex;               
  balloon.content = '<b>'+accod[index].Name + '</b><br/>' + accod[index].Accomodation_Name__c + '<br/>' + accod[index].City__c;                 balloon.open(map,this);    
        });      
      markers.push(marker);    
    }   
  }   
  geocodeClientSide();   
  </script> 
</apex:page> 


Class: 
public with sharing class tourmapController1 {  
  public String accodJson { get; set; }  
public String searchText {get;set;}
public List<Accomodation__c> accod{get; private set;}
public static final String GEOCODING_URI_BASE = 'https://maps.googleapis.com/maps/api/geocode/json?sensor=true&address='; 
public static final Integer MAX_CALLOUTS_FROM_APEX = 3; // Limits.getLimitCallouts() 
public tourmapController1(){     
searchText = ApexPages.currentPage().getParameters().get('q'); 

public void find() {   
  if(searchText != null && searchText.length() > 1){     
    List<List<SObject>> results = [FIND :('*' + searchText + '*') IN ALL FIELDS RETURNING              Accomodation__c (Id, Name,Accomodation_Name__c,                 Street_Address__c,City__c,PostalCode__c, State__c, Country__c,                  Location__Latitude__s, Location__Longitude__s)             ];   
      accod = (List<Accomodation__c>)results[0];    
    if(accod.isEmpty()){       
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'No matches for "' + searchText + '"'));   
      } 
else {       
      serverSideGeocode();      
  }   
  } 
else {   
      if(accod != null) {       
      accod.clear();     
    }        
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Please provide at least 2 characters for the search.'));  
  } } 
public void clearGeocodedData(){ 
    for(Accomodation__c a : accod){     
    a.Location__Latitude__s = a.Location__Longitude__s = null;  
  }    
Database.update(accod, false);     
accod.clear(); 

public String getAccomodationJson(){  
  return JSON.serialize(accod);

public String getDebugAccomodationJson(){ 
    return JSON.serializePretty(accod); 

private void serverSideGeocode(){  
  List<Accomodation__c> accodToUpdate = new List<Accomodation__c>();   
  Http h = new Http();  
    HttpRequest req = new HttpRequest(); 
    req.setMethod('GET');    
  req.setTimeout(10000);  
  for(Accomodation__c a : accod){  
      if((a.Location__Latitude__s == null || a.Location__Longitude__s == null)){     
        String address = a.Street_Address__c != null ? a.Street_Address__c + ' ' : '' +                 a.City__c != null ? a.City__c + ' ' : '' +                 a.State__c != null ? a.State__c + ' ' : '' +                 a.PostalCode__c != null ? a.PostalCode__c + ' ' : '' +                 a.Country__c != null ? a.Country__c : '';    
        if(address != ''){        
        req.setEndpoint(GEOCODING_URI_BASE + EncodingUtil.urlEncode(address, 'UTF-8'));         
        try{      
              HttpResponse res = h.send(req);               
      GResponse gr = (GResponse) JSON.deserialize(res.getBody(), tourmapController1.GResponse.class);  
                  if(gr.status == 'OK'){       
                  LatLng ll = gr.results[0].geometry.location;            
            a.Location__Latitude__s = ll.lat;             
            a.Location__Longitude__s = ll.lng;       
                  accodToUpdate.add(a);          
          } 
else {            
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Geocoding of "' + address + '" failed:' + gr.status));  
                  }          
      }
catch(Exception e){       
              ApexPages.addMessages(e);      
          }      
      }                
          if(Limits.getCallouts() == MAX_CALLOUTS_FROM_APEX) {            
    break;         
    }     
    }   
  }   
  if(!accodToUpdate.isEmpty()) {  
      Database.update(accodToUpdate, false); // some data in Developer editions is invalid (on purpose I think).        

  } }
public class GResponse{   
  public String status; 
    public GComponents[] results;

public class GComponents{    
public String formatted_address;  
 public GGeometry geometry; 

public class GGeometry {   
  public LatLng location; 

public class LatLng{  
  public Double lat, lng;
}
​ }
Hi All,
I have a Visualforce Tab that is a jquery calendar pulling dates from different objects.
I would like to be able to make different views on this or filter in some way so that users can pick to only look at dates by owner or by department and so on. Much like creating list views.
Any help in adding this feature would me much appreciated

Visual Force Page
<apex:page controller="CalendarExample_Controller" action="{!pageLoad}">
    
    <apex:relatedList list="CalendarExample_Controller" />

    <link href="{!$Resource.fullCalendarCSS}" rel="stylesheet" />

    <link href="{!$Resource.fullCalendarPrintCSS}" rel="stylesheet" media="print" />
    
    <apex:includeScript value="{!$Resource.moment_min_js}"  />
    

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>

    <script src="{!$Resource.fullCalendarMinJS}"></script>

    

    <script>

        //We need to wrap everything in a doc.ready function so that the code fires after the DOM is loaded

        $(document).ready(function() {   

            //Call the fullCallendar method. You can replace the '#calendar' with the ID of the dom element where you want the calendar to go. 

            $('#calendar').fullCalendar({

                header: {

                    left: 'prev,next today',

                    center: 'title',

                    right: 'month,agendaWeek,agendaDay'

                },

                editable: false,

                events:

                [

                    //At run time, this APEX Repeat will reneder the array elements for the events array

                    <apex:repeat value="{!events}" var="e">

                        {

                            title: "{!e.title}",

                            start: '{!e.startString}',

                            end: '{!e.endString}',

                            url: '{!e.url}',

                            allDay: {!e.allDay},

                            className: '{!e.className}'

                        },

                    </apex:repeat>

                ]

            });

            

        });

    

    </script>

    

    <!--some styling. Modify this to fit your needs-->

    <style>

        #cal-options {float:left;}

        #cal-legend { float:right;}

        #cal-legend ul {margin:0;padding:0;list-style:none;}

        #cal-legend ul li {margin:0;padding:5px;float:left;}

        #cal-legend ul li span {display:block; height:16px; width:16px; margin-right:4px; float:left; border-radius:4px;}

        #calendar {margin-top:20px;}

        #calendar a:hover {color:#fff !important;}

        

        .fc-event-inner {padding:3px;}

        .event-birthday {background:#56458c;border-color:#56458c;}

        .event-campaign {background:#cc9933;border-color:#cc9933;}

        .event-personal {background:#1797c0;border-color:#1797c0;}
        
        .event-travel {background:#1797c0;border-color:#1797c0;}

    </style>

    

    <apex:sectionHeader title="My Calendar Example"/>

    <apex:outputPanel id="calPanel">

        <apex:form >

            <div id="cal-options">

                <apex:commandButton value="{!IF(includeMyEvents,'Hide My Events','Show My Events')}" action="{!toggleMyEvents}"/>

            </div>

            <div id="cal-legend">

                <ul>

                    <li><span class="event-birthday"></span>Contact's Birthdays</li>

                    <li><span class="event-campaign"></span>Campaigns</li>
                    
                    <li><span class="event-travel"></span>Travel</li>

                    <li style="{!IF(includeMyEvents,'','display:none')}"><span class="event-personal"></span>My Events</li>

                </ul>

                <div style="clear:both;"><!--fix floats--></div>

            </div>

            <div style="clear:both;"><!--fix floats--></div>

            <div id="calendar"></div>

        </apex:form>

    </apex:outputPanel>

</apex:page>
Apex Class
public class CalendarExample_Controller {



    public Boolean includeMyEvents {get;set;}

    public list<calEvent> events {get;set;}

    

    //The calendar plugin is expecting dates is a certain format. We can use this string to get it formated correctly

    String dtFormat = 'EEE, d MMM yyyy HH:mm:ss z';

    

    //constructor

    public CalendarExample_Controller() {

        //Default showing my events to on

        includeMyEvents = true;

    }

    

    public PageReference pageLoad() {

        events = new list<calEvent>();

        //Get Contact's Birthdays

        for(Contact cont : [select Id, Birthdate, FirstName, LastName from Contact where Birthdate != null]){

            //here we need to replace the birth year with the current year so that it will show up on this years calendar

            DateTime startDT = datetime.newInstance(Date.Today().Year(),cont.Birthdate.Month(), cont.Birthdate.Day());

            calEvent bday = new calEvent();

            

            bday.title = cont.FirstName + ' ' + cont.LastName + '\'s Birthday!';

            bday.allDay = true;

            bday.startString = startDT.format(dtFormat);

            //Because this is an all day event that only spans one day, we can leave the send date null

            bday.endString = '';

            bday.url = '/' + cont.Id;

            bday.className = 'event-birthday';

            events.add(bday);

        }

        

        //Get Campaigns

        for(Campaign camp : [select Id, Name, StartDate, EndDate from Campaign where IsActive = true]){

            DateTime startDT = camp.StartDate;

            DateTime endDT = camp.EndDate;

            calEvent campEvent = new calEvent();

            

            campEvent.title = camp.Name;

            campEvent.allDay = true;

            campEvent.startString = startDT.format(dtFormat);

            campEvent.endString = endDT.format(dtFormat);

            campEvent.url = '/' + camp.Id;

            campEvent.className = 'event-campaign';

            events.add(campEvent);

        }

        //Get Travel

        for(Travel__c trav : [select Id, Name, Departure_Date__c, Return_Date__c from Travel__c where Approval_Status__c = 'Approved']){

            DateTime startDT = Trav.Departure_Date__c;

            DateTime endDT = Trav.Return_Date__c;

            calEvent travEvent = new calEvent();

            

            travEvent.title = Trav.Name;

            travEvent.allDay = true;

            travEvent.startString = startDT.format(dtFormat);

            travEvent.endString = endDT.format(dtFormat);

            travEvent.url = '/' + Trav.Id;

            travEvent.className = 'event-travel';

            events.add(travEvent);

        }
        

        //Get my Events if we have selected the correct option

        if(includeMyEvents){

            for(Event evnt: [select Id, Subject, isAllDayEvent, StartDateTime, EndDateTime from Event where OwnerID = :UserInfo.getUserId()]){

                DateTime startDT = evnt.StartDateTime;

                DateTime endDT = evnt.EndDateTime;

                calEvent myEvent = new calEvent();

                

                myEvent.title = evnt.Subject;

                myEvent.allDay = evnt.isAllDayEvent;

                myEvent.startString = startDT.format(dtFormat);

                myEvent.endString = endDT.format(dtFormat);

                myEvent.url = '/' + evnt.Id;

                myEvent.className = 'event-personal';

                events.add(myEvent);

            }

        }

        return null;

    }

    

    public PageReference toggleMyEvents() {

        if(includeMyEvents){

            includeMyEvents = false;

        }

        else{

            includeMyEvents = true;

        }

        pageload();

        return null;

    }



    

    //Class to hold calendar event data

    public class calEvent{

        public String title {get;set;}

        public Boolean allDay {get;set;}

        public String startString {get;private set;}

        public String endString {get;private set;}

        public String url {get;set;}

        public String className {get;set;}

    }

}

Calendar
User-added image

Hello,

Our site's login page does not display properly/certificate issue.

here it is:  https://vehiport.secure.force.com/login

We haven't logged into force yet so where exactly is this page being generated from?

Should note, I purchased the site with SF already intergrated so there is a lot of unknowns.

Hi,

I have written a visualforce page and class for uploading attachement in Details__ c object.

Records are saving correctly in Details__c, but I wonder where the attechment goes.. Is there a specific path to view those attachements?

Help plz.


Thanks,

Hi Expert,

In my trigger below, new Account is created when trigger happens on Appointment__c object:
if(Trigger.isInsert){
            for(Appointment__c newRec : Trigger.new) {
                    Account converted = new Account(
                    LastName =  UserInfo.getLastName(),
                    FirstName = UserInfo.getFirstName(),
                    ABN_ACN__c = newRec.ABN__c,
                    Entity_Name__c = newRec.Legal_Entity_Name__c,
                    Trading_Name__c = newRec.Business_Trading_Name__c,
                    Owners__c = newRec.Owner_s__c,
           
                    );
                System.debug('long converted.Name' + converted.Name);
                newRec.Legal_Entity_Name__c = converted.Name;
                lstAccounts.add(converted);
            }
            upsert lstAccounts;
    }
This problem is that converted.Name is Null. As i know, when First Name and Last name are populated for an Account then Account.Name should be populated also. Pls show me the way to fix this issue?

 
I have List method in a controller class...and i am going to call this  Method  in Test class. But i am getting  Method does not exist or  Incorrect signature error ? can any one resolve this.

This is the method in Controller class :

 public List<Building_Owner__c> contactList {
        get {
            if (contactList == null) {
                contactList = [Select id,Name,Address_1__c,Address_2__c,City__c,Contractor_Branch_Location__c,Company_Company_Location12__c,Contractor_Company_Location__c,Country__c,Email_Address__c,First_Name__c,Last_Name__c,Phone_Number__c,Postal_Code__c,State__c,Time_Zone__c from Building_Owner__c];
            }
            return contactList;
        }
        set;
    }


Test Class :

LCBSBuildingOwnersController bc = new LCBSBuildingOwnersController();   // creating controller class
        bc.newBuildingOwner();
        bc.Order();
        bc.buidingCancel();
        bc.buidingSave();
        bc.getContractorCompanyLoc();   // this is the page reference method calling correct
         bc.contactlist();   // this is the List method (How to call this method)