• Jeff_SF
  • NEWBIE
  • 50 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 13
    Replies
I am getting the above error when running a lfow attempting to update a coule hundred records.  The flow runs OK with one record by completing a fast update using a loop.  It fails when the 200 records are updated.  Any suggestions?

thanks
  • September 28, 2017
  • Like
  • 0
AM having some issues deploying a small change for a trigger and adding a new trigger.  I am getting only19% coverage even though a previous developer has written a test class for all triggers a few years ago.  The api version for most triggers and testclass is 18.0.  the new trigger is api version 39.  could this have anything to do with why the coverage is so low?  What would be the best way to remedy this issue.?  Thank you
The same error is not happening in sandbox.  I am atempting to add a trigger and update another.  this same erro is happening on several failed tests.  I am not able to deploy for this reason.

System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_USERNAME, Duplicate Username.<br>The username already exists in this or another Salesforce organization. Usernames must be unique across all Salesforce organizations. To resolve, use a different username (it doesn't need to match the user's email address). : [Username]
I am getting the above error when running a flow to update records In an object.  The same object has a trigger that updates whenever a record is udated.  Is there a work around for this limit issue in this particular instance? I have a couple of flows that will need to update records on this object but the trigger is getting in the way.  thank you
trigger ServiceBillingsTrigger on Service_Billings__c (after delete, after insert, after update) {
 
  Map<String,Special_Services_Sched__c> spcMap = new Map<String,Special_Services_Sched__c>();
  List<Special_Services_Sched__c> spcList = new List<Special_Services_Sched__c>();

  Map<String,Account> acctMap = new Map<String,Account>();
  List<Account> acctList = new List<Account>();
  
  final Product2 prod = [Select Id, Name From Product2 Where RecordTypeId = '012A0000000IqewIAC' And Name = 'JC' LIMIT 1][0];
  final RecordType inSpecsRt = [Select Id From RecordType WHERE SobjectType='Special_Services_Sched__c' AND Name='Specs' LIMIT 1];
  
  if (trigger.isDelete)
  {
      for (Service_Billings__c s : trigger.old) 
      {
      if(s.Cleaner__c != null)
      {
        if(!acctMap.containsKey(s.Cleaner__c))
        {
          Account clnrAcct = new Account(Id=s.Cleaner__c);
          clnrAcct.Active_Service__c = [Select count() 
                          From Service_Billings__c 
                          Where Active__c=true 
                          And Cleaner__c=:s.Cleaner__c];
          AggregateResult[] groupedResults = [Select SUM(Cleaner_Price__c) 
                          From Service_Billings__c 
                          Where Active__c=true 
                          And Cleaner__c=:s.Cleaner__c];
          clnrAcct.Services_Total__c = Double.valueOf(groupedResults[0].get('expr0'));

          acctMap.put(s.Cleaner__c,clnrAcct);
        }
      }

      if(s.Customer__c != null)
      {
        if(!acctMap.containsKey(s.Customer__c))
        {
          Account custAcct = new Account(Id=s.Customer__c);
          custAcct.Active_Service__c = [Select count() 
                          From Service_Billings__c 
                          Where Active__c=true 
                          And Customer__c=:s.Customer__c];
          AggregateResult[] groupedResults = [Select SUM(Customer_Price__c) 
                          From Service_Billings__c 
                          Where Active__c=true 
                          And Customer__c=:s.Customer__c];
          custAcct.Services_Total__c = Double.valueOf(groupedResults[0].get('expr0'));

          acctMap.put(s.Customer__c,custAcct);
        }
        if(s.Active__c)
        {
          if(s.Service__c == prod.Id)
          {
            for(Special_Services_Sched__c spc : [Select Id 
                                From Special_Services_Sched__c 
                                Where Active__c=true 
                                  And RecordTypeId =:inSpecsRt.Id
                                  And Customer__c=:s.Customer__c])
            {
              if(spcMap.containsKey(spc.Id))
                spcMap.remove(spc.Id);
              spc.Service_Billing__c = s.Id;
              spcMap.put(spc.Id,spc);
            }
          }
        }
      } 
      }    
  } else {

    if(Trigger.isUpdate)
    {
      for(integer x = 0; x < trigger.old.size(); x++)
          {
            if(trigger.old[x].LastBilled__c != trigger.new[x].LastBilled__c)
            {
              // billing Cycle Ignore Request.
            } else {
              Service_Billings__c s = trigger.new[x];
          if(s.Cleaner__c != null)
          {
            if(!acctMap.containsKey(s.Cleaner__c))
            {
              Account clnrAcct = new Account(Id=s.Cleaner__c);
              clnrAcct.Active_Service__c = [Select count() 
                              From Service_Billings__c 
                              Where Active__c=true 
                              And Cleaner__c=:s.Cleaner__c];
              AggregateResult[] groupedResults = [Select SUM(Cleaner_Price__c) 
                              From Service_Billings__c 
                              Where Active__c=true 
                              And Cleaner__c=:s.Cleaner__c];
              clnrAcct.Services_Total__c = Double.valueOf(groupedResults[0].get('expr0'));
              
              acctMap.put(s.Cleaner__c,clnrAcct);
            }
          }
    
          if(s.Customer__c != null)
          {
            if(!acctMap.containsKey(s.Customer__c))
            {
              Account custAcct = new Account(Id=s.Customer__c);
              custAcct.Active_Service__c = [Select count() 
                              From Service_Billings__c 
                              Where Active__c=true 
                              And Customer__c=:s.Customer__c];
              AggregateResult[] groupedResults = [Select SUM(Customer_Price__c) 
                              From Service_Billings__c 
                              Where Active__c=true 
                              And Customer__c=:s.Customer__c];
              custAcct.Services_Total__c = Double.valueOf(groupedResults[0].get('expr0'));
              acctMap.put(s.Customer__c,custAcct);
            }    
            if(s.Active__c)
            {
              if(s.Service__c == prod.Id)
              {
                for(Special_Services_Sched__c spc : [Select Id 
                                    From Special_Services_Sched__c 
                                    Where Active__c=true 
                                      And RecordTypeId =:inSpecsRt.Id
                                      And Customer__c=:s.Customer__c])
                {
                  if(spcMap.containsKey(spc.Id))
                    spcMap.remove(spc.Id);
                  spc.Service_Billing__c = s.Id;
                  spcMap.put(spc.Id,spc);
                }
              }
            }
          } 
        }
          }
    }

    if(Trigger.isInsert)
    {    
        for (Service_Billings__c s : trigger.new) 
        {
        if(s.Cleaner__c != null)
        {
          if(!acctMap.containsKey(s.Cleaner__c))
          {
            Account clnrAcct = new Account(Id=s.Cleaner__c);
            clnrAcct.Active_Service__c = [Select count() 
                            From Service_Billings__c 
                            Where Active__c=true 
                            And Cleaner__c=:s.Cleaner__c];
  
            AggregateResult[] groupedResults = [Select SUM(Cleaner_Price__c) 
                            From Service_Billings__c 
                            Where Active__c=true 
                            And Cleaner__c=:s.Cleaner__c];
            clnrAcct.Services_Total__c = Double.valueOf(groupedResults[0].get('expr0'));

            acctMap.put(s.Cleaner__c,clnrAcct);
          }
        }
  
        if(s.Customer__c != null)
        {
          if(!acctMap.containsKey(s.Customer__c))
          {
            Account custAcct = new Account(Id=s.Customer__c);
            custAcct.Active_Service__c = [Select count() 
                            From Service_Billings__c 
                            Where Active__c=true 
                            And Customer__c=:s.Customer__c];
            AggregateResult[] groupedResults = [Select SUM(Customer_Price__c) 
                            From Service_Billings__c 
                            Where Active__c=true 
                            And Customer__c=:s.Customer__c];
            custAcct.Services_Total__c = Double.valueOf(groupedResults[0].get('expr0'));
            acctMap.put(s.Customer__c,custAcct);
          }  
          if(s.Active__c)
          {
            if(s.Service__c == prod.Id)
            {
              for(Special_Services_Sched__c spc : [Select Id 
                                  From Special_Services_Sched__c 
                                  Where Active__c=true 
                                    And RecordTypeId =:inSpecsRt.Id
                                    And Customer__c=:s.Customer__c])
              {
                if(spcMap.containsKey(spc.Id))
                  spcMap.remove(spc.Id);
                spc.Service_Billing__c = s.Id;
                spcMap.put(spc.Id,spc);
              }
            }
          }
        } 
        }
    }
    }
   
     if(!acctMap.isEmpty())
       acctList.addAll(acctMap.values());
    if(acctList.size() > 0)
      update(acctList);
      
    if(!spcMap.isEmpty())
      spcList.addAll(spcMap.values());
  if(spcList.size() > 0)
    update(spcList);
}

 
i am getting an error that is in code. line 287 is the very last line of code.  Any suggestions?
 
<apex:page standardController="Opportunity" renderAs="pdf" sidebar="false" title="Opportunity Quotation">
<apex:composition template="PDF_Header_Template">
    <apex:define name="extraStyle">
<style type="text/css">
.style4 {
    color: #000000;
    font-size: 14px;
    font-weight: bold;
}
#PreparedBy {
    position: absolute;
    width: 77%;
    height: 60px;
    left: 30px;
    top: 145px;
    border: 0px red solid;
}
.ShipAndBillSection {
    position: absolute;
    width: 99%;
    height: 90px;
    left: 5px;
    top: 215px;
    border: 0px blue solid;
}
.ShipAndBill {
    width: 340px;
    height: 90px;
    border: 1px silver solid;
    vertical-align: top;
}
.billToShipToLabel {
    font-size: 12px;
    width: 110px;
    height: 100%;
    vertical-align: top;
}
.addr {
    font-size: 12px;
    width: 450px;
    vertical-align: top;
}
.LineItems {
    position: absolute;
    left: 5px;
    height: 300px;
    top: 330px;
    z-index: 1;
    width: 99%;
    border: 0px green solid;
}
.LineItemsTable {
    width: 100%;
    height: 100%;
    border-top: 0px;
}
.LineItemHeader {
    background-color: gray;
    border: 1px gray solid;
    text-align: right;
}
.TotalColHeader {
    background-color: gray;
    border: 0px gray solid;
    text-align: right;
}
.TotalColRow {
    background-color: silver;
    border-right: 0px silver solid;
    text-align: right;
}
.LineItemCell {
    border-right: 1px silver solid;
    background-color: white;
    text-align: right;
}
#commentBox {
    position: relative;
    left: 100px;
    top: 10px;
    width: 80%;
}
#bottomSection {
    position: absolute;
    top: 770px;
    left: 130px;
    width: 450px;
    border: 0px aqua solid;
}
#ApprovalBlock {
    position: relative;
    left: 0px;
    top: 10px;
    width: 450px;
    border: 0px purple solid;
}
.approvalTable {
    width:100%;
    height:105px;
    border: 0px lime solid;
}
</style>
    </apex:define>
    <apex:define name="PageTitle">{!IF(contains(Opportunity.RecordType.Name,'Addendum'),'WAGE ADJUSTMENT','QUOTATION')}</apex:define>
    <apex:define name="titleBoxInfo">
        <span class="style4"># {!Opportunity.Opportunity_Number__c}</span> <br />
        DATE:&nbsp;&nbsp; <apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!Opportunity.CreatedDate}" /></apex:outputText>
        <br style="line-height:1.3;" />
        <apex:outputText value="VALID UNTIL: {0,date,MM/dd/yyyy}" rendered="{!IF(OR(ISBLANK(Opportunity.Valid_Until__c),ISNULL(Opportunity.Valid_Until__c)),'FALSE','TRUE')}"><apex:param value="{!Opportunity.Valid_Until__c}" /></apex:outputText>
    </apex:define>
</apex:composition>

<div id="PreparedBy">
    <table cellpadding="2" cellspacing="0" width="100%" border="0">
        <tr>
            <td style="width: 75px">Prepared By</td>
            <td colspan="2">{!$User.FirstName & " " & $User.LastName}</td>
        </tr>
        <tr>
            <td>Phone</td>
            <td colspan="2">{!$User.Phone}</td>
        </tr>
        <tr>
            <td>Email</td>
            <td>{!$User.Email}</td>
            <td style="width:300px;text-align:right;">Customer # {!Opportunity.Account.QB_Account_Number__c}</td>
        </tr>
    </table>
</div>
<div id="ShipAndBillSection" class="ShipAndBillSection">
    <table style="width:100%;height:100%;" cellpadding="0" cellspacing="0">
        <tr>
            <td>
            <table cellpadding="0" cellspacing="0" class="ShipAndBill">
                <tr>
                    <td>
                    <table style="width:100%;height:100%;" cellpadding="1" cellspacing="1">
                        <tr>
                            <td rowspan="3" class="billToShipToLabel">BILL TO:</td>
                            <td class="addr">{!IF(Opportunity.Account.RecordType.Name='Service Customer',Opportunity.Account.Parent.Name,Opportunity.Account.Name)}</td>
                        </tr>
                        <tr><td class="addr">{!IF(Opportunity.Account.RecordType.Name='Service Customer',Opportunity.Account.Parent.BillingStreet,Opportunity.Account.BillingStreet)}</td></tr>
                        <tr><td class="addr">{!IF(Opportunity.Account.RecordType.Name='Service Customer',Opportunity.Account.Parent.BillingCity,Opportunity.Account.BillingCity)}, 
                                             {!IF(Opportunity.Account.RecordType.Name='Service Customer',Opportunity.Account.Parent.BillingState,Opportunity.Account.BillingState)} 
                                             {!IF(Opportunity.Account.RecordType.Name='Service Customer',Opportunity.Account.Parent.BillingPostalCode,Opportunity.Account.BillingPostalCode)}
                            </td>
                        </tr>
                    </table>
                    </td>
                </tr>
            </table>
            </td>
            <td style="width: 30px;">&nbsp;</td>
            <td>
            <table cellpadding="0" cellspacing="0" class="ShipAndBill">
                <tr>
                    <td style="vertical-align: top;">
                    <table style="width:100%;height:100%;" cellpadding="1" cellspacing="1">
                        <tr>
                            <td rowspan="5" class="billToShipToLabel">SERVICE AT:</td>
                            <td class="addr">{!Opportunity.Account.Name}</td>
                        </tr>
                        <tr><td class="addr">{!Opportunity.Account.ShippingStreet}</td></tr>
                        <tr><td class="addr">{!Opportunity.Account.ShippingCity}, 
                                             {!Opportunity.Account.ShippingState} 
                                             {!Opportunity.Account.ShippingPostalCode}</td></tr>
                        <tr><td class="addr">{!Opportunity.Account.Phone}</td></tr>
                    </table>
                    </td>
                </tr>
            </table>
            </td>
        </tr>
    </table>
</div>
    <c:OpportunitySortedItems value="{!Opportunity}" />
<!-- 
<apex:outputPanel layout="block" styleClass="LineItems" rendered="{!IF(OR(contains(Opportunity.RecordType.Name,'Special Service'),contains(Opportunity.RecordType.Name,'Addendum')),'FALSE','TRUE')}">
    <table class="LineItemsTable" cellpadding="5" cellspacing="0">
        <thead>
            <tr class="LineItemHeader">
                <td style="text-align:left;width:15%;">Product Name</td>
                <td style="text-align:left;width:40%;">Description</td>
                <td style="width:15%;">Sales Price</td>
                <td style="width:15%;">Quantity</td>
                <td style="width:15%;" class="TotalColHeader">Total Price</td>
            </tr>
        </thead>
        <apex:repeat var="line" value="{!Opportunity.OpportunityLineItems}" >
                <tr>
                    <td class="LineItemCell" style="text-align:center;border-bottom:1px silver solid;border-left:1px silver solid;">{!line.PricebookEntry.Name}</td>
                    <td class="LineItemCell" style="text-align:left;border-bottom:1px silver solid;">{!line.Description}</td>
                    <td class="LineItemCell" style="border-bottom:1px silver solid;"><apex:outputText value="{0, number, $###,###.00}">
                          <apex:param value="{!line.UnitPrice}" />
                        </apex:outputText>
                    </td>
                    <td class="LineItemCell" style="border-bottom:1px silver solid;"><apex:outputText value="{0, number, #,###.00}">
                          <apex:param value="{!line.Quantity}" />
                        </apex:outputText>
                    </td>
                    <td class="TotalColRow" style="border-bottom:1px silver solid;"><apex:outputText value="{0, number, $###,###.00}">
                          <apex:param value="{!line.TotalPrice}" />
                        </apex:outputText>
                    </td>
                </tr>
        </apex:repeat>
    <tr><td height="50px" colspan="3" class="LineItemCell" >&nbsp;</td>
        <td class="LineItemCell" style="border-bottom:1px gray solid;">&nbsp;</td>
        <td class="TotalColRow" style="border-bottom:1px gray solid;">&nbsp;</td>
    </tr>
    <tr>
        <td colspan="3" class="LineItemCell" >&nbsp;</td>
        <td class="LineItemCell" style="border-bottom:1px gray solid;" >Grand Total</td>
        <td class="TotalColRow" style="border-bottom:1px gray solid;">
            <apex:outputText value="{0, number, $###,###.00}">
                <apex:param value="{!Opportunity.Amount}" />
            </apex:outputText>
        </td>
    </tr>
    <tr><td colspan="5" align="left" style="padding: 10px 50px 5px 50px;"><div id="commentBox2">{!Opportunity.Quote_Comments__c}</div></td></tr>
</table>
</apex:outputPanel>
<apex:outputPanel layout="block" styleClass="LineItems" rendered="{!IF(OR(contains(Opportunity.RecordType.Name,'Special Service'),contains(Opportunity.RecordType.Name,'Addendum')),'TRUE','FALSE')}">
 <table class="LineItemsTable" cellpadding="5" cellspacing="0">
        <thead>
            <tr class="LineItemHeader">
                <td style="text-align:left;width:5%;">Service</td>
                <td style="text-align:left;width:65%;">Description</td>
                <td style="width:15%;">Sales Price</td>
                <td style="width:15%;"class="TotalColHeader">Total Price</td>
            </tr>
        </thead>
        <apex:repeat var="line" value="{!Opportunity.OpportunityLineItems}" >
                <tr>
                    <td class="LineItemCell" style="text-align:center;border-bottom:1px silver solid;border-left:1px silver solid;">{!line.PricebookEntry.Name}</td>
                    <td class="LineItemCell" style="text-align:left;border-bottom:1px silver solid;">{!line.Description}</td>
                    <td class="LineItemCell" style="border-bottom:1px silver solid;"><apex:outputText value="{0, number, $###,###.00}">
                          <apex:param value="{!line.UnitPrice}" />
                        </apex:outputText>
                    </td>
                    <td class="TotalColRow" style="border-bottom:1px silver solid;"><apex:outputText value="{0, number, $###,###.00}">
                          <apex:param value="{!line.TotalPrice}" />
                        </apex:outputText>
                    </td>
                </tr>
        </apex:repeat>
    <tr><td height="50px" colspan="2" class="LineItemCell" >&nbsp;</td>
        <td class="LineItemCell" style="border-bottom:1px gray solid;">&nbsp;</td>
        <td class="TotalColRow" style="border-bottom:1px gray solid;">&nbsp;</td>
    </tr>
    <tr>
        <td colspan="2" class="LineItemCell" >&nbsp;</td>
        <td class="LineItemCell" style="border-bottom:1px gray solid;" >Grand Total</td>
        <td class="TotalColRow" style="border-bottom:1px gray solid;">
            <apex:outputText value="{0, number, $###,###.00}">
                <apex:param value="{!Opportunity.Amount}" />
            </apex:outputText>
        </td>
    </tr>
    <tr><td colspan="5" align="left" style="padding: 10px 50px 5px 50px;"><div id="commentBox2">{!Opportunity.Quote_Comments__c}</div></td></tr>
</table>
    <div id="commentBox">
    <apex:outputPanel rendered="{!IF(contains(Opportunity.RecordType.Name,'Addendum'),'TRUE','FALSE')}">    
        <br /><br />When signed this Quote will serve as an addendum to the original service agreement and will change the monthly billing to the above stated amount.
    </apex:outputPanel>
    </div>
</apex:outputPanel>
-->
<div id="bottomSection">
    <div id="ReturnMsg" class="rtnMsg">
    The prices, specifications and conditions are satisfactory and are hereby accepted. 
    Square Feat, Inc. is authorized to do these items as specified.  Please line out 
    and initial any line items not needed.</div>
    <div id="ApprovalBlock">
        <table class="approvalTable" cellpadding="0" cellspacing="0">
            <tr><td style="width:75px;">Approved&nbsp;By</td><td style="width:375px;height:20px;border-bottom:1px gray solid;">&nbsp;</td></tr>
            <tr><td>Date</td><td style="height:20px;border-bottom:1px gray solid;">&nbsp;</td></tr>
            <tr><td>Signature</td><td style="height:20px;border-bottom:1px gray solid;">&nbsp;</td></tr>
            <tr style="display:{!IF(OR(contains(Opportunity.RecordType.Name,'Special Service'),contains(Opportunity.RecordType.Name,'Addendum')),'visible','none')}">
            <td>{!IF(contains(Opportunity.RecordType.Name,'Addendum'),'Effective Date','')}{!IF(contains(Opportunity.RecordType.Name,'Special Service'),'Preferred Service Date','')}</td><td style="height:20px;border-bottom:1px gray solid;">&nbsp;</td></tr>
        </table>
    </div>
    <div style="align:center;">PLEASE FAX OR EMAIL BACK APPROVED {!IF(contains(Opportunity.RecordType.Name,'Addendum'),'ADDENDUM','QUOTE')} TO SCHEDULE WORK.</div>
    <br />
    <div style="align:center;font-weight:bold;">Thank you for the opportunity! Visit us on our web site at www.squarefeat.com</div>
</div>
</body>
</apex:page>

 
I would like to display the standard system info on a VF form.  What is the proper format to use for code that will show the created by name and time and last modified by name and time .  thank you
I would like to display the standard system info on a VF form.  What is the format to use for code that will show the created by name and time and last modified by name and time .  thank you
How can a default value be set in a VF page in a long text feild? Currently the default value set in the object feild for comments__c does not populate when the record is entered from the VF page.
 </apex:tab>
                <apex:tab label="Comments" name="CommentsTab" id="tabComments">
                    <apex:pageBlockSection columns="1" id="CommentsPageBlock">
                        <apex:outputField value="{!Inspection__c.Comments__c}" id="Comments" />
                    </apex:pageBlockSection>
                </apex:tab>
 

Would like to have text formula function to convert a currency field in a salesforce object to another field in  Written English.  For example $100.00 to "One hundred dollars and zero cents".  It would be similar to this Microsoft code:

 

Number to Words/Text

 

Thanks

Jeff

The same error is not happening in sandbox.  I am atempting to add a trigger and update another.  this same erro is happening on several failed tests.  I am not able to deploy for this reason.

System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_USERNAME, Duplicate Username.<br>The username already exists in this or another Salesforce organization. Usernames must be unique across all Salesforce organizations. To resolve, use a different username (it doesn't need to match the user's email address). : [Username]
I am getting the above error when running a flow to update records In an object.  The same object has a trigger that updates whenever a record is udated.  Is there a work around for this limit issue in this particular instance? I have a couple of flows that will need to update records on this object but the trigger is getting in the way.  thank you
trigger ServiceBillingsTrigger on Service_Billings__c (after delete, after insert, after update) {
 
  Map<String,Special_Services_Sched__c> spcMap = new Map<String,Special_Services_Sched__c>();
  List<Special_Services_Sched__c> spcList = new List<Special_Services_Sched__c>();

  Map<String,Account> acctMap = new Map<String,Account>();
  List<Account> acctList = new List<Account>();
  
  final Product2 prod = [Select Id, Name From Product2 Where RecordTypeId = '012A0000000IqewIAC' And Name = 'JC' LIMIT 1][0];
  final RecordType inSpecsRt = [Select Id From RecordType WHERE SobjectType='Special_Services_Sched__c' AND Name='Specs' LIMIT 1];
  
  if (trigger.isDelete)
  {
      for (Service_Billings__c s : trigger.old) 
      {
      if(s.Cleaner__c != null)
      {
        if(!acctMap.containsKey(s.Cleaner__c))
        {
          Account clnrAcct = new Account(Id=s.Cleaner__c);
          clnrAcct.Active_Service__c = [Select count() 
                          From Service_Billings__c 
                          Where Active__c=true 
                          And Cleaner__c=:s.Cleaner__c];
          AggregateResult[] groupedResults = [Select SUM(Cleaner_Price__c) 
                          From Service_Billings__c 
                          Where Active__c=true 
                          And Cleaner__c=:s.Cleaner__c];
          clnrAcct.Services_Total__c = Double.valueOf(groupedResults[0].get('expr0'));

          acctMap.put(s.Cleaner__c,clnrAcct);
        }
      }

      if(s.Customer__c != null)
      {
        if(!acctMap.containsKey(s.Customer__c))
        {
          Account custAcct = new Account(Id=s.Customer__c);
          custAcct.Active_Service__c = [Select count() 
                          From Service_Billings__c 
                          Where Active__c=true 
                          And Customer__c=:s.Customer__c];
          AggregateResult[] groupedResults = [Select SUM(Customer_Price__c) 
                          From Service_Billings__c 
                          Where Active__c=true 
                          And Customer__c=:s.Customer__c];
          custAcct.Services_Total__c = Double.valueOf(groupedResults[0].get('expr0'));

          acctMap.put(s.Customer__c,custAcct);
        }
        if(s.Active__c)
        {
          if(s.Service__c == prod.Id)
          {
            for(Special_Services_Sched__c spc : [Select Id 
                                From Special_Services_Sched__c 
                                Where Active__c=true 
                                  And RecordTypeId =:inSpecsRt.Id
                                  And Customer__c=:s.Customer__c])
            {
              if(spcMap.containsKey(spc.Id))
                spcMap.remove(spc.Id);
              spc.Service_Billing__c = s.Id;
              spcMap.put(spc.Id,spc);
            }
          }
        }
      } 
      }    
  } else {

    if(Trigger.isUpdate)
    {
      for(integer x = 0; x < trigger.old.size(); x++)
          {
            if(trigger.old[x].LastBilled__c != trigger.new[x].LastBilled__c)
            {
              // billing Cycle Ignore Request.
            } else {
              Service_Billings__c s = trigger.new[x];
          if(s.Cleaner__c != null)
          {
            if(!acctMap.containsKey(s.Cleaner__c))
            {
              Account clnrAcct = new Account(Id=s.Cleaner__c);
              clnrAcct.Active_Service__c = [Select count() 
                              From Service_Billings__c 
                              Where Active__c=true 
                              And Cleaner__c=:s.Cleaner__c];
              AggregateResult[] groupedResults = [Select SUM(Cleaner_Price__c) 
                              From Service_Billings__c 
                              Where Active__c=true 
                              And Cleaner__c=:s.Cleaner__c];
              clnrAcct.Services_Total__c = Double.valueOf(groupedResults[0].get('expr0'));
              
              acctMap.put(s.Cleaner__c,clnrAcct);
            }
          }
    
          if(s.Customer__c != null)
          {
            if(!acctMap.containsKey(s.Customer__c))
            {
              Account custAcct = new Account(Id=s.Customer__c);
              custAcct.Active_Service__c = [Select count() 
                              From Service_Billings__c 
                              Where Active__c=true 
                              And Customer__c=:s.Customer__c];
              AggregateResult[] groupedResults = [Select SUM(Customer_Price__c) 
                              From Service_Billings__c 
                              Where Active__c=true 
                              And Customer__c=:s.Customer__c];
              custAcct.Services_Total__c = Double.valueOf(groupedResults[0].get('expr0'));
              acctMap.put(s.Customer__c,custAcct);
            }    
            if(s.Active__c)
            {
              if(s.Service__c == prod.Id)
              {
                for(Special_Services_Sched__c spc : [Select Id 
                                    From Special_Services_Sched__c 
                                    Where Active__c=true 
                                      And RecordTypeId =:inSpecsRt.Id
                                      And Customer__c=:s.Customer__c])
                {
                  if(spcMap.containsKey(spc.Id))
                    spcMap.remove(spc.Id);
                  spc.Service_Billing__c = s.Id;
                  spcMap.put(spc.Id,spc);
                }
              }
            }
          } 
        }
          }
    }

    if(Trigger.isInsert)
    {    
        for (Service_Billings__c s : trigger.new) 
        {
        if(s.Cleaner__c != null)
        {
          if(!acctMap.containsKey(s.Cleaner__c))
          {
            Account clnrAcct = new Account(Id=s.Cleaner__c);
            clnrAcct.Active_Service__c = [Select count() 
                            From Service_Billings__c 
                            Where Active__c=true 
                            And Cleaner__c=:s.Cleaner__c];
  
            AggregateResult[] groupedResults = [Select SUM(Cleaner_Price__c) 
                            From Service_Billings__c 
                            Where Active__c=true 
                            And Cleaner__c=:s.Cleaner__c];
            clnrAcct.Services_Total__c = Double.valueOf(groupedResults[0].get('expr0'));

            acctMap.put(s.Cleaner__c,clnrAcct);
          }
        }
  
        if(s.Customer__c != null)
        {
          if(!acctMap.containsKey(s.Customer__c))
          {
            Account custAcct = new Account(Id=s.Customer__c);
            custAcct.Active_Service__c = [Select count() 
                            From Service_Billings__c 
                            Where Active__c=true 
                            And Customer__c=:s.Customer__c];
            AggregateResult[] groupedResults = [Select SUM(Customer_Price__c) 
                            From Service_Billings__c 
                            Where Active__c=true 
                            And Customer__c=:s.Customer__c];
            custAcct.Services_Total__c = Double.valueOf(groupedResults[0].get('expr0'));
            acctMap.put(s.Customer__c,custAcct);
          }  
          if(s.Active__c)
          {
            if(s.Service__c == prod.Id)
            {
              for(Special_Services_Sched__c spc : [Select Id 
                                  From Special_Services_Sched__c 
                                  Where Active__c=true 
                                    And RecordTypeId =:inSpecsRt.Id
                                    And Customer__c=:s.Customer__c])
              {
                if(spcMap.containsKey(spc.Id))
                  spcMap.remove(spc.Id);
                spc.Service_Billing__c = s.Id;
                spcMap.put(spc.Id,spc);
              }
            }
          }
        } 
        }
    }
    }
   
     if(!acctMap.isEmpty())
       acctList.addAll(acctMap.values());
    if(acctList.size() > 0)
      update(acctList);
      
    if(!spcMap.isEmpty())
      spcList.addAll(spcMap.values());
  if(spcList.size() > 0)
    update(spcList);
}

 
i am getting an error that is in code. line 287 is the very last line of code.  Any suggestions?
 
<apex:page standardController="Opportunity" renderAs="pdf" sidebar="false" title="Opportunity Quotation">
<apex:composition template="PDF_Header_Template">
    <apex:define name="extraStyle">
<style type="text/css">
.style4 {
    color: #000000;
    font-size: 14px;
    font-weight: bold;
}
#PreparedBy {
    position: absolute;
    width: 77%;
    height: 60px;
    left: 30px;
    top: 145px;
    border: 0px red solid;
}
.ShipAndBillSection {
    position: absolute;
    width: 99%;
    height: 90px;
    left: 5px;
    top: 215px;
    border: 0px blue solid;
}
.ShipAndBill {
    width: 340px;
    height: 90px;
    border: 1px silver solid;
    vertical-align: top;
}
.billToShipToLabel {
    font-size: 12px;
    width: 110px;
    height: 100%;
    vertical-align: top;
}
.addr {
    font-size: 12px;
    width: 450px;
    vertical-align: top;
}
.LineItems {
    position: absolute;
    left: 5px;
    height: 300px;
    top: 330px;
    z-index: 1;
    width: 99%;
    border: 0px green solid;
}
.LineItemsTable {
    width: 100%;
    height: 100%;
    border-top: 0px;
}
.LineItemHeader {
    background-color: gray;
    border: 1px gray solid;
    text-align: right;
}
.TotalColHeader {
    background-color: gray;
    border: 0px gray solid;
    text-align: right;
}
.TotalColRow {
    background-color: silver;
    border-right: 0px silver solid;
    text-align: right;
}
.LineItemCell {
    border-right: 1px silver solid;
    background-color: white;
    text-align: right;
}
#commentBox {
    position: relative;
    left: 100px;
    top: 10px;
    width: 80%;
}
#bottomSection {
    position: absolute;
    top: 770px;
    left: 130px;
    width: 450px;
    border: 0px aqua solid;
}
#ApprovalBlock {
    position: relative;
    left: 0px;
    top: 10px;
    width: 450px;
    border: 0px purple solid;
}
.approvalTable {
    width:100%;
    height:105px;
    border: 0px lime solid;
}
</style>
    </apex:define>
    <apex:define name="PageTitle">{!IF(contains(Opportunity.RecordType.Name,'Addendum'),'WAGE ADJUSTMENT','QUOTATION')}</apex:define>
    <apex:define name="titleBoxInfo">
        <span class="style4"># {!Opportunity.Opportunity_Number__c}</span> <br />
        DATE:&nbsp;&nbsp; <apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!Opportunity.CreatedDate}" /></apex:outputText>
        <br style="line-height:1.3;" />
        <apex:outputText value="VALID UNTIL: {0,date,MM/dd/yyyy}" rendered="{!IF(OR(ISBLANK(Opportunity.Valid_Until__c),ISNULL(Opportunity.Valid_Until__c)),'FALSE','TRUE')}"><apex:param value="{!Opportunity.Valid_Until__c}" /></apex:outputText>
    </apex:define>
</apex:composition>

<div id="PreparedBy">
    <table cellpadding="2" cellspacing="0" width="100%" border="0">
        <tr>
            <td style="width: 75px">Prepared By</td>
            <td colspan="2">{!$User.FirstName & " " & $User.LastName}</td>
        </tr>
        <tr>
            <td>Phone</td>
            <td colspan="2">{!$User.Phone}</td>
        </tr>
        <tr>
            <td>Email</td>
            <td>{!$User.Email}</td>
            <td style="width:300px;text-align:right;">Customer # {!Opportunity.Account.QB_Account_Number__c}</td>
        </tr>
    </table>
</div>
<div id="ShipAndBillSection" class="ShipAndBillSection">
    <table style="width:100%;height:100%;" cellpadding="0" cellspacing="0">
        <tr>
            <td>
            <table cellpadding="0" cellspacing="0" class="ShipAndBill">
                <tr>
                    <td>
                    <table style="width:100%;height:100%;" cellpadding="1" cellspacing="1">
                        <tr>
                            <td rowspan="3" class="billToShipToLabel">BILL TO:</td>
                            <td class="addr">{!IF(Opportunity.Account.RecordType.Name='Service Customer',Opportunity.Account.Parent.Name,Opportunity.Account.Name)}</td>
                        </tr>
                        <tr><td class="addr">{!IF(Opportunity.Account.RecordType.Name='Service Customer',Opportunity.Account.Parent.BillingStreet,Opportunity.Account.BillingStreet)}</td></tr>
                        <tr><td class="addr">{!IF(Opportunity.Account.RecordType.Name='Service Customer',Opportunity.Account.Parent.BillingCity,Opportunity.Account.BillingCity)}, 
                                             {!IF(Opportunity.Account.RecordType.Name='Service Customer',Opportunity.Account.Parent.BillingState,Opportunity.Account.BillingState)} 
                                             {!IF(Opportunity.Account.RecordType.Name='Service Customer',Opportunity.Account.Parent.BillingPostalCode,Opportunity.Account.BillingPostalCode)}
                            </td>
                        </tr>
                    </table>
                    </td>
                </tr>
            </table>
            </td>
            <td style="width: 30px;">&nbsp;</td>
            <td>
            <table cellpadding="0" cellspacing="0" class="ShipAndBill">
                <tr>
                    <td style="vertical-align: top;">
                    <table style="width:100%;height:100%;" cellpadding="1" cellspacing="1">
                        <tr>
                            <td rowspan="5" class="billToShipToLabel">SERVICE AT:</td>
                            <td class="addr">{!Opportunity.Account.Name}</td>
                        </tr>
                        <tr><td class="addr">{!Opportunity.Account.ShippingStreet}</td></tr>
                        <tr><td class="addr">{!Opportunity.Account.ShippingCity}, 
                                             {!Opportunity.Account.ShippingState} 
                                             {!Opportunity.Account.ShippingPostalCode}</td></tr>
                        <tr><td class="addr">{!Opportunity.Account.Phone}</td></tr>
                    </table>
                    </td>
                </tr>
            </table>
            </td>
        </tr>
    </table>
</div>
    <c:OpportunitySortedItems value="{!Opportunity}" />
<!-- 
<apex:outputPanel layout="block" styleClass="LineItems" rendered="{!IF(OR(contains(Opportunity.RecordType.Name,'Special Service'),contains(Opportunity.RecordType.Name,'Addendum')),'FALSE','TRUE')}">
    <table class="LineItemsTable" cellpadding="5" cellspacing="0">
        <thead>
            <tr class="LineItemHeader">
                <td style="text-align:left;width:15%;">Product Name</td>
                <td style="text-align:left;width:40%;">Description</td>
                <td style="width:15%;">Sales Price</td>
                <td style="width:15%;">Quantity</td>
                <td style="width:15%;" class="TotalColHeader">Total Price</td>
            </tr>
        </thead>
        <apex:repeat var="line" value="{!Opportunity.OpportunityLineItems}" >
                <tr>
                    <td class="LineItemCell" style="text-align:center;border-bottom:1px silver solid;border-left:1px silver solid;">{!line.PricebookEntry.Name}</td>
                    <td class="LineItemCell" style="text-align:left;border-bottom:1px silver solid;">{!line.Description}</td>
                    <td class="LineItemCell" style="border-bottom:1px silver solid;"><apex:outputText value="{0, number, $###,###.00}">
                          <apex:param value="{!line.UnitPrice}" />
                        </apex:outputText>
                    </td>
                    <td class="LineItemCell" style="border-bottom:1px silver solid;"><apex:outputText value="{0, number, #,###.00}">
                          <apex:param value="{!line.Quantity}" />
                        </apex:outputText>
                    </td>
                    <td class="TotalColRow" style="border-bottom:1px silver solid;"><apex:outputText value="{0, number, $###,###.00}">
                          <apex:param value="{!line.TotalPrice}" />
                        </apex:outputText>
                    </td>
                </tr>
        </apex:repeat>
    <tr><td height="50px" colspan="3" class="LineItemCell" >&nbsp;</td>
        <td class="LineItemCell" style="border-bottom:1px gray solid;">&nbsp;</td>
        <td class="TotalColRow" style="border-bottom:1px gray solid;">&nbsp;</td>
    </tr>
    <tr>
        <td colspan="3" class="LineItemCell" >&nbsp;</td>
        <td class="LineItemCell" style="border-bottom:1px gray solid;" >Grand Total</td>
        <td class="TotalColRow" style="border-bottom:1px gray solid;">
            <apex:outputText value="{0, number, $###,###.00}">
                <apex:param value="{!Opportunity.Amount}" />
            </apex:outputText>
        </td>
    </tr>
    <tr><td colspan="5" align="left" style="padding: 10px 50px 5px 50px;"><div id="commentBox2">{!Opportunity.Quote_Comments__c}</div></td></tr>
</table>
</apex:outputPanel>
<apex:outputPanel layout="block" styleClass="LineItems" rendered="{!IF(OR(contains(Opportunity.RecordType.Name,'Special Service'),contains(Opportunity.RecordType.Name,'Addendum')),'TRUE','FALSE')}">
 <table class="LineItemsTable" cellpadding="5" cellspacing="0">
        <thead>
            <tr class="LineItemHeader">
                <td style="text-align:left;width:5%;">Service</td>
                <td style="text-align:left;width:65%;">Description</td>
                <td style="width:15%;">Sales Price</td>
                <td style="width:15%;"class="TotalColHeader">Total Price</td>
            </tr>
        </thead>
        <apex:repeat var="line" value="{!Opportunity.OpportunityLineItems}" >
                <tr>
                    <td class="LineItemCell" style="text-align:center;border-bottom:1px silver solid;border-left:1px silver solid;">{!line.PricebookEntry.Name}</td>
                    <td class="LineItemCell" style="text-align:left;border-bottom:1px silver solid;">{!line.Description}</td>
                    <td class="LineItemCell" style="border-bottom:1px silver solid;"><apex:outputText value="{0, number, $###,###.00}">
                          <apex:param value="{!line.UnitPrice}" />
                        </apex:outputText>
                    </td>
                    <td class="TotalColRow" style="border-bottom:1px silver solid;"><apex:outputText value="{0, number, $###,###.00}">
                          <apex:param value="{!line.TotalPrice}" />
                        </apex:outputText>
                    </td>
                </tr>
        </apex:repeat>
    <tr><td height="50px" colspan="2" class="LineItemCell" >&nbsp;</td>
        <td class="LineItemCell" style="border-bottom:1px gray solid;">&nbsp;</td>
        <td class="TotalColRow" style="border-bottom:1px gray solid;">&nbsp;</td>
    </tr>
    <tr>
        <td colspan="2" class="LineItemCell" >&nbsp;</td>
        <td class="LineItemCell" style="border-bottom:1px gray solid;" >Grand Total</td>
        <td class="TotalColRow" style="border-bottom:1px gray solid;">
            <apex:outputText value="{0, number, $###,###.00}">
                <apex:param value="{!Opportunity.Amount}" />
            </apex:outputText>
        </td>
    </tr>
    <tr><td colspan="5" align="left" style="padding: 10px 50px 5px 50px;"><div id="commentBox2">{!Opportunity.Quote_Comments__c}</div></td></tr>
</table>
    <div id="commentBox">
    <apex:outputPanel rendered="{!IF(contains(Opportunity.RecordType.Name,'Addendum'),'TRUE','FALSE')}">    
        <br /><br />When signed this Quote will serve as an addendum to the original service agreement and will change the monthly billing to the above stated amount.
    </apex:outputPanel>
    </div>
</apex:outputPanel>
-->
<div id="bottomSection">
    <div id="ReturnMsg" class="rtnMsg">
    The prices, specifications and conditions are satisfactory and are hereby accepted. 
    Square Feat, Inc. is authorized to do these items as specified.  Please line out 
    and initial any line items not needed.</div>
    <div id="ApprovalBlock">
        <table class="approvalTable" cellpadding="0" cellspacing="0">
            <tr><td style="width:75px;">Approved&nbsp;By</td><td style="width:375px;height:20px;border-bottom:1px gray solid;">&nbsp;</td></tr>
            <tr><td>Date</td><td style="height:20px;border-bottom:1px gray solid;">&nbsp;</td></tr>
            <tr><td>Signature</td><td style="height:20px;border-bottom:1px gray solid;">&nbsp;</td></tr>
            <tr style="display:{!IF(OR(contains(Opportunity.RecordType.Name,'Special Service'),contains(Opportunity.RecordType.Name,'Addendum')),'visible','none')}">
            <td>{!IF(contains(Opportunity.RecordType.Name,'Addendum'),'Effective Date','')}{!IF(contains(Opportunity.RecordType.Name,'Special Service'),'Preferred Service Date','')}</td><td style="height:20px;border-bottom:1px gray solid;">&nbsp;</td></tr>
        </table>
    </div>
    <div style="align:center;">PLEASE FAX OR EMAIL BACK APPROVED {!IF(contains(Opportunity.RecordType.Name,'Addendum'),'ADDENDUM','QUOTE')} TO SCHEDULE WORK.</div>
    <br />
    <div style="align:center;font-weight:bold;">Thank you for the opportunity! Visit us on our web site at www.squarefeat.com</div>
</div>
</body>
</apex:page>

 
I would like to display the standard system info on a VF form.  What is the proper format to use for code that will show the created by name and time and last modified by name and time .  thank you
How can a default value be set in a VF page in a long text feild? Currently the default value set in the object feild for comments__c does not populate when the record is entered from the VF page.
 </apex:tab>
                <apex:tab label="Comments" name="CommentsTab" id="tabComments">
                    <apex:pageBlockSection columns="1" id="CommentsPageBlock">
                        <apex:outputField value="{!Inspection__c.Comments__c}" id="Comments" />
                    </apex:pageBlockSection>
                </apex:tab>
 
hi all,
 
is there any method by which we can send email with cc and bcc field?
 
i looked into workflow-> email alert but no cc and bcc options were given.
 
please help me its urgent.
 
thanks,
mahi
  • November 15, 2007
  • Like
  • 0