• Adeel Ahmad 17
  • NEWBIE
  • 0 Points
  • Member since 2016


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
HI

Can any one help me out in getting total count of opportunites between this years 2010 to 2016 which also needs accountname.

Thanks in Advance
select id, Name, (Select id, Accountid, Createddate, stageName From Opportunities) From Account where stageName = '6 - Closed Won' AND createdDate > 2010-01-01T00:00:00Z and createdDate < 2016-01-31T23:59:59Z

 
I have a VisualForce page that has Two input fields with onchange actions that if I were type a currency value into a field it will update the other input field and then immediately click save will re-calculate and do the onchange event before the save of the record happens. **Mind you if I click out of the field before immediately clicking save it will calculate and save the record.
My VF page:
 
<apex:page standardController="EventPackageRevenueBreakdown__c"
	extensions="EventPackageRevenueBreakdownExt" standardStylesheets="true"
	tabstyle="EventPackageRevenueBreakdown__c" docType="html-5.0">
<apex:form >
		<apex:sectionHeader title="{!$ObjectType.EventPackageRevenueBreakdown__c.label} {!$Label.Edit}"
			subtitle="{!EventPackageRevenueBreakdown__c.Name}"
			help="{!$Label.NIBaseHelpURL}#cshid= event_package_revenue_breakdown_edit">
		</apex:sectionHeader>
		<apex:pageBlock mode="edit"
			title="{!$ObjectType.EventPackageRevenueBreakdown__c.label} {!$Label.Edit}">
			<apex:pageblockbuttons >
				<apex:commandbutton action="{!save}" value="{!$Label.Package_Save}"></apex:commandbutton>
				<apex:commandbutton action="{!SaveAndNew}"
					value="{!$Label.Package_SaveAndNew}"></apex:commandbutton>
				<apex:commandbutton action="{!cancel}"
					value="{!$Label.Package_Cancel}"></apex:commandbutton>
			</apex:pageblockbuttons>
			<apex:pagemessages ></apex:pagemessages>
			<apex:pageblocksection title="{!$Label.Package_Information}"
				id="block123">
				<apex:actionFunction name="UpdateInclusivePrice"
					action="{!UpdateInclusivePrice}" rerender="block123"></apex:actionFunction>
				<apex:actionFunction name="UpdateUnitPrice"
					action="{!UpdateUnitPrice}" rerender="block123"></apex:actionFunction>
				<apex:actionFunction name="CalculateInclusive"
					action="{!CalculateInclusive}" rerender="block123"></apex:actionFunction>
				<apex:outputpanel layout="block" styleClass="requiredBlock"></apex:outputpanel>
				<apex:inputField required="false" value="{!EventPackageRevenueBreakdown__c.UnitPrice__c}"
					label="{!IF(showInclusivePrices, $Label.ExclPrice, $ObjectType.EventPackageRevenueBreakdown__c.fields.UnitPrice__c.label)}"
					 onchange="UpdateInclusivePrice()" onkeypress="enterPress(event, 'inclusive')">
				</apex:inputField>
				<apex:inputfield required="false"
					value="{!EventPackageRevenueBreakdown__c.Location__c}"></apex:inputfield>
				<apex:pageBlockSectionItem rendered="{!NOT(showInclusivePrices)}">
				</apex:pageBlockSectionItem>
				<apex:pageBlockSectionItem rendered="{!showInclusivePrices}">
					<apex:outputLabel value="{!$Label.InclPrice}"></apex:outputLabel>
					<apex:inputField required="false" styleClass="test" value="{!EventPackageRevenueBreakdown__c.InclusiveUnitPrice__c}"
						onChange="UpdateUnitPrice()" onkeypress="enterPress(event, 'exclusive')"></apex:inputField>
				</apex:pageBlockSectionItem>
				<apex:outputfield value="{!EventPackageRevenueBreakdown__c.BookingPackageEvent__c}" />
			<apex:pageblocksectionitem >
					<apex:outputlabel >{!$ObjectType.EventPackageRevenueBreakdown__c.fields.RevenueClassification__c.label}</apex:outputlabel>
					<apex:outputpanel layout="block" styleClass="requiredInput">
						<apex:outputpanel layout="block" styleClass="requiredBlock"></apex:outputpanel>
						<apex:inputfield value="{!EventPackageRevenueBreakdown__c.RevenueClassification__c}"
							onChange="CalculateInclusive()">
						</apex:inputfield>
					</apex:outputpanel>
				</apex:pageblocksectionitem>
			</apex:pageblocksection>
			<apex:pageblocksection title="{!$Label.AdminChargeAndGratuity}">
				<apex:inputfield required="false"
					value="{!EventPackageRevenueBreakdown__c.AdminCharge__c}"
					onChange="CalculateInclusive()"></apex:inputfield>
				<apex:inputfield required="false"
					value="{!EventPackageRevenueBreakdown__c.Gratuity__c}"
					onChange="CalculateInclusive()"></apex:inputfield>
			</apex:pageblocksection>
			<apex:pageblocksection title="{!$Label.InclusivePrice}"
				rendered="{!showInclusivePrices}" collapsible="true">
				<apex:inputcheckbox value="{!EventPackageRevenueBreakdown__c.AdminIsIncludedInInclusivePrice__c}"
					onChange="CalculateInclusive()"></apex:inputcheckbox>
				<apex:inputcheckbox value="{!EventPackageRevenueBreakdown__c.GratuityIsIncludedInInclusivePrice__c}"
					onChange="CalculateInclusive()"></apex:inputcheckbox>
			</apex:pageblocksection>
		</apex:pageBlock>
		<apex:actionFunction name="saveInclusive" action="{!saveFromEnterInclusive}"></apex:actionFunction>
		<apex:actionFunction name="saveUnit" action="{!saveFromEnterUnit}"></apex:actionFunction>
	</apex:form>
	<script>
	function enterPress(e, fields)
	{
		if(e.keyCode==13)
		{
			if(e.preventDefault)
			{ 
            	e.preventDefault();
            }
            if(fields == 'inclusive')
            {
            	saveInclusive();
           }
           else
           {
           		saveUnit();
           }
        }        
    }</script>
</apex:page>

My standard Controller
 
public with sharing class EventPackageRevenueBreakdownExt {
    public boolean showInclusivePrices { get; set; }
    
    private ApexPages.standardController sController;
    private decimal price;
    private decimal inclusivePrice;
    private Id taxGroupId;
    private EventPackageRevenueBreakdown__c eprb;
    private QueryTaxGroupSchedule qtgs;
    public EventPackageRevenueBreakdownExt(ApexPages.standardController stdController) {

            //Set showInclusivePrices based on feature toggle
            if (Test.isRunningTest()) {
                showInclusivePrices = true;
            } else {
                NiPublic__c niSettings = NiPublic__c.getOrgDefaults();
                if (niSettings != null) {
                    showInclusivePrices = niSettings.EnableInclusivePrices__c;
                } else {
                    showInclusivePrices = false;
                }
                stdController.addFields(new list<string>{'UnitPrice__c'});
            }
            
            sController = stdController;
            eprb = (EventPackageRevenueBreakdown__c) sController.getRecord();
            
            if(eprb.UnitPrice__c == null){ 	
			eprb.UnitPrice__c = 0.00;}
			
			price = eprb.UnitPrice__c;			
			
            if (ApexPages.currentPage().getParameters().get('BookingPackageEventId') != null) {
                eprb.BookingPackageEvent__c = ApexPages.currentPage().getParameters().get('BookingPackageEventId');
            }

            if (eprb.BookingPackageEvent__c != null) {
            	BookingPackageEvent__c bookingPackageEvent = [Select Location__c, BookingEvent__r.TaxGroup__c From BookingPackageEvent__c Where Id = :eprb.BookingPackageEvent__c Limit 1];
                eprb.Location__c = bookingPackageEvent.Location__c;
                taxGroupId = bookingPackageEvent.BookingEvent__r.TaxGroup__c;
                qtgs = new QueryTaxGroupSchedule(taxGroupId, false);          
            }

            if (eprb.Name == null) {
                eprb.Name = '{AUTO}';
            }
           
            CalculateInclusive();           
    }

    public Pagereference SaveAndNew() {
    	
    	if(this.save() == null){
    		return null;
    	}
    	
        PageReference pageRef = page.NewEventPackageRevenueBreakdown;
        pageRef.getParameters().put('BookingPackageEventId', eprb.BookingPackageEvent__c);
        pageRef.setRedirect(true);
        return pageRef;
    }
    
    public pageReference save() {
    	
    	//throw new ni.niException(string.valueOf(eprb.UnitPrice__c));
    	
        // if the recipient revenue classification is null, add an error to the field
        // and return null to remain on the current page...
        if(eprb.RevenueClassification__c == null) {
            eprb.RevenueClassification__c.addError(label.MustEnterValue);
            return null;
        }
        else {
        	eprb.InclusiveUnitPrice__c = null;
        	eprb.UnitPrice__c = price;
            return sController.save();
        }
    }

    public Pagereference DeleteRecord() {
        string bkgPkgEventId = eprb.BookingPackageEvent__c;
        delete(eprb);
        if (bkgPkgEventId != null) {
            return(new PageReference('/' + bkgPkgEventId));
        } else {
            return(new PageReference('/'));
        }
    }

    public decimal getTotalRate() {       
        decimal totalRate = qtgs.GetInclusiveBaseRate(taxGroupId, eprb.RevenueClassification__c);
        if(eprb.AdminIsIncludedInInclusivePrice__c)
            totalRate += (eprb.AdminCharge__c==null?0: eprb.AdminCharge__c / 100)*(qtgs.GetInclusiveAdminRate(taxGroupId, eprb.RevenueClassification__c));
        if(eprb.GratuityIsIncludedInInclusivePrice__c)
            totalRate += (eprb.Gratuity__c==null?0: eprb.Gratuity__c / 100)*(qtgs.GetInclusiveGratuityRate(taxGroupId, eprb.RevenueClassification__c));
        return totalRate==null?1:totalRate;
    }
 
    public void UpdateInclusivePrice() {
    	price = eprb.UnitPrice__c;	 	 
        CalculateInclusive();
    }
    
    public void UpdateUnitPrice() {   
    	inclusivePrice = eprb.InclusiveUnitPrice__c;	
    	CalculateExclusive();      
    }
    
    public pagereference SaveFromEnterInclusive() {
		UpdateInclusivePrice(); 
		return save();
	}
	
	public pagereference SaveFromEnterUnit() {
		UpdateUnitPrice();
		return save();
	}
    
    public void CalculateInclusive() {
    	inclusivePrice = (price==null?0:price)*(getTotalRate());
    	eprb.UnitPrice__c = (price==null?0:price.setScale(2, RoundingMode.HALF_UP));
    	eprb.InclusiveUnitPrice__c = (inclusivePrice==null?0:inclusivePrice.setScale(2, RoundingMode.HALF_UP));
    }
    
    public void CalculateExclusive() {
    	price = (inclusivePrice==null?0:inclusivePrice)/(getTotalRate());
        eprb.UnitPrice__c = (price==null?0:price.setScale(2, RoundingMode.HALF_UP));
        eprb.InclusiveUnitPrice__c = (inclusivePrice==null?0:inclusivePrice.setScale(2, RoundingMode.HALF_UP));        
    }

}

Any help would greatly be appreciated. I've tried actionsupport immediate false for the save, sending an onclick event to js when save clicked an attempted to prevent the click event, and using onblur as well.
Hello All,
Please help me to know about lightning ,What will work in lightning same as (/apex/pagename?ID=xxx) in classic salesforce. 
I don't want to switch from (one.app) LEX to classic .
So need alternative for calling my VF page from other vf page in ligtning .
Right now i am ussing static Url '/apex/pagename?ID =xxx' on click in JavaScript. Result in LEX :- It is redirected to classic url . but want to open this in lightning UI only.

Thanks In Advance. 
Hi everyone,

I am trying to build out an email template that will not have me select which related to object because it will be predefined within the html code. I don't want to go in and update the fields by writing in the numbers. I need it to grab the field  based off the specific ID that is predefined within the html code.

This is where I am at:

<messaging:emailTemplate recipientType="Contact"
relatedToType="PricebookEntry"

subject="Stock Listings"

replyTo="me@me.com">
<messaging:htmlEmailBody >
<html>
<body>
<style>
<table>

.xl90
    {mso-style-parent:style16;
    color:windowtext;
    font-size:9.0pt;
    font-family:Arial, sans-serif;
    mso-font-charset:0;
    text-align:center;
    vertical-align:middle;
    border-top:none;
    border-right:1.5pt solid black;
    border-bottom:1.5pt solid black;
    border-left:1.5pt solid black;
    white-space:normal;}
.xl91
    {mso-style-parent:style16;
    color:windowtext;
    font-size:9.0pt;
    font-family:Arial, sans-serif;
    mso-font-charset:0;
    mso-number-format:"\#\,\#\#0_\)\;\\\(\#\,\#\#0\\\)";
    text-align:center;
    vertical-align:middle;
    border-top:none;
    border-right:1.5pt solid black;
    border-bottom:1.5pt solid black;
    border-left:1.5pt solid black;
    white-space:normal;}

</table>
</style>
<tbody>

<tr class="xl65535" style="mso-height-source:userset;height:19.0pt" height="19">
<td colspan="2" class="xl96" style="border-right:1.5pt solid black;height:19.0pt;width:146pt" height="19" width="146">Hard Maple First Grade</td>
        <td class="xl90" style="border-left:none;width:65pt" width="65">3-14'</td>
        <td class="xl91" style="border-left:none;width:51pt" width="51">{!relatedto.000000000m00HaX12T.unitPrice}</td>
        <td class="xl91" style="border-left:none;width:51pt" width="51">{!relatedto.000000000m00AD32gT.unitPrice}</td>
<br />
</td>
</tr>
</tbody>
</table>
</html>
</messaging:htmlEmailBody>
<messaging:plainTextEmailBody >
    
</messaging:plainTextEmailBody>  
</messaging:emailTemplate>

Is this even possible to have mulitple IDs being used within the code and how would I grad specific fields so become a static output?