• Mathew Andresen 5
  • SMARTIE
  • 648 Points
  • Member since 2014
  • Director of Finance and Business Systems
  • Terravant Wine Company

  • Chatter
    Feed
  • 8
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 64
    Questions
  • 171
    Replies
Hello,

When i create a account, i get a link to create contacts.

What are the steps for doing so , (If i am duplicating account and contacts)?

Do they have master detail or lookup relationship AND, Do where is this relationship created
I have a trigger in my org that I didn't write.  From my slight understanding of triggers, this doesn't look like it does anything.  Below is the entire trigger.  Can you tell me if this is just cluttering up my org?

1 trigger UpdateEQLineOnProjTask on AcctSeed__Project_Task__c (after update) {
2    
3 }
  • January 18, 2016
  • Like
  • 0
Hi, another newbie programmer here with a question about the following trigger. The intention is to get the Product Abbreviation of only the Product from the highest priced Opportunity Line Item into a field on Opportunity.

The trigger works to get the primary product abbreviation when there is one Opp Line Item, but it is unreliable about getting the highest priced OLI when there is more than one. Any thoughts/help would be very appreciated. Thank you.
 
trigger getProduct on Opportunity (before insert, before update) {
   public list<opportunity> Opps = trigger.new;
   public list<opportunityLineItem> Prods = new list<opportunityLineItem>([SELECT Id, TotalPrice, PricebookEntry.Product2Id, Product2.name,                                                                           PricebookEntry.Product2.Abbreviation__c, opportunityId 
                                            FROM opportunityLineItem WHERE opportunityId =: trigger.new[0].id ORDER BY TotalPrice LIMIT 1]);

  
  string productvar='';
  for(opportunityLineItem p : Prods) {

       productvar = p.PricebookEntry.Product2.Abbreviation__c;

  }

  for(Opportunity opp : trigger.new) {
     opp.Prim_Prod_Abbrev__c = productvar;

  }
}

 
I need to create what would essentially be a 15 column / 5 row table in a VisualForce page with individual fields and labels in the cells. Some of the rows would be headers, and some of the columns would be field labels. The individual fields within the cells would be input fields. 

What is the best way to approach this ? I'm looking into block tables (?) but most of the online documentation I'm finding is regarding tables which are being populated with lists produced by queries. I don't want lists. I only want fields to be in each of the cells, just like a spreadsheet. 

Thank you for any input.
  • November 12, 2015
  • Like
  • 0
I have a List Button on a Contact List View which I've set to execute Javascript. I am trying to update a custom field on the Account associated with the selected Contact when the button is pressed. Right now I can't get the Account ID which relates the selected Contact(s). I will post my Javascript code below.

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
// Get list of selected Contact IDs
var records = {!GETRECORDIDS($ObjectType.Contact)};

if (records[0] == null) {
   alert("Please select at least one record to update.");
}

// Loop through Contact IDs
for(var i=0; i < records.length; i++) {
   // Create Account object to update field on
   var account = new sforce.SObject("Account");
   account.id = records[i]; // won't work because Account.Id != Contact.Id

   // Update custom field value
   account.My_Custom_Field__c = "value";
   sforce.connection.update([account]);
}
window.location.reload();

As you can see, I have most of the code ready to use. The only problem is that the Contact's id does not match the Account id. Is it possbile I could get the Contact.AccountId field value and use it to set account.id?
Hi,

How can I add to return.page syntax the account id.
My code below doesn't work. 
 
public class Bestandsauswertung3_class {

private Id accId {get; set;}
public Bestandsauswertung3_class(ApexPages.StandardController stdcontroller) { 
    accId = stdcontroller.getRecord().Id;
}

public Decimal testValue { get; set; }

public PageReference nextPage () {    
        
        if(testValue == null) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Required value'));
            return null;
        }        
        
        testValue += 500;
        
        return Page.Bestandsauswertung3?id=accid;    
    }
Thanks,
Sascha
 
I have been able to get similar ones to work (based on prior challenges) but I am struggling here.  Probably a newbie mistake somewhere.  Any help would be appreciated!  Thanks, Aron

-> Page (Gives Error: Unknown property 'String.Id error)

<apex:page controller="NewCaseListController">
    <apex:form >
        <apex:pageBlock title="Case List" id="Case_list">
            <!-- Case_list -->
         <apex:repeat value="{!Case}" var="case">
            <apex:outputLink value="{!Case.Id}">{!Case.Id}</apex:outputLink>
            <apex:outputLink value="{!case.CaseNumber}">{!case.CaseNumber}</apex:outputLink>
        </apex:repeat>      
        </apex:pageBlock>
    </apex:form>
</apex:page>

-> Class

ublic class NewCaseListController {

    public String getCase() {
        return null;
    }


    public String getCases() {
        return null;
    }

private String sortOrder = 'CaseNumber';
public List<Case> getNewCases() {
    List<Case> results = Database.query(
        'SELECT Id, CaseNumber ' +
        'FROM Case ' +
        'WHERE Status = New ' +
        'ORDER BY ' + sortOrder + ' ASC ' +
    );
    return results;
    }
}
When an opportunity is updated, I have a trigger that checks the account and contact associated with that opportunity, and updates fields on the account and contact.  To get that data, I'm using SOQL, but this causes errors when someone tries to bulk-update records.

How can I check the data from the related objects without using SOQL inside my trigger?

Here is the code I'm currently using (not the full trigger, just the beginning to show the problem area:

Thanks!
trigger SetCustomerStatusAfterOpWin on Opportunity (after insert, after update) {

    List<Contact> ContactsToUpdateListOriginal = new List<Contact>();
    List<Account> AccountsToUpdateListOriginal = new List<Account>();        
    
    for( Opportunity o : Trigger.new)
    {
        //Get contact from Opportunity
        string contactId = o.Primary_Contact__c;
        //Contact contactToUpdate = new Contact(Id = contactId);
        Contact contactToUpdate = [SELECT Id, RM_ID_Status__c, RSM_ID_Status__c, RWC_ID_Status__c
                                   FROM Contact
                                   WHERE Id = :contactId limit 1];

        //Get contacts account id
        string accountId = o.AccountId;
        //Account accountToUpdate = new Account(Id = accountId);      
        Account accountToUpdate = [SELECT Id, RM_ID_Status__c, RSM_ID_Status__c, RWC_ID_Status__c
                                   FROM Account
                                   WHERE Id = :accountId limit 1];
        //Get Opportunity's Name eg. RM-60013
        string opName = o.Name;
        
        //Update contact based on company and op status.
        if((opName.contains('RM') || opName.contains('RAMP')))
        {
           if( o.StageName == 'Closed Won')
           {
               //update contact by id
                if(contactToUpdate.Id != null)
                {
                    contactToUpdate.RM_ID_Status__c = 'Customer';
                    ContactsToUpdateListOriginal.add(contactToUpdate);
                    //update contactToUpdate;
                }
                //Update Contact's account status
                if(accountToUpdate.Id != null)
                {
                    accountToUpdate.RM_ID_Status__c = 'Customer';
                    AccountsToUpdateListOriginal.add(accountToUpdate);
                    //update accountToUpdate;         
                }
           }
           else if( o.StageName == 'Quote Sent' || o.StageName == 'Closed Lost' || o.StageName == 'Sale Pending' || o.StageName == 'Updated Quote')
           {
               //update contact by id
                if(contactToUpdate.Id != null && contactToUpdate.RM_ID_Status__c != 'Customer')
                {
                    contactToUpdate.RM_ID_Status__c = 'Quoted';
                    ContactsToUpdateListOriginal.add(contactToUpdate);
                    //update contactToUpdate;
                }
                //Update Contact's account status
                if(accountToUpdate.Id != null && accountToUpdate.RM_ID_Status__c != 'Customer')
                {
                    accountToUpdate.RM_ID_Status__c = 'Quoted';
                    AccountsToUpdateListOriginal.add(accountToUpdate);
                    //update accountToUpdate;         
                }
           }
            
        }// end if

 
Hi,

I'm working on my first integration and have some questions on how to go about it properly.  

right now, I created my first callout which gets executed by the apex scheduler with an @future call.

But soon I will probably have 10-20 callouts.  Should I have a separate apex schedular class for each one? And schedule each one separetly, or should I have a master class that calls the rest of them, and schedule that one.  

thoughts?

 
Here’s a free lightning based Event calendar. Basically it builds an calendar based on the event object.  Once built it allows for sorting the calendar by department.  Also within the calendar it allows for creating and editing new events (with limited functionality, no changing owners in the calendar, or creating recurring events).
 
Anyway, feel free to use or share.


https://github.com/Kroneborge/Lightning-Calendar
 
 built a reporting calendar that displays events and allows you to filter by department etc. It also includes some additional event fields such as completed.
Then my users create recurring events for reports (say every Monday do event X) that they need to mark complete.
But when trying to mark the event complete through apex I get the following error
"You cannot reassign a recurring event occurrence"
Note going back and changing the recurring event won't work, because I want to change each event individually, even if it started as a recurrence.
Any ideas on how to do this besides creating my own apex method that creates recurring events?
 
@AuraEnabled
    public static List<Event> getEventList(Decimal month, Decimal year) {
        Integer workingMonth = (Integer)month;
        Integer workingYear = (Integer)year;
        system.debug('year ' + year);
        system.debug('currentMonth' + workingMonth);
        List<Event> eventList = [SELECT Subject, Id, StartDateTime, Department__c, Out_Of_Office__c, Status__c, Reporting_Calendar__c FROM Event 
                                 WHERE (CALENDAR_MONTH(StartDateTime) = :workingMonth AND CALENDAR_YEAR(StartDateTime) = :workingYear) AND Reporting_Calendar__c=true AND isRecurrence=false]; //
        system.debug(eventList);
        return eventList;
    }
    
    @AuraEnabled
    public static Event getNewEvent(Event newEvent) {
        String userId = UserInfo.getUserId();
        newEvent.OwnerId = userId;
        upsert newEvent;
        system.debug(newEvent);
        return newEvent;
    }

 
Hi,

Normally in Salesforce there is a lookup field for users you can click and find the user.  Is there an easy way to do this in lightning?

Thanks,
Hi,

I developed a customizable ligtning calendar component.  It queries event data and then puts the event subjects on the relevant days.  Everything works great, except I can't get my calendar days to align properly.  The days with data in them don't align with the days that don't. I put all code here in case anyone else wants a working lightning calendar

Any ideas?  
 
<!-- Calendar.cmp  -->
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" controller="CalendarEvent_CLASS">
    <aura:attribute name="daysOfWeek" type="String[]"/>
    <aura:attribute name="week1" type="String"/>
    <aura:attribute name="month" type="String"/>
    <aura:attribute name="currentMonth" type="Date"/>
    <aura:attribute name="pickList" type="String[]"/>
    <aura:attribute name="selectedDept" type="String" default="Any"/>
    <aura:attribute name="selectedUser" type="String" default="Any"/>
    <aura:attribute name="eventList" type="Event[]"/>
 
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
 
    <div class="slds-grid slds-page-header"   role="banner">  <!-- banner  -->
        
        
        <div class=" slds-size--1-of-12 slds-align--absolute-center"   > <lightning:buttonIcon name="back" alternativeText="Back" iconName="utility:chevronleft" onclick="{!c.lastMonth}"/> </div>
   	    <div class=" slds-size--9-of-12 slds-align--absolute-center"> <b>{!v.month} </b></div>
        <div class=" slds-size--1-of-12 slds-align--absolute-center"  >  <lightning:buttonIcon name="back" alternativeText="Back" iconName="utility:chevronright" onclick="{!c.nextMonth}"/> </div>
        <div class=" slds-size--1-of-12 slds-align--absolute-center"  > 
            
    <lightning:select name="pick" label="Department" onchange="{!c.updateDepartment}" aura:id="pickId">
        <aura:iteration items="{!v.pickList}" var="item">
        <option value="{!item}">{!item}</option>
        
        </aura:iteration>
    
    </lightning:select>
        
        </div>
            
    </div>

	<table class="slds-table slds-table--bordered slds-is-resizable" role="grid">
  		<thead>
   			 <tr class="slds-text-title--caps">
                 <aura:iteration items="{!v.daysOfWeek}" var="day">
                     <th class="slds-cell-shrink" scope="col" style="text-align: center;"><b>{!day}</b> </th>
                 </aura:iteration>
            </tr>
        </thead>
        <tbody>
   {!v.body}
        
        </tbody>
    </table>


    

	
</aura:component>

({
    // Calendar - controller
    
	doInit : function(component, event, helper) {
        var today = new Date();
        var dd = today.getDate();
        var mm = today.getMonth(); //January is 0!
        var yyyy = today.getFullYear();
      // get first day of month
        var today = new Date(yyyy, mm, 1); 
        component.set("v.currentMonth", today);
        var selected = component.get("v.selectedDept");
       helper.retrievePickList(component);
        helper.retrieveEventList(component, mm +1, yyyy, selected);
	},  // end function
    
    
    lastMonth : function(component, event, helper) {
        var currentMonth = component.get('v.currentMonth');
        currentMonth = new Date(currentMonth);
        
        currentMonth = currentMonth.setMonth(currentMonth.getMonth() -1);
        currentMonth = new Date(currentMonth);
        component.set('v.currentMonth', currentMonth);
        var month = currentMonth.getMonth() +1;
        var year = currentMonth.getFullYear() ;
        var selected = component.get("v.selectedDept");
        helper.retrieveEventList(component, month, year);
	},
    
 
    nextMonth : function(component, event, helper) {
        var currentMonth = component.get('v.currentMonth');
        currentMonth = new Date(currentMonth);
        
        currentMonth = currentMonth.setMonth(currentMonth.getMonth() +1);
        currentMonth = new Date(currentMonth);
        component.set('v.currentMonth', currentMonth);
        var month = currentMonth.getMonth() +1;
        var year = currentMonth.getFullYear() ;  
        var selected = component.get("v.selectedDept");
        helper.retrieveEventList(component, month, year);
        
	},


    updateDepartment : function(component, event, helper) {  
        var selected = component.find("pickId").get("v.value");
        component.set('v.selectedDept', selected);
        console.log('result' + selected);
    	var currentMonth = component.get('v.currentMonth');
        currentMonth = new Date(currentMonth);
        var month = currentMonth.getMonth() +1;
        var year = currentMonth.getFullYear() ;
        helper.createCalendar(component);        
    },
    
    
    
})
 
({
    // calendar - helper
    
    retrievePickList : function(component) {
		var action = component.get("c.getDepartments");
       
       // action.setParams({"month": month, "year": year});
        action.setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                var returned =response.getReturnValue();
                console.log("SUCCESS returned: " + JSON.stringify(returned));
                component.set('v.pickList', returned);
            }
        });
        $A.enqueueAction(action);          
    },
    
    
    retrieveEventList : function(component, month, year) {
		var action = component.get("c.getEventList");
        action.setParams({"month": month, "year": year});
        action.setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                var returned =response.getReturnValue();
                component.set('v.eventList', returned);
                // console.log("SUCCESS returned: " + JSON.stringify(returned));
                var that = this;
                that.createCalendar(component);

            }
        });
        $A.enqueueAction(action);          
    },
    
    
    
	createCalendar : function(component) {
        var eventList = component.get('v.eventList');
        var today = component.get('v.currentMonth');
        var selectedDept = component.get('v.selectedDept');
		
        //these are labels for the days of the week
        var cal_days_labels = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];    
        component.set('v.daysOfWeek', cal_days_labels)
        // these are human-readable month name labels, in order
        var cal_months_labels = ['January', 'February', 'March', 'April',
                         'May', 'June', 'July', 'August', 'September',
                         'October', 'November', 'December'];        
		            
        //today = new Date();
        var dd = today.getDate();
        var mm = today.getMonth(); //January is 0!
        var yyyy = today.getFullYear();
        // get first day of month
        var firstDay = new Date(yyyy, mm, 1);
        console.log(' firstday = ' + firstDay);
				
		        
        var startingDay = firstDay.getDay();
        var nextDay = new Date(firstDay);
        component.set('v.month', cal_months_labels[mm] + ' ' + yyyy);       
        console.log(' starting day ' + startingDay);
	    
        // find number of days in month
        var monthLength = new Date(yyyy, mm, 0).getDate() +1;
        console.log (' monthLength ' + monthLength);  
				       
        // compensate for leap year
        if (mm == 2) { // February only!
        	if((yyyy % 4 == 0 && yyyy % 100 != 0) || yyyy % 400 == 0){
          		monthLength = 29;
        }
      }
        
        

 // **********************************************************************88   
    // Array of components to create
    	var newComponents = [];
        
        // put the weeks/table rows in the components array
        for (var i = 0; i < 7; i++) 
        {
			newComponents.push(["aura:html", {
            	"tag": "tr"
      		}]);              
        }
        
        for (var i = 1; i <= startingDay; i++) {
            // put the days rows in the components array
       		 newComponents.push(["c:CalendarDay", {
				"visible": false
        	 }]); 
        }           
  
 // **********************************************************************88 
 // in this section, we loop through the days of the month and create components for each day       
        for (var i = 1; i <= monthLength; i++) {  //
            var stringBody = [];
            var nextDay = nextDay.toISOString().slice(0,10);
            // console.log('nextDay ' +nextDay);
            for(var e = 0;  e < eventList.length; e ++) {
                var eventDate = new Date(eventList[e].StartDateTime);
                var eventDept = eventList[e].Department__c;
                eventDate = eventDate.toISOString().slice(0,10);
                // if the calendar day of the month matches the calendar day of the event, then add the subject of the event to the calendar day compeonet
            	if (eventDate == nextDay) {
                    if (selectedDept == 'Any') {
                    	stringBody.push(eventList[e].Subject);    
                    }
                    else if (eventDept == selectedDept) {
                        stringBody.push(eventList[e].Subject); 
                    }
            	}                
            } // end for 

            // increament day for the date variable
            var nextDay = new Date(nextDay);
            var dateValue = nextDay.getDate() + 1;
            nextDay.setDate(dateValue);
     		
            newComponents.push(["c:CalendarDay", {
				"day": i,
                 "toDoItems": stringBody
        	 }]); 
        }  
        
        for (var i = 1; i <= 5; i++) {
            // put the days rows in the components array
       		 newComponents.push(["c:CalendarDay", {
                 "visible": false
        	 }]); 
        }             
            
 // **********************************************************************88           
 
   $A.createComponents(newComponents,
        function (components, status, errorMessage) {
           if (status === "SUCCESS") {
               var pageBody = component.get("v.body");
               pageBody = [];
               for (var outer = 0; outer < 5; outer ++) {	
                    var tr = components[outer];
                    var trBody = tr.get("v.body");
                    for (var inner = 1; inner < 8; inner ++) {
                        var outerAdj = outer +0;
                    	var adj =  6 + + inner + (7 * outerAdj); 
                        var toDay = components[adj];
                        trBody.push(toDay);
                    }
                    tr.set("v.body", trBody)
                    pageBody.push(tr);
               }

				component.set("v.body", pageBody);
            }  // end success
            else // Report any error
            {
                this.displayToast("Error", "Failed to create list components.");
            }
        } // end callback function
    );     // end create component   
        		
	}
})

<!-- CalendarDay.cmp  -->
<aura:component >
    <aura:attribute name="day" type="String"/>
    <aura:attribute name="visible" type="Boolean" default="true"/>
    <aura:attribute name="toDoItems" type="String[]"/>
    
    <td class = "outline" scope="col" >
       <aura:if isTrue="{!v.visible}">  
        <fieldset class="slds-box slds-theme--default ">
           
            
            
    <table class="subtable" style="vertical-align:top">
  		<thead>
   			 <tr >

                    <th   class="thClass"> {!v.day} </th>

            </tr>
        </thead>
        <tbody>
        	<aura:iteration items="{!v.toDoItems}" var="item">
           		<tr><td >{!item} </td></tr>
               </aura:iteration>
            

        
        </tbody>
    </table>
 

            
        </fieldset>
           </aura:if>
        </td>
	
</aura:component>

/* calendarDay.css  */

.THIS.outline {
    border: solid black 1px;
    float: top;
}

.THIS .thClass {
    vertical-align:top;
    text-align: center;

}

.THIS .subtable {
        vertical-align:top;
    position: relative;
     






}


 
Hi,

Is there an easy way to clone opportunities and products in lightning?  

Thanks,
Hi,

I have a lightning component that is creating a new task.  It used to call it's component, which calls the apex class and that works fine.  But then I realized it would really be better if it called an event which passed the task up so it could be created by the main component, and that doesn't work


Account Activities component calls for creation
<aura:component controller="AccountProspectingClass">
	<aura:attribute name="selectedAccount" type="account"/>
    <aura:attribute name="newTask" type="Task" />
    <aura:attribute name="subject" type="string"/>
    <aura:registerEvent name="createTask" type="c.accountProspecting_TaskEvent"/>
    
    
  
    <lightning:tabset >
        <lightning:tab label="Make a Call">
            <fieldset class="slds-box slds-theme--default slds-container--small">
                <form class="slds-form--stacked">
                
                      <div class="slds-form-element slds-is-required">
                          <div class="slds-form-element__control">
                              <ui:inputText aura:id="subject" label="Subject:"
                                  class="slds-input"
                                  labelClass="slds-form-element__label"
                                  value="{!v.newTask.Subject}"
                                  required="true"/>
                          </div>
                     </div>                

                      <div class="slds-form-element slds-is-required">
                          <div class="slds-form-element__control">
                              <ui:inputText aura:id="comments" label="Comments:"
                                  class="slds-input"
                                  labelClass="slds-form-element__label"
                                  value="{!v.newTask.Description}"
                                  required="true"/>
                          </div>
                     </div>                      

                    <div class="slds-form-element slds-is-required">
                          <div class="slds-form-element__control">
                              <ui:inputDate aura:id="taskDate" label="Date:"
                                  class="slds-input"
                                            displayDatePicker="true"
                                  labelClass="slds-form-element__label"
                                  value="{!v.newTask.ActivityDate}"
                                  required="true"/>
                          </div>
                     </div>                        
                    
                     <div class="slds-form-element">
                          <ui:button label="Create Expense"
                              class="slds-button slds-button--brand"
                              press="{!c.clickCreateTask}"/>
                     </div>

                
                 
                </form>
            </fieldset>             
        </lightning:tab>
        
        <lightning:tab label="New Task">
        
        
        </lightning:tab>
    
    </lightning:tabset>
 
 
</aura:component>
That component then calls the lightning controller which calls the apex class and that works fine
 
({
	clickCreateTask : function(component, event, helper) {
   
		// old way of doing works fine
        var newTask = component.get("v.newTask");
        var acct = component.get("v.selectedAccount");
        component.set("v.newTask.WhatId", acct.Id);
        console.log("acct Id = " + acct.Id);
        console.log("task is : " + JSON.stringify(newTask));
        
        var action = component.get("c.createTask");
        action.setParams({"newTask": newTask});
       
        action.setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                var returned =response.getReturnValue()
                console.log("items returned: " + JSON.stringify(returned));
             //   var expenses = component.get("v.expenses");
              //  expenses.push(response.getReturnValue());
              //  component.set("v.expenses", expenses);
              
            }
        });
        $A.enqueueAction(action);
                             
		
	}
})

New way, calls the event
({
	clickCreateTask : function(component, event, helper) {
           // new way of doing things, calls event
        var newTask = component.get("v.newTask");
        
        var updateEvent = component.getEvent("createTask");
        updateEvent.setParam({"currentTask": newTask});
        updateEvent.fire();

		
	}
})
<aura:event type="COMPONENT" description="task event" >
    <aura:attribute name="currentTask" type="Task"/>
</aura:event>
The main component
<aura:component controller="AccountProspectingClass"  implements="force:appHostable,flexipage:availableForAllPageTypes" access="global">
    <aura:attribute name="accountList" type="account[]"/>
    <aura:attribute name="selectedAccount" type="account"/>
    <aura:attribute name="newTask" type="Task" default="{'sobjectType': 'Task', 'Subject': 'blank subject', 'Description': ' blank description'}"/>
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    <aura:handler name="selectAccount" event="c.accountProspecting_selectAccountEvent" action="{!c.updateAccount}"/>
    <aura:handler name="createTask" event="c.accountProspecting_TaskEvent" action="{!c.createTask}"/>
	<!-- header for selected Account -->
    <c:accountProspectingSelected selectedAccount="{!v.selectedAccount}"/>
    <!-- end header -->
    <div class="slds-grid  "  >
       <div class="slds-col slds-size--1-of-6 slds-scrollable " style="height: 600px;">    
           <table class="slds-table " >
           <aura:iteration items="{!v.accountList}" var="acct" >
                <c:accountProspectingItem acct="{!acct}"/>  
        
           </aura:iteration>
           </table>
       </div> 
    
    
        <div class="slds-col slds-size--2-of-3 slds-p-around--large">
            <c:accountActivities selectedAccount="{!v.selectedAccount}" newTask="{!v.newTask}"/>
        </div>
                    

        

    </div> <!-- end the main grid -->
	
</aura:component>

and the controller for the main component
createTask: function(component, event, helper) {
        
       
        var newTask = event.getParam("currentTask");
        var acct = component.get("v.selectedAccount");
        component.set("v.newTask.WhatId", acct.Id);
        console.log("acct Id = " + acct.Id);
        console.log("task is : " + JSON.stringify(newTask));
        
        var action = component.get("c.createTask");
        action.setParams({"newTask": newTask});
       
        action.setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                var returned =response.getReturnValue()
                console.log("items returned: " + JSON.stringify(returned));
             //   var expenses = component.get("v.expenses");
              //  expenses.push(response.getReturnValue());
              //  component.set("v.expenses", expenses);
              
            }
        });
        $A.enqueueAction(action);
       
        
    },






 
Hi,

I have developed an account based forecast tool for my current company and am considering trying to get it on the app exchange.  Anyone that might be interested in a partnership to do so please contact me.

Thanks,

Mathew
Hi,

I have two data tables, the top one provides summary information for the bottom one.  But they don't always line up even though they have the same number of columns, and I use the width parameter on the data tables to make sure they are the same size..  Is there a good way to make sure the columns from the top and bottom data table always line up.  

Thanks,
 
Hi,

I would like to group columns columns to make them easy to hide and unide like you can do in excel.  I know I can use the render feature to hide and unide them, but what's the best way to trigger the hiding and unhiding?  I'm hoping for something a bit better than a checkbox.

Thanks,
Hi,

I'm trying to use apex:repeat to loop through the list of contacts attached to a opportunity (through the account), but I'm getting an error.  I assume my dot notation is messed up.

What I have is
 
<apex:repeat value="{!Opportunity.account.contacts}" var="con">

Thanks,
I am trying to get my visualforce pdf page to open in landscape but having some problems.  I have the following
 
<apex:page standardController="Opportunity" showHeader="false"  extensions="savePDF" renderAs="pdf">
<head>
    <style type="text/css">
@page {
    size: landscape;
}
</style>
    </head>
   
 <apex:form >

But still no luck.  Any ideas?
Hi,

I have a map/list with year over year sales by quarter for accounts.  I want to calculate the change year over year.  For example if Q1 prior year is 100 and Q1 current year is 150 then the growth should be 150.

Currently what I'm doing is changing my map into a list and then doing the calculation based on the position in the list, but I'm wondering if there is a better way to do this. 

Any thoughts?
 
for (PivotTimeSeries_Class.PivotRowWrapper wrapper :partialRowList) {
            List<decimal> salesList = new List<decimal>();
            for (string period:periodYearList) {
                salesList.add(wrapper.amountMap.get(period));
            }
        	map<string, decimal> growthMap = new map<string, decimal>();
            decimal Y1Total;
            decimal Y2Total;
            decimal q1Growth;
            decimal q2Growth;
            decimal q3Growth;
            decimal q4Growth;
            decimal YGrowth;
            
            Y1Total = salesList[0] + salesList[1] + salesList[2] + salesList[3];
            Y2Total = salesList[5] + salesList[6] + salesList[7] + salesList[8];

            wrapper.amountMap.put('Y1 Total', Y1Total);
            wrapper.amountMap.put('Y2 Total', Y2Total);
            if (salesList[0] != 0 && salesList[0] != NULL && salesList[4] != 0 && salesList[4] != NULL) { q1Growth = salesList[4]/salesList[0]*100 -100; } else { q1Growth = 0; } growthMap.put('P1Growth', q1Growth); 
            if (salesList[1] != 0 && salesList[1] != NULL && salesList[5] != 0 && salesList[5] != NULL) { q2Growth = salesList[5]/salesList[1]*100 -100; } else { q2Growth = 0; } growthMap.put('P2Growth', q2Growth); 
            if (salesList[2] != 0 && salesList[2] != NULL && salesList[6] != 0 && salesList[6] != NULL) { q3Growth = salesList[6]/salesList[2]*100 -100; } else { q3Growth = 0; } growthMap.put('P3Growth', q3Growth); 
            if (salesList[3] != 0 && salesList[3] != NULL && salesList[7] != 0 && salesList[7] != NULL) { q4Growth = salesList[7]/salesList[3]*100 -100; } else { q4Growth = 0; } growthMap.put('P4Growth', q4Growth); 
            if (Y1Total != 0 && Y2Total != 0) { YGrowth = Y2Total / Y1TOtal*100 -100; system.debug ('firing'); } else { YGrowth = 0; } growthMap.put('YoY Growth', YGrowth);
            system.debug('YGrowth = ' +YGrowth);
            sortList.add(new SortWrapper(new CompleteRowWrapper(wrapper, growthMap)));

        }
        sortList.sort();
        for (SortWrapper sorted:sortList) {
            CompleteRowList.add(sorted.wrapper);
        }

 
Hi,

Is it possible to hide and unhide (make collasable) a horizontal portion of a table?  For example say I had the following in a data table
time series data - forecast on time series data - percent growth on time series data

and I wanted to make it possible to hide an unhide sections.

Thanks,
Hi,

This is really wierd.  I have an action that triggers a summary email to be sent when triggered.  The first time I click the action button the email gets sent but is blank.  The second time I click it the email is sent but has data in it.  I can't think what could possibly cause behavior like that.

This is the section
try {
        PageReference displayPage = page.BottlingSummaryEmail_page;
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {}; 
		toAddresses.add(userEmail);

        Blob body;
        string htmlBody;
        try {
            // returns the output of the page as a blob
            body = displayPage.getContent();
            system.debug('body should be fine');
            // need to pass unit test -- current bug    
            } catch (VisualforceException e) {
                system.debug('in the catch block');
                 body = Blob.valueOf('Some Text');
            }
        htmlBody = body.toString();
        email.setHtmlBody(htmlBody);
        email.setToAddresses(toAddresses);  
     	email.setSubject('Bottling Summary for '); // + dateString);            
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        } catch (exception e) { system.debug ('TastingRecap_class *** error in the send email and error = ' + e);}

of code where I send the summary email (I can provide the rest if needed)


and here is the visualforce page I call for the tempalte
 
<apex:repeat value="{!botLotMap}" var="shift">
        
   <h1>  Bottling Summary for Shift {!shift} </h1>
        <table width="100%">
            
      
       <th>Shift</th><th>Change Over</th><th>Operation</th> <th>Client</th><th>Brand</th><th>Cases</th><th>Cases per Hour</th><th>Notes</th>
        <apex:repeat value="{!botLotMap[shift]}" var="v" >
       
            <tr>
            <td><apex:outputtext value="{!botLotMap[shift][v].Bottling_Shift__r.Bottling_Shift__c}" /></td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Type_of_Changeover__c}"  />  </td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Labeled_Bottled__c}"/></td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Client_Lookup__r.name}" /></td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Brand__c}"/></td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Actual_Bottled__c}"/> </td>           
            <td><apex:outputtext value="{!botLotMap[shift][v].Cases_Per_Hour__c}"/></td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Notes__c}"/></td>
            </tr>

            
        </apex:repeat>  
            <tr><td colspan="4">Total</td><td>{!totalCasesBottled[shift]}</td><td></td><td></td><td></td></tr>
        </table>
    </apex:repeat>
  
    
</apex:page>

Thanks,
 
Hi,

Is there any way to have multiple picklists always have the same data in different objects?   For example, we have a wine business so data such as appellation or wine variety is the same but is in different objects such as products, samples, etc.  Is there anyway to designate it all comes from one source so I don't have to update it in multiple places each time it changes.

Thanks,
Hi,

I see how to implement custom sorting here
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_list_sorting_sobject.htm
And this is working for me.

If I want to sort on various custom columns is my only option to create a seperate class with a different sortable definition for each one?  Or is there a better way to do it.

For example, this is my current class where I sort on a total column that is part of a map of columns.
Thanks,
 
public class SortWrapper implements Comparable {

        public CompleteRowWrapper wrapper;
        
        // Constructor
        public SortWrapper(CompleteRowWrapper wrapper) {
            this.wrapper = wrapper;
        }
        
        // Compare opportunities based on the opportunity amount.
        public Integer compareTo(Object compareTo) {
            // Cast argument to SortWrapper
            SortWrapper compareToWrapper = (SortWrapper)compareTo;
            
            // The return value of 0 indicates that both elements are equal.
            Integer returnValue = 0;
            if (wrapper.partialRowList.amountMap.get('Total') < compareToWrapper.wrapper.partialRowList.amountMap.get('Total')) {
                // Set return value to a positive value.
                returnValue = 1;
            } else if (wrapper.partialRowList.amountMap.get('Total') > compareToWrapper.wrapper.partialRowList.amountMap.get('Total')) {
                // Set return value to a negative value.
                returnValue = -1;
            }
            
            return returnValue;       
        }
	} // end the sortable

 
Hi,

I have a date time field that when I display in visualforce doesn't always show the correct date.  If the time I enter is 4:00 PM or later it displays the next days date.

My company time and user times are both PST (GMT + 8)
 
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}"> <apex:param value="{!v.tasting.Date_of_Tasting_Start__c}" />

Any ideas?
 
Hi,

I have a list that I want to split up into seperate sub groups.  Basically it's an aggregate result list that I want to split up by account name, and then time period (which I define as a string of year plus quarter).  Here is what I have so far, but I have to think there's a better way.

Thanks,
 
Map<string, Decimal> amountMap = new Map<String, Decimal>();
        string lastname;
        string name;
        string accountId;
        try {
            for (AggListWrapper wrapper:wrapperList) {
                name = wrapper.name;
                accountId = wrapper.accountId;
                decimal amount = wrapper.amount;
                string periodYear = ''+ wrapper.year + '-' + wrapper.period;
                periodYearSet.add(periodYear);
                if (lastName == NULL) { lastName=name;}
                if (lastName != name) {
                    completeRowList.add(new PivotRowWrapper(lastName, accountId, amountMap, NULL));
                    amountMap = new Map<string, Decimal>();
                 }
                amountMap.put(periodYear, amount);
                system.debug('PivotTimeSeries_Class *** account id = ' + accountId + 'end of loop name=' + name + ' lastName=' + lastName + ' amountMap=' + amountMap);
                lastName = name;
             }
        } catch (exception e) {
            system.debug('PivotTimeSeries_Class *** error in the wraperList lopp ' + e);
        }
        periodYearList.addAll(periodYearSet);
        periodYearList.sort();
        completeRowList.add(new PivotRowWrapper(name, accountId, amountMap, NULL));  // line total is null when we first go through

 
Hi,

I have a list of bottling's done each day that I'm breaking up by user email and then account so each user might be multiple accounts.  The structure I went with was map<email, map <account id, bottling_lot__C>

Then my idea was to pass that map into a visualforce page's custom controller where it could then generate a custom visualforce page which I could then bring back into my main class convert from blob to string and send on it's merry way as an html email.

So my question is in two parts, one is this a reasonable way to do this, or should is there a better solution.

The second is I can't figure out how to get the visualforce page to connect to the right version of my class that has the correct map.  Normally I would pass in an Id of some sort but that won't exactly work here.  I need to pass in the map, or at least a list of some type.

Any ideas?
 
public void sendClientEmail() {
       
        
        Set<String> repSet = new set<String>();
        map<String, Map<string, Bottling_Lot__c>> repMap = new map<String, Map<string, Bottling_Lot__c>>(); // email <account Id, bottling lot>
        Map<string, Bottling_Lot__c> acctMap;
        
        // build a set of all the owner Id that will have to be emailed        
        if (botLotList.size() > 0) {
            for (Bottling_Lot__c bot:botLotList) {  
                repSet.add(bot.client_lookup__r.owner.email);
            }
            for (String s:repSet) {
                acctMap = new map<String, Bottling_lot__c>();
                for (Bottling_Lot__c bot:botLotList) { 
                    if (s == bot.client_lookup__r.owner.email) {
                        acctMap.put(bot.client_lookup__c, bot);
                    }
                 }
                repMap.put(s, acctMap);
             }
            system.debug('repMap = ' + repMap);
         }
        
        // Define the email
       
        for (String s:repSet) {
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();        
            String[] toAddresses = new String[] {}; 
            String[] ccAddresses = new String[] {}; 
            toAddresses.add('mathew@terravant.com');

            blob body;
            BottlingEmail_Class botClass = new BottlingEmail_Class(repMap);
            PageReference htmlPage = page.bottlingEmail_Page;
            body = htmlPage.getContent();
            String htmlBody = body.toString();
 
			email.setToAddresses(toAddresses);
            email.setSubject('test');
            email.setHtmlBody(htmlBody);
            Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
            
        }
      
        
        
    } // end the send email method
 
<apex:page controller="BottlingEmail_Class" >
    
    <p>
        Hello, the following items were bottled for your clients
    </p>
    
    <table>
        <tr>
        <th>Date</th>
        <th>Account</th>
        <th>Cases</th>
        </tr>
        
        <apex:repeat value="{!botLotList}" var="v">
        	<tr>
                <td>{!v.Bottling_Shift__r.Bottling_Day__r.Bottling_Date__c}</td>
                <td>{!v.client_lookup__r.name}</td>
                <td>{!v.Actual_Bottled__c}</td>
                <td>testing</td>
            
            
            </tr>
        </apex:repeat>
        
        
        
    </table>
    <p>
        end of page
    </p>
    
</apex:page>
 
public class BottlingEmail_Class {
    
    public map<String, Map<string, Bottling_Lot__c>> repMap {get; set;}  // email <account Id, bottling lot>
    public List<Bottling_Lot__c> botLotList {get; set; }
        
    
 
    
    public BottlingEmail_Class(map<String, Map<string, Bottling_Lot__c>> repMap) {
        botLotList = new List<bottling_Lot__c>();
    	this.repMap = repMap;
        for (string key :repMap.keySet()) {
            Map<String, Bottling_lot__c> acctMap = new Map<String, Bottling_Lot__c>();
            acctMap = repMap.get(key);
            for (Bottling_Lot__c lot :acctMap.values() ) {
                botLotList.add(lot);
                
            }
            
            
        }
       
        
        
    } // end the constructor

}

 
Hi,

Is there any way to have multiple picklists always have the same data in different objects?   For example, we have a wine business so data such as appellation or wine variety is the same but is in different objects such as products, samples, etc.  Is there anyway to designate it all comes from one source so I don't have to update it in multiple places each time it changes.

Thanks,

Hello all,

I'm currently working through Step 7 of the new "Lightning Component Framework Specialist" superbadge, and I'm running into an error while checking the challenge:

"The AddBoatReview controller's onSave() function doesn't fire the BoatReviewAdded event."

The problem is that I'm testing the component right now, and my event is being received by the parent just fine, and my tabset switches to the "Reviews" section like it should, so know it's being handled correctly. I've tried using both a Component event and an Application event just to debug a bit (even though Component is the best option for this scenario), and that doesn't change anything. Any idea what could be triggering this error message?

Relevant code:

AddBoatReviewController.js

onSave : function(component, event, helper){
    	component.set("v.boatReview.Boat__c",component.get("v.boat.Id"));

        component.find("service").saveRecord(function(saveResult) {
            if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {

               var cmpEvent = component.getEvent("reviewAdded");
		       cmpEvent.fire();

               //Attempt at trying an Application event instead
		       //var cmpEvent = $A.get("e.c:BoatReviewAdded");
		       //cmpEvent.fire();


                var resultsToast = $A.get("e.force:showToast");
                //Toast code and other saveResults states below...
AddBoatReview.cmp
<aura:registerEvent name="reviewAdded" type="c:BoatReviewAdded"/>
     
    <!-- Display form -->
    <lightning:layout multipleRows="true">
            <lightning:layoutItem size="12" padding="around-small">
                <lightning:input name="title" label="Title" value="{!v.boatReview.Name}"/>
            </lightning:layoutItem>

            <lightning:layoutItem size="12" padding="around-small">
                <label class="slds-form-element__label" for="input-id-01">Description</label>
                <lightning:inputRichText value="{!v.boatReview.Comment__c}" disabledCategories="FORMAT_FONT"/>
            </lightning:layoutItem>

            <lightning:layoutItem size="12" class="slds-align--absolute-center">
                <lightning:button iconName="utility:save" label="Submit" onclick="{!c.onSave}"/>
            </lightning:layoutItem>
    </lightning:layout>
BoatDetails.cmp
<aura:handler name="reviewAdded" event="c:BoatReviewAdded" action="{!c.onBoatReviewAdded}"/>

BoatDetailsController.js

onBoatReviewAdded : function(component, event, helper) {
	console.log("Event received");
	component.set("v.selTabId", "boatreviewtab");
}

Hi,
I'm stuck at the first challenge where it always returns me:
Could not find an entry in the ServiceCredentials custom setting named 'BillingServiceCredential' with the specified username and password. Ensure the you have entered the data correctly into the custom settings record.
I think that I did everything right. The unmanaged package came with a custom setting called ServiceCredentials:

User-added image
I clicked manage and added the BillingServiceCredential

User-added image

With following details
User-added image

Still giving me above error!
Any ideas?

Regs,
Pieter

 built a reporting calendar that displays events and allows you to filter by department etc. It also includes some additional event fields such as completed.
Then my users create recurring events for reports (say every Monday do event X) that they need to mark complete.
But when trying to mark the event complete through apex I get the following error
"You cannot reassign a recurring event occurrence"
Note going back and changing the recurring event won't work, because I want to change each event individually, even if it started as a recurrence.
Any ideas on how to do this besides creating my own apex method that creates recurring events?
 
@AuraEnabled
    public static List<Event> getEventList(Decimal month, Decimal year) {
        Integer workingMonth = (Integer)month;
        Integer workingYear = (Integer)year;
        system.debug('year ' + year);
        system.debug('currentMonth' + workingMonth);
        List<Event> eventList = [SELECT Subject, Id, StartDateTime, Department__c, Out_Of_Office__c, Status__c, Reporting_Calendar__c FROM Event 
                                 WHERE (CALENDAR_MONTH(StartDateTime) = :workingMonth AND CALENDAR_YEAR(StartDateTime) = :workingYear) AND Reporting_Calendar__c=true AND isRecurrence=false]; //
        system.debug(eventList);
        return eventList;
    }
    
    @AuraEnabled
    public static Event getNewEvent(Event newEvent) {
        String userId = UserInfo.getUserId();
        newEvent.OwnerId = userId;
        upsert newEvent;
        system.debug(newEvent);
        return newEvent;
    }

 
Hi,

Normally in Salesforce there is a lookup field for users you can click and find the user.  Is there an easy way to do this in lightning?

Thanks,
Hi,

I developed a customizable ligtning calendar component.  It queries event data and then puts the event subjects on the relevant days.  Everything works great, except I can't get my calendar days to align properly.  The days with data in them don't align with the days that don't. I put all code here in case anyone else wants a working lightning calendar

Any ideas?  
 
<!-- Calendar.cmp  -->
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" controller="CalendarEvent_CLASS">
    <aura:attribute name="daysOfWeek" type="String[]"/>
    <aura:attribute name="week1" type="String"/>
    <aura:attribute name="month" type="String"/>
    <aura:attribute name="currentMonth" type="Date"/>
    <aura:attribute name="pickList" type="String[]"/>
    <aura:attribute name="selectedDept" type="String" default="Any"/>
    <aura:attribute name="selectedUser" type="String" default="Any"/>
    <aura:attribute name="eventList" type="Event[]"/>
 
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
 
    <div class="slds-grid slds-page-header"   role="banner">  <!-- banner  -->
        
        
        <div class=" slds-size--1-of-12 slds-align--absolute-center"   > <lightning:buttonIcon name="back" alternativeText="Back" iconName="utility:chevronleft" onclick="{!c.lastMonth}"/> </div>
   	    <div class=" slds-size--9-of-12 slds-align--absolute-center"> <b>{!v.month} </b></div>
        <div class=" slds-size--1-of-12 slds-align--absolute-center"  >  <lightning:buttonIcon name="back" alternativeText="Back" iconName="utility:chevronright" onclick="{!c.nextMonth}"/> </div>
        <div class=" slds-size--1-of-12 slds-align--absolute-center"  > 
            
    <lightning:select name="pick" label="Department" onchange="{!c.updateDepartment}" aura:id="pickId">
        <aura:iteration items="{!v.pickList}" var="item">
        <option value="{!item}">{!item}</option>
        
        </aura:iteration>
    
    </lightning:select>
        
        </div>
            
    </div>

	<table class="slds-table slds-table--bordered slds-is-resizable" role="grid">
  		<thead>
   			 <tr class="slds-text-title--caps">
                 <aura:iteration items="{!v.daysOfWeek}" var="day">
                     <th class="slds-cell-shrink" scope="col" style="text-align: center;"><b>{!day}</b> </th>
                 </aura:iteration>
            </tr>
        </thead>
        <tbody>
   {!v.body}
        
        </tbody>
    </table>


    

	
</aura:component>

({
    // Calendar - controller
    
	doInit : function(component, event, helper) {
        var today = new Date();
        var dd = today.getDate();
        var mm = today.getMonth(); //January is 0!
        var yyyy = today.getFullYear();
      // get first day of month
        var today = new Date(yyyy, mm, 1); 
        component.set("v.currentMonth", today);
        var selected = component.get("v.selectedDept");
       helper.retrievePickList(component);
        helper.retrieveEventList(component, mm +1, yyyy, selected);
	},  // end function
    
    
    lastMonth : function(component, event, helper) {
        var currentMonth = component.get('v.currentMonth');
        currentMonth = new Date(currentMonth);
        
        currentMonth = currentMonth.setMonth(currentMonth.getMonth() -1);
        currentMonth = new Date(currentMonth);
        component.set('v.currentMonth', currentMonth);
        var month = currentMonth.getMonth() +1;
        var year = currentMonth.getFullYear() ;
        var selected = component.get("v.selectedDept");
        helper.retrieveEventList(component, month, year);
	},
    
 
    nextMonth : function(component, event, helper) {
        var currentMonth = component.get('v.currentMonth');
        currentMonth = new Date(currentMonth);
        
        currentMonth = currentMonth.setMonth(currentMonth.getMonth() +1);
        currentMonth = new Date(currentMonth);
        component.set('v.currentMonth', currentMonth);
        var month = currentMonth.getMonth() +1;
        var year = currentMonth.getFullYear() ;  
        var selected = component.get("v.selectedDept");
        helper.retrieveEventList(component, month, year);
        
	},


    updateDepartment : function(component, event, helper) {  
        var selected = component.find("pickId").get("v.value");
        component.set('v.selectedDept', selected);
        console.log('result' + selected);
    	var currentMonth = component.get('v.currentMonth');
        currentMonth = new Date(currentMonth);
        var month = currentMonth.getMonth() +1;
        var year = currentMonth.getFullYear() ;
        helper.createCalendar(component);        
    },
    
    
    
})
 
({
    // calendar - helper
    
    retrievePickList : function(component) {
		var action = component.get("c.getDepartments");
       
       // action.setParams({"month": month, "year": year});
        action.setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                var returned =response.getReturnValue();
                console.log("SUCCESS returned: " + JSON.stringify(returned));
                component.set('v.pickList', returned);
            }
        });
        $A.enqueueAction(action);          
    },
    
    
    retrieveEventList : function(component, month, year) {
		var action = component.get("c.getEventList");
        action.setParams({"month": month, "year": year});
        action.setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                var returned =response.getReturnValue();
                component.set('v.eventList', returned);
                // console.log("SUCCESS returned: " + JSON.stringify(returned));
                var that = this;
                that.createCalendar(component);

            }
        });
        $A.enqueueAction(action);          
    },
    
    
    
	createCalendar : function(component) {
        var eventList = component.get('v.eventList');
        var today = component.get('v.currentMonth');
        var selectedDept = component.get('v.selectedDept');
		
        //these are labels for the days of the week
        var cal_days_labels = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];    
        component.set('v.daysOfWeek', cal_days_labels)
        // these are human-readable month name labels, in order
        var cal_months_labels = ['January', 'February', 'March', 'April',
                         'May', 'June', 'July', 'August', 'September',
                         'October', 'November', 'December'];        
		            
        //today = new Date();
        var dd = today.getDate();
        var mm = today.getMonth(); //January is 0!
        var yyyy = today.getFullYear();
        // get first day of month
        var firstDay = new Date(yyyy, mm, 1);
        console.log(' firstday = ' + firstDay);
				
		        
        var startingDay = firstDay.getDay();
        var nextDay = new Date(firstDay);
        component.set('v.month', cal_months_labels[mm] + ' ' + yyyy);       
        console.log(' starting day ' + startingDay);
	    
        // find number of days in month
        var monthLength = new Date(yyyy, mm, 0).getDate() +1;
        console.log (' monthLength ' + monthLength);  
				       
        // compensate for leap year
        if (mm == 2) { // February only!
        	if((yyyy % 4 == 0 && yyyy % 100 != 0) || yyyy % 400 == 0){
          		monthLength = 29;
        }
      }
        
        

 // **********************************************************************88   
    // Array of components to create
    	var newComponents = [];
        
        // put the weeks/table rows in the components array
        for (var i = 0; i < 7; i++) 
        {
			newComponents.push(["aura:html", {
            	"tag": "tr"
      		}]);              
        }
        
        for (var i = 1; i <= startingDay; i++) {
            // put the days rows in the components array
       		 newComponents.push(["c:CalendarDay", {
				"visible": false
        	 }]); 
        }           
  
 // **********************************************************************88 
 // in this section, we loop through the days of the month and create components for each day       
        for (var i = 1; i <= monthLength; i++) {  //
            var stringBody = [];
            var nextDay = nextDay.toISOString().slice(0,10);
            // console.log('nextDay ' +nextDay);
            for(var e = 0;  e < eventList.length; e ++) {
                var eventDate = new Date(eventList[e].StartDateTime);
                var eventDept = eventList[e].Department__c;
                eventDate = eventDate.toISOString().slice(0,10);
                // if the calendar day of the month matches the calendar day of the event, then add the subject of the event to the calendar day compeonet
            	if (eventDate == nextDay) {
                    if (selectedDept == 'Any') {
                    	stringBody.push(eventList[e].Subject);    
                    }
                    else if (eventDept == selectedDept) {
                        stringBody.push(eventList[e].Subject); 
                    }
            	}                
            } // end for 

            // increament day for the date variable
            var nextDay = new Date(nextDay);
            var dateValue = nextDay.getDate() + 1;
            nextDay.setDate(dateValue);
     		
            newComponents.push(["c:CalendarDay", {
				"day": i,
                 "toDoItems": stringBody
        	 }]); 
        }  
        
        for (var i = 1; i <= 5; i++) {
            // put the days rows in the components array
       		 newComponents.push(["c:CalendarDay", {
                 "visible": false
        	 }]); 
        }             
            
 // **********************************************************************88           
 
   $A.createComponents(newComponents,
        function (components, status, errorMessage) {
           if (status === "SUCCESS") {
               var pageBody = component.get("v.body");
               pageBody = [];
               for (var outer = 0; outer < 5; outer ++) {	
                    var tr = components[outer];
                    var trBody = tr.get("v.body");
                    for (var inner = 1; inner < 8; inner ++) {
                        var outerAdj = outer +0;
                    	var adj =  6 + + inner + (7 * outerAdj); 
                        var toDay = components[adj];
                        trBody.push(toDay);
                    }
                    tr.set("v.body", trBody)
                    pageBody.push(tr);
               }

				component.set("v.body", pageBody);
            }  // end success
            else // Report any error
            {
                this.displayToast("Error", "Failed to create list components.");
            }
        } // end callback function
    );     // end create component   
        		
	}
})

<!-- CalendarDay.cmp  -->
<aura:component >
    <aura:attribute name="day" type="String"/>
    <aura:attribute name="visible" type="Boolean" default="true"/>
    <aura:attribute name="toDoItems" type="String[]"/>
    
    <td class = "outline" scope="col" >
       <aura:if isTrue="{!v.visible}">  
        <fieldset class="slds-box slds-theme--default ">
           
            
            
    <table class="subtable" style="vertical-align:top">
  		<thead>
   			 <tr >

                    <th   class="thClass"> {!v.day} </th>

            </tr>
        </thead>
        <tbody>
        	<aura:iteration items="{!v.toDoItems}" var="item">
           		<tr><td >{!item} </td></tr>
               </aura:iteration>
            

        
        </tbody>
    </table>
 

            
        </fieldset>
           </aura:if>
        </td>
	
</aura:component>

/* calendarDay.css  */

.THIS.outline {
    border: solid black 1px;
    float: top;
}

.THIS .thClass {
    vertical-align:top;
    text-align: center;

}

.THIS .subtable {
        vertical-align:top;
    position: relative;
     






}


 
Hi,

Is there an easy way to clone opportunities and products in lightning?  

Thanks,
Hi All,
I need to fetch data from multiple apex methods which yield separate and different lists of objects but I only have one DoInit function and one possible object to be passed to $A.enqueueAction(action). If i call the enqueueAction several times each for a different object, it malfunctions.

Can you think of any solution where I can call different methods on the same class and also set different attributes on my components once the data has returned? without the need of havingg to separate each methods to have its own component. I just created one component just for demo purposes to the client and i want to have it worked the soonest. TIA
Hi All,

I want to display a GRID view page based on SDLS (Salesforce Lightning Design System) which can fetch the list of Account and its associated attributes. The idea is to have a single view showing multiple GRID for each accounts based on some categorization like slow support cases, recently viewed and Stale Accounts. for example the Image below can give a rough idea.



First Screen
Once the user clicks any Account inside the GRID view, for example Account1 in Slow Support case section. Another View will open which will display the account information for that particular Account being clicked and will show the list of support cases in another GRID view section. Refer the Screenshot below.
Second Screen
                            
 
Hi all,

i want to customize lightning calendar.how can i do it.can any one try to help me.

Thank you..
HI,

I am working on a requirement where below are the two criterias , I created two checkboxes on opportunity , Proposals and opportunity do not share master detail relationship,

So workflows might not work, Any suggestions?

field on Opportunity (checkbox): "Has Primary Accepted Proposal"
Logic:  If Proposal that is Primary is changed to Approval Stage = "Accepted", then check this box.  If the Primary proposal is deleted from the opportunity or the status of the primary is changed from Accepted to something else, uncheck this box.

Field on Opportunity (checkbox):   "Has Proposal"
Logic:  If Opportunity has at least one Proposal attached, the box should be checked.  If all Proposals attached to Opp are deleted, this box should be unchecked.  
Hi,

I have developed an account based forecast tool for my current company and am considering trying to get it on the app exchange.  Anyone that might be interested in a partnership to do so please contact me.

Thanks,

Mathew
Hi,

I have two data tables, the top one provides summary information for the bottom one.  But they don't always line up even though they have the same number of columns, and I use the width parameter on the data tables to make sure they are the same size..  Is there a good way to make sure the columns from the top and bottom data table always line up.  

Thanks,
 
Hi,

I'm trying to use apex:repeat to loop through the list of contacts attached to a opportunity (through the account), but I'm getting an error.  I assume my dot notation is messed up.

What I have is
 
<apex:repeat value="{!Opportunity.account.contacts}" var="con">

Thanks,
Hi,

I have a map/list with year over year sales by quarter for accounts.  I want to calculate the change year over year.  For example if Q1 prior year is 100 and Q1 current year is 150 then the growth should be 150.

Currently what I'm doing is changing my map into a list and then doing the calculation based on the position in the list, but I'm wondering if there is a better way to do this. 

Any thoughts?
 
for (PivotTimeSeries_Class.PivotRowWrapper wrapper :partialRowList) {
            List<decimal> salesList = new List<decimal>();
            for (string period:periodYearList) {
                salesList.add(wrapper.amountMap.get(period));
            }
        	map<string, decimal> growthMap = new map<string, decimal>();
            decimal Y1Total;
            decimal Y2Total;
            decimal q1Growth;
            decimal q2Growth;
            decimal q3Growth;
            decimal q4Growth;
            decimal YGrowth;
            
            Y1Total = salesList[0] + salesList[1] + salesList[2] + salesList[3];
            Y2Total = salesList[5] + salesList[6] + salesList[7] + salesList[8];

            wrapper.amountMap.put('Y1 Total', Y1Total);
            wrapper.amountMap.put('Y2 Total', Y2Total);
            if (salesList[0] != 0 && salesList[0] != NULL && salesList[4] != 0 && salesList[4] != NULL) { q1Growth = salesList[4]/salesList[0]*100 -100; } else { q1Growth = 0; } growthMap.put('P1Growth', q1Growth); 
            if (salesList[1] != 0 && salesList[1] != NULL && salesList[5] != 0 && salesList[5] != NULL) { q2Growth = salesList[5]/salesList[1]*100 -100; } else { q2Growth = 0; } growthMap.put('P2Growth', q2Growth); 
            if (salesList[2] != 0 && salesList[2] != NULL && salesList[6] != 0 && salesList[6] != NULL) { q3Growth = salesList[6]/salesList[2]*100 -100; } else { q3Growth = 0; } growthMap.put('P3Growth', q3Growth); 
            if (salesList[3] != 0 && salesList[3] != NULL && salesList[7] != 0 && salesList[7] != NULL) { q4Growth = salesList[7]/salesList[3]*100 -100; } else { q4Growth = 0; } growthMap.put('P4Growth', q4Growth); 
            if (Y1Total != 0 && Y2Total != 0) { YGrowth = Y2Total / Y1TOtal*100 -100; system.debug ('firing'); } else { YGrowth = 0; } growthMap.put('YoY Growth', YGrowth);
            system.debug('YGrowth = ' +YGrowth);
            sortList.add(new SortWrapper(new CompleteRowWrapper(wrapper, growthMap)));

        }
        sortList.sort();
        for (SortWrapper sorted:sortList) {
            CompleteRowList.add(sorted.wrapper);
        }

 
I have the following code, but when I open this VF I just receive the error: The value 'null' is not valid for operator '>'

I really dont know what I'm missing, I think its related with pageBlockTable.

Thanks in advance.
 
<apex:page StandardController="Opportunity" contenttype="application/pdf" renderAs="pdf">
<apex:stylesheet value="{!$Resource.landscape}"/>

    <apex:pageBlock >
 	<apex:form >
        <apex:variable var="i" value="{!0}"/>
    		<apex:pageBlockTable value="{!Opportunity.OpportunityLineItems}" rendered="{!OR(ISNULL(Opportunity.Desconto__c),Opportunity.Desconto__c=0)}" var="oli" cellpadding="4" style="font-size:14px" border="0">
                <apex:column > 
                	 <apex:variable var="i" value="{!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, i+1, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, i+1, i))}"/>
                 </apex:column>
			<apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;" headerValue="Código"><apex:outputText >{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.productcode, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.productcode, null))}</apex:outputText></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;" headerValue="Descrição">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.name, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.name, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;" headerValue="Fabricante">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.Fabricante__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.Fabricante__c, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;" headerValue="ANVISA">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.ANVISA__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.ANVISA__c, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;text-align:center;" headerValue="Fornecedor">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.Representante_nacional__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.Representante_nacional__c, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;text-align:center" headerValue="Qtde"><apex:outputText value="{0,number, integer}"><apex:param value="{!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, oli.Quantidade_cotada__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.Quantidade_consumida__c, null))}"/></apex:outputText></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;" headerValue="Preço"><apex:outputText value="R${!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, IF(oli.UnitPrice >= 1000000,TEXT(FLOOR(oli.UnitPrice / 1000000)) & ".","") & IF(oli.UnitPrice >= 1000,RIGHT(TEXT(FLOOR(oli.UnitPrice / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.UnitPrice)), 3) & "," & IF(MOD(oli.UnitPrice , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.UnitPrice , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.UnitPrice , 1), 2) * 100, 99))), IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, IF(oli.UnitPrice >= 1000000,TEXT(FLOOR(oli.UnitPrice / 1000000)) & ".","") & IF(oli.UnitPrice >= 1000,RIGHT(TEXT(FLOOR(oli.UnitPrice / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.UnitPrice)), 3) & "," & IF(MOD(oli.UnitPrice , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.UnitPrice , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.UnitPrice , 1), 2) * 100, 99))), null))}" /></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;" headerValue="Valor"><apex:outputText value="R${!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, IF(oli.Total_cotado__c >= 1000000,TEXT(FLOOR(oli.Total_cotado__c / 1000000)) & ".","") & IF(oli.Total_cotado__c >= 1000,RIGHT(TEXT(FLOOR(oli.Total_cotado__c / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.Total_cotado__c)), 3) & "," & IF(MOD(oli.Total_cotado__c , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.Total_cotado__c , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.Total_cotado__c , 1), 2) * 100, 99))), IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, IF(oli.Total_consumido__c >= 1000000,TEXT(FLOOR(oli.Total_consumido__c / 1000000)) & ".","") & IF(oli.Total_consumido__c >= 1000,RIGHT(TEXT(FLOOR(oli.Total_consumido__c / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.Total_consumido__c)), 3) & "," & IF(MOD(oli.Total_consumido__c , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.Total_consumido__c , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.Total_consumido__c , 1), 2) * 100, 99))), null))}"/></apex:column>
                 
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;" headerValue="Código"><apex:outputText >{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.productcode, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.productcode, null))}</apex:outputText></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;" headerValue="Descrição">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.name, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.name, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;" headerValue="Fabricante">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.Fabricante__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.Fabricante__c, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;" headerValue="ANVISA">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.ANVISA__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.ANVISA__c, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;text-align:center;" headerValue="Fornecedor">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.Representante_nacional__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.Representante_nacional__c, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;text-align:center;" headerValue="Qtde"><apex:outputText value="{0,number, integer}"><apex:param value="{!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, oli.Quantidade_cotada__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.Quantidade_consumida__c, null))}"/></apex:outputText></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;" headerValue="Preço"><apex:outputText value="R${!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, IF(oli.UnitPrice >= 1000000,TEXT(FLOOR(oli.UnitPrice / 1000000)) & ".","") & IF(oli.UnitPrice >= 1000,RIGHT(TEXT(FLOOR(oli.UnitPrice / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.UnitPrice)), 3) & "," & IF(MOD(oli.UnitPrice , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.UnitPrice , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.UnitPrice , 1), 2) * 100, 99))), IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, IF(oli.UnitPrice >= 1000000,TEXT(FLOOR(oli.UnitPrice / 1000000)) & ".","") & IF(oli.UnitPrice >= 1000,RIGHT(TEXT(FLOOR(oli.UnitPrice / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.UnitPrice)), 3) & "," & IF(MOD(oli.UnitPrice , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.UnitPrice , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.UnitPrice , 1), 2) * 100, 99))), null))}" /></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;" headerValue="Valor"><apex:outputText value="R${!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, IF(oli.Total_cotado__c >= 1000000,TEXT(FLOOR(oli.Total_cotado__c / 1000000)) & ".","") & IF(oli.Total_cotado__c >= 1000,RIGHT(TEXT(FLOOR(oli.Total_cotado__c / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.Total_cotado__c)), 3) & "," & IF(MOD(oli.Total_cotado__c , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.Total_cotado__c , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.Total_cotado__c , 1), 2) * 100, 99))), IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, IF(oli.Total_consumido__c >= 1000000,TEXT(FLOOR(oli.Total_consumido__c / 1000000)) & ".","") & IF(oli.Total_consumido__c >= 1000,RIGHT(TEXT(FLOOR(oli.Total_consumido__c / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.Total_consumido__c)), 3) & "," & IF(MOD(oli.Total_consumido__c , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.Total_consumido__c , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.Total_consumido__c , 1), 2) * 100, 99))), null))}"/></apex:column>
			</apex:pageBlockTable>
        
<!-- Se não tem desconto, é a lista relacionada de cima, se sim é o de baixo -->
        
        
             <apex:pageBlockTable value="{!Opportunity.OpportunityLineItems}" rendered="{!NOT(OR(ISNULL(Opportunity.Desconto__c),Opportunity.Desconto__c=0))}" var="oli" cellpadding="4" style="font-size:14px" border="0">
                 <apex:column > 
                 	<apex:variable var="i" value="{!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, i+1, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, i+1, i))}"/>
                 </apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;" headerValue="Código"><apex:outputText >{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.productcode, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.productcode, null))}</apex:outputText></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;" headerValue="Descrição">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.name, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.name, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;" headerValue="{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO','Fabricante','Lote')}">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.Fabricante__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.Fabricante__c, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;" headerValue="ANVISA">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.ANVISA__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.ANVISA__c, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;text-align:center;" headerValue="Fornecedor">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.Representante_nacional__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.Representante_nacional__c, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;text-align:center" headerValue="Qtde"><apex:outputText value="{0,number, integer}"><apex:param value="{!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, oli.Quantidade_cotada__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.Quantidade_consumida__c, null))}"/></apex:outputText></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;" headerValue="Preço Lista"><apex:outputText value="R${!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, IF(oli.UnitPrice >= 1000000,TEXT(FLOOR(oli.UnitPrice / 1000000)) & ".","") & IF(oli.UnitPrice >= 1000,RIGHT(TEXT(FLOOR(oli.UnitPrice / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.UnitPrice)), 3) & "," & IF(MOD(oli.UnitPrice , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.UnitPrice , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.UnitPrice , 1), 2) * 100, 99))), IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, IF(oli.UnitPrice >= 1000000,TEXT(FLOOR(oli.UnitPrice / 1000000)) & ".","") & IF(oli.UnitPrice >= 1000,RIGHT(TEXT(FLOOR(oli.UnitPrice / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.UnitPrice)), 3) & "," & IF(MOD(oli.UnitPrice , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.UnitPrice , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.UnitPrice , 1), 2) * 100, 99))), null))}" /></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;text-align:center;" headerValue="Desc"><apex:outputText value="{0,number,percent}"><apex:param value="{!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, oli.Discount/100, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.Discount/100, null))}" /></apex:outputText></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;" headerValue="Preço Desconto"><apex:outputText value="R${!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, oli.Valor_cotado__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.Valor_consumido__c, null))}"/></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 0, true, false)}" style="background:#edf9fc;" headerValue="Valor"><apex:outputText value="R${!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, IF(oli.Total_cotado__c >= 1000000,TEXT(FLOOR(oli.Total_cotado__c / 1000000)) & ".","") & IF(oli.Total_cotado__c >= 1000,RIGHT(TEXT(FLOOR(oli.Total_cotado__c / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.Total_cotado__c)), 3) & "," & IF(MOD(oli.Total_cotado__c , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.Total_cotado__c , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.Total_cotado__c , 1), 2) * 100, 99))), IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, IF(oli.Total_consumido__c >= 1000000,TEXT(FLOOR(oli.Total_consumido__c / 1000000)) & ".","") & IF(oli.Total_consumido__c >= 1000,RIGHT(TEXT(FLOOR(oli.Total_consumido__c / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.Total_consumido__c)), 3) & "," & IF(MOD(oli.Total_consumido__c , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.Total_consumido__c , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.Total_consumido__c , 1), 2) * 100, 99))), null))}"/></apex:column>
                 
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;" headerValue="Código"><apex:outputText >{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.productcode, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.productcode, null))}</apex:outputText></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;" headerValue="Descrição">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.name, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.name, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;" headerValue="{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO','Fabricante','Lote')}">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.Fabricante__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.Fabricante__c, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;" headerValue="ANVISA">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.ANVISA__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.ANVISA__c, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;text-align:center;" headerValue="Fornecedor">{!IF(Opportunity.pdfPre_Pos__c = 'COTAÇÃO' && oli.Quantidade_cotada__c>0, oli.PricebookEntry.Product2.Representante_nacional__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.PricebookEntry.Product2.Representante_nacional__c, null))}</apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;text-align:center;" headerValue="Qtde"><apex:outputText value="{0,number, integer}"><apex:param value="{!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, oli.Quantidade_cotada__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.Quantidade_consumida__c, null))}"/></apex:outputText></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;" headerValue="Preço Lista"><apex:outputText value="R${!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, IF(oli.UnitPrice >= 1000000,TEXT(FLOOR(oli.UnitPrice / 1000000)) & ".","") & IF(oli.UnitPrice >= 1000,RIGHT(TEXT(FLOOR(oli.UnitPrice / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.UnitPrice)), 3) & "," & IF(MOD(oli.UnitPrice , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.UnitPrice , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.UnitPrice , 1), 2) * 100, 99))), IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, IF(oli.UnitPrice >= 1000000,TEXT(FLOOR(oli.UnitPrice / 1000000)) & ".","") & IF(oli.UnitPrice >= 1000,RIGHT(TEXT(FLOOR(oli.UnitPrice / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.UnitPrice)), 3) & "," & IF(MOD(oli.UnitPrice , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.UnitPrice , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.UnitPrice , 1), 2) * 100, 99))), null))}" /></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;text-align:center;" headerValue="Desc"><apex:outputText value="{0,number,percent}"><apex:param value="{!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, oli.Discount/100, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.Discount/100, null))}" /></apex:outputText></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;" headerValue="Preço Desconto"><apex:outputText value="R${!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, oli.Valor_cotado__c, IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, oli.Valor_consumido__c, null))}"/></apex:column>
                <apex:column rendered="{!IF((mod(i,2)) == 1, true, false)}" style="background:#cdf9eb;" headerValue="Valor"><apex:outputText value="R${!IF(Opportunity.pdfPre_Pos__c="COTAÇÃO" && oli.Quantidade_cotada__c>0, IF(oli.Total_cotado__c >= 1000000,TEXT(FLOOR(oli.Total_cotado__c / 1000000)) & ".","") & IF(oli.Total_cotado__c >= 1000,RIGHT(TEXT(FLOOR(oli.Total_cotado__c / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.Total_cotado__c)), 3) & "," & IF(MOD(oli.Total_cotado__c , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.Total_cotado__c , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.Total_cotado__c , 1), 2) * 100, 99))), IF(Opportunity.pdfPre_Pos__c = 'PÓS' && oli.Quantidade_consumida__c>0, IF(oli.Total_consumido__c >= 1000000,TEXT(FLOOR(oli.Total_consumido__c / 1000000)) & ".","") & IF(oli.Total_consumido__c >= 1000,RIGHT(TEXT(FLOOR(oli.Total_consumido__c / 1000)), 3) & ".","") & RIGHT(TEXT(FLOOR(oli.Total_consumido__c)), 3) & "," & IF(MOD(oli.Total_consumido__c , 1) * 100 < 10,"0" & TEXT(ROUND(MOD(oli.Total_consumido__c , 1), 2) * 100),TEXT(MIN(ROUND(MOD(oli.Total_consumido__c , 1), 2) * 100, 99))), null))}"/></apex:column>
                </apex:pageBlockTable>
        <br/>
            <apex:panelGrid columns="2" style="float:right;">
                <apex:outputText escape="false" value="<b>VALOR TOTAL:</b> "></apex:outputText><apex:outputText escape="false" value="R${!IF( 
  Opportunity.Valor_cotado__c >= 1000000, 
  TEXT(FLOOR(Opportunity.Valor_cotado__c / 1000000)) & ".", 
  "") & 
IF( 
  Opportunity.Valor_cotado__c >= 1000, 
  RIGHT(TEXT(FLOOR(Opportunity.Valor_cotado__c / 1000)), 3) & ".", 
  "") & 
RIGHT(TEXT(FLOOR(Opportunity.Valor_cotado__c)), 3) & "," & 
IF( 
  MOD(Opportunity.Valor_cotado__c , 1) * 100 < 10, 
  "0" & TEXT(ROUND(MOD(Opportunity.Valor_cotado__c , 1), 2) * 100), 
  TEXT(MIN(ROUND(MOD(Opportunity.Valor_cotado__c , 1), 2) * 100, 99)) 
)}"/>
                <apex:outputText escape="false" value="<b>Prazo de pagamento:</b> {!Opportunity.Prazo__r.name}"/>
            </apex:panelGrid>
        </apex:form> 
        <br/><br/>
        
        <apex:outputText escape="false" value="<b>Observação: </b>{!Opportunity.Coment_rios_da_Cota_o__c}" rendered="{!NOT(ISNULL(Opportunity.Coment_rios_da_Cota_o__c))}"/><br/>
        
        
        </apex:pageBlock>
</apex:page>

 
Lets say I have Id of Account record and I am initializing the sobject and assigning the Id to account variable. Below is the code :
sObject obj = Schema.getGlobalDescribe().get(parentObjName).newSObject() ;
obj.Id = recordId;
System.debug('****obj : '+obj);
Debug Result: 
****obj : Account:{Id=0019000001dbup5AAA}
I was hoping that the debug will have the entire information from the account example like : Account:{Id=0019000001dbup5AAA, Name=TestAccount,...}
Is there any way to initialize the sobject in a way such that it gets loaded with the entire information?