• Irene Sless
  • NEWBIE
  • 65 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 20
    Questions
  • 22
    Replies
I created a VisualForce email template that includes building up an attachment. If I test it from the template it all works nicely and includes the attachment when sending the email.

I then created a custom button on my Order object detail page with a URL (have also tried Javascript) that runs this template. The email is sent but the attachment is nowhere to be found. Debug log doesn't tell me anything so I have no idea what's happening. 
<apex:page standardController="Order" showHeader="false" applyHtmlTag="false" applyBodyTag="false" renderas="pdf">
    <head>
        <style>
            body { 
            font-size:10px;
            font-family: Verdana, Tahoma, sans-serif}
            
            h2 {
            font-size:14px; 
            font-weight: bold; 
            line-height: 16px}
            
            h3 {
            font-size:12px; 
            font-weight: bold; 
            line-height: 14px }
            
            h4 {
            font-size:11px; 
            font-weight: bold; 
            line-height:13px}
            
            table, th, td {
            border-collapse: collapse;
            }
            
            th { font-weight: bold; }
                        
            @page {
                counter-increment: pages;
                @top-center {content: counter(page) " of " counter(pages);}
                @bottom-center {content: element(footer);}
            }
            div.footer {position: running(footer)}
            #pageNum: before {content: counter(pages);}
        </style>        
    </head>
    
    <div class="footer" style="font-size:8pt;text-align:center">

		<p align="center"><i>Copyright {!$Organization.Name}</i></p>
         
        <apex:outputText value="Printed: {! NOW() }"/>
        
    </div>
    <!--Logo and RMA number -->
    <table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
        <tr>
            <td>
                <img src='{!URLFOR($Resource.xx_address)}' title="logo" />
            </td>
        </tr>
        <hr/>
    </table>
    <table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
        <tr>
            <td>
                This number must be attached to all items being returned<br/>
            </td>
            <td align="right">
                <h2>Return Authorisation #: {!Order.OrderNumber}</h2>
            </td>
        </tr>
        <hr/>
    </table>
    
    <!--Addresses -->
    <table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
        <tr>    
            <td width="48%">
                <h4>Customer Details</h4>
                <h3>{!Order.Account.Name}</h3>
                {!Order.Account.BillingStreet}<br/>
                {!Order.Account.BillingPostalCode} {!Order.Account.BillingCity}
                <br/><br/>
                <b>Account Number: </b>{!Order.Account.AccountNumber}<br/>
            </td>
            <td width="4%">&nbsp;</td>
            <td>
		        <apex:outputText value="Date: {0,date,dd' 'MMMM', 'yyyy}">
                    <apex:param value="{!TODAY()}" />
                </apex:outputText><br/>
                <h4>Delivery Address for Return</h4>
                {!$Organization.Name}<br/>
                {!$Organization.Street}<br/>
                {!$Organization.PostalCode} {!$Organization.City}<br/>
                {!$Organization.Country}<br/>
            </td> 
        </tr>
    </table>
    <br/>
    <hr/>
    
    <table border="0" width="100%" id="table2">
        <tr>
            <td>
                <b>Contact name:</b> {!Order.CustomerAuthorizedBy.Name}<br/>
                <b>Contact email:</b> {!Order.CustomerAuthorizedBy.Email}<br/>
                <b>Contact phone:</b> {!Order.CustomerAuthorizedBy.Phone}
            </td>
            <td>
                <b>Created by:</b> {!Order.CreatedBy.Name}<br/>
                <b>Source Order :</b> {!Order.RMA_Source_Order__r.OrderNumber}<br/>
                <b>Source Invoice:</b> {!Order.RMA_Source_Invoice__r.Name}<br/>
                <b>Case:</b> {!Order.RMA_Source_Document__c}
            </td>
        </tr>    
    </table>
    <br/>
    <hr/>
    <table border="0" width="100%" id="table3">
        <tr>
            <td bgcolor="#C0C0C0"><h4>Product</h4></td>
            <td bgcolor="#C0C0C0"><h4>Description</h4></td>
            <td bgcolor="#C0C0C0"><h4>Quantity</h4></td>
            <td bgcolor="#C0C0C0"><h4>Unit</h4></td>
        </tr>
        <apex:repeat value="{!Order.OrderItems}" var="line">
            <tr>
                <td>{!line.PricebookEntry.ProductCode}</td>
                <td>{!line.Description}</td>
                <td>{!line.Quantity}</td>
                <td>{!line.Unit__c}</td>
            </tr>
        </apex:repeat>  
    </table>
    <br/>
    <hr/>
    <br/>
    <p>{!Order.Description}</p>
    <br/>
    <hr/>
    <table width="100%" id="table5">
        <tr>
            <td><b>This is your RMA (Return Maintenance Authority) return form as requested.<br/>
                THE RMA NUMBER ABOVE MUST BE CLEARLY MARKED ON THE OUTSIDE OF THE PARCEL BEING RETURNED</b>
                <br/>
                Please ensure that the goods are sufficiently packaged to ensure that no damage occurs during transit.<br/>
                If you have any queries or, want to follow up on the collection relating to this return, please contact
                xx on <b>0800 xxxxx</b> or <b>email sales@xx.com</b>
            </td>
        </tr>
        <tr>
            <td alight="center">
                <h3>Return Reason - please complete</h3>
			    <table border="1" width="95%" height="100px">
                    <tr><td height="100px"></td></tr>
                </table>
            </td>
        </tr>
    </table>
</apex:page>

Button URL is as below, the template id taken from the above email template.
/_ui/core/email/author/EmailAuthor?p2_lkid=001O000000NYJbV&rtype=003&p3_lkid={!Order.Id}&retURL=%2F{!Order.Id}&template_id=00XO0000000Ek5M
I have a batch job which used to run fine, but since end of last week is throwing an error: 'FATAL ERROR Internal Salesforce Error' every time. 

Developer script from .... exception  : 'OrderItemCleanup' : common.exception.SfdcSqlException: ORA-20145:  ORA-06512: at "DOPEY.BORDERITEM", line 1830 ORA-06512: at line 1   SQLException while executing plsql statement: {call bOrderItem.check_delete_o...

Apex script unhandled exception by user/organization: .../...
Failed to process batch for class 'OrderItemCleanup' for job id '7079000005qLkrQ'

It's a batch job that runs through existing OrderItems and deletes those of a certain type, then updates the parent Order with text and a roll-up summary field.
I tried to log a case but it seems I can't do so anymore, and am directed to the Community here. Having read other posts, it seems to be something I need to log with SF, but I can't. 
Is it possible to display a multiline select or text box on a Visualforce page in a 2 column pageblocksection, without it creating a gap in the other column? Something like a row merge for the 2nd column only. I would like to use the space effeciently - keep all the checkboxes on one side and the multi-select on the other side.
User-added image
Is it possible to display a multiline select or text box on a Visualforce page in a 2 column pageblocksection, without it creating a gap in the other column? Something like a row merge for the 2nd column only. I would like to use the space effeciently - keep all the checkboxes on one side and the multi-select on the other side.

User-added image
I have an insert/update trigger where I need to prevent a record of a certain type to be skipped over (not inserted) in a batch. I've read up and see I can do this using the addError method, but currently if I do that it rolls back the entire batch, even the valid ones. Furthermore I've read that it depends on the allOrNone parameter being set - I am setting it (even though it says the default setting = false), yet it still rolls back the entire batch. What am I doing wrong, or is this not possible to do? How can I achieve a partial insert?
trigger InvoiceLineBeforeInsertUpdate on InvoiceLine__c (before insert, before update) {
    
    Map<string, string> mapLineTyps = new Map<string, string>();
    Map<Id, string> mapNarratives = new Map<Id, string>();
    string strNarr;
    Id inv;
    Database.DMLOptions dlo = new Database.DMLOptions();
    dlo.OptAllOrNone = false;

    try{   
        for(InvoiceLine__c  invln : trigger.new){
            if(invln.LineType__c == 'Narrative'){
                if(inv != invln.Invoice__c){
                    mapNarratives.put(inv, strNarr);
                    inv = invln.Invoice__c;
                    strNarr = invln.Description__c;
                }
                else if(inv == invln.Invoice__c){
                    strNarr += + '\r\n' + invln.Description__c;
                }
                invln.addError('Exclude Narrative line: ' + invln.Description__c);
            }
                
        }
        if(mapNarratives.size() > 0){
            //add the last entry
            mapNarratives.put(inv, strNarr);
            List<Invoice__c> invoices = new List<Invoice__c>();
	        Invoice__c updInv;
            //Add the Narratives to the Invoice. Remove the blank entry in the map.
            mapNarratives.remove(null);
            for(Id invId : mapNarratives.keySet()){
                updInv = new Invoice__c(Id = invId, Description__c = mapNarratives.get(invId));
                invoices.add(updInv);
            }
            update invoices;
        }
        
    } catch(NullPointerException e){
        System.debug('##InvLineBF Catch Error: An error has occurred where there is no value for an ID: ' + e.getMessage());
        
    } catch(Exception e){
        System.debug('##InvLineBF Catch Error: The following error has occurred: ' + e.getMessage());
    }
    
}

 
I have 2 buttons that toggle between 2 different views (detail and list) of an object (ie all calls for a sales rep) using the sam Controller for both.

In the list view the sales rep or the date can be changed to retrieve for another rep or for another date. When I click the toggle button however to display the detail view again, it displays the original record selected, not the new one I selected in the list view, as the ID parameter in the URL doesn't change when I select a new record.

How do I get it to change the ID in the URL to the latest one, or to pick it up regardless of the URL parameter? In my commandbutton I put in the new ID as below, yet when it loads the detail view through the controller it loads the old one.
<apex:commandButton id="CCActivitiesView" action="{!view}" title="Call Cycle Activities View" value="Call Cycle Activities Detail View" 
        onclick="location.href=('/apex/CallCycleView?id={!CallCycle.Id}')" />
And the code in my Controller is as follows:
public CallCycleController(ApexPages.StandardController std) {

stdCtrl=std;        
CallCycle = (CallCycle__c)std.getRecord();
date ccDate = CallCycle.Date__c;

if(CallCycle != null && CallCycle.Id != null){
    CallCycle = [Select Id, OwnerId, Name, Date__c, CycleStart__c, CycleEnd__c, SalesPerson__c, SalesPerson__r.Name
                 From CallCycle__c Where Id = :CallCycle.Id];
    LoadModel();
}
I've been looking for an answer to this for a while and one person suggested 'move the redirection code into server side', but I don't know what's meant by that (have asked but no reply and am getting a bit more desperate now). 
I've looked at several other posts in the forum regarding this, but none seem to have my problem. My VF page does not use an sObject, so I don't know what to do next, and would appreciate any help please.
I get the following error:
Constructor not defined: [CallCyclePrintController].<Constructor>(ApexPages.StandardController)

My VF form:
<apex:page showHeader="false" sidebar="false" controller="CallCyclePrintController">

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

            $j = jQuery.noConflict();
            
            $j(document).ready(function() {           
                window.print();
            });

        </script>

        <style>

            body {
                margin: 10px;
            }
            .title {
                padding: 5px 0;
            }

            .title h1 {
                font-size: 20px;
            }

            .account {
                padding: 5px;
                border-top: solid 1px #000;
                margin-top: 3px;
            }

            .clearBoth {
                clear: both;
            }
            
            table {
                width: 100%;
            }
            table, th, td{
                border: 1px solid #ccc;
                border-collapse: collapse;
            }
            th, td{
                padding: 5px;
                font-size: 9px;
            }

            @page {
                @bottom-right {
                    content: counter(page) " of " counter(pages);
                }
            }

        </style>
    </head>

    <div class="title">
        <h1>Call Cycle Schedule For: {!CallCycleModel.CallCycle.SalesPerson__r.Name} [Date: {!CallCycleDate}]</h1>
    </div>

        <table>
            <thead>
                <tr>
                    <th>CRM</th>                  
                    <th>Name</th>                  
                    <th>Phone</th>                  
                    <th>Mobile</th>                  
                    <th>Title</th>                  
                    <th>Department</th>                  
                    <th>Category</th>                  
                </tr>
            </thead>
            <tbody>
                <apex:repeat value="{!CallCycleModel.CallCycleActivities}" var="activity">
      
                <tr>
                    <td colspan="7" class="account">
                        <h2>{!activity.CallCycleActivity.Account__r.AccredoID__c} - {!activity.CallCycleActivity.Account__r.Name}</h2>
                    </td>
                </tr>
                <apex:repeat value="{!activity.CallCycleActivityContacts}" var="contact">
                    <tr>        
                        <td class="">
                            {!contact.Contact__r.AccredoCRMGroup__c}
                        </td>
            
                        <td class="">
                            {!contact.Contact__r.Name}
                        </td>
            
                        <td class="">
                            {!contact.Contact__r.Phone}
                        </td>
                        <td class="">
                            <div>{!activity.CallCycleActivity.CallCycleCategory__c}</div>
                            <div><apex:outputField value="{!contact.Contact__r.LastMemoContent__c}"/></div>
                        </td>
                    </tr>          
                        <td class="">
                            <div>{!activity.CallCycleActivity.MeetingTime__c}</div>
                        </td>
    
                </apex:repeat>
                </apex:repeat>
            </tbody>
        </table>

</apex:page>

My Controller class:
public with sharing class CallCyclePrintController {
    
    string CallCycleId { get; set; }
    public CallCycleModel CallCycleModel { get; set; }
    
    public string CallCycleDate {
        get {
            DateTime d = DateTime.newInstance(CallCycleModel.CallCycle.Date__c.Year(),
                                              CallCycleModel.CallCycle.Date__c.Month(),
                                              CallCycleModel.CallCycle.Date__c.Day());
            
            return d.format('dd/MM/yyyy');
        }
    }
    
    //-----------------------------------------------------------------------------------------
    public CallCyclePrintController() {
        CallCycleId = ApexPages.currentPage().getParameters().get('id');
        CallCycleModel = new CallCycleModel();
        system.debug('##CCPC enter - CCId: ' + CallCycleId);        
        
        //set the call cycle
        CallCycleModel.CallCycle = [Select Id, Date__c, Name, SalesPerson__r.Name
                                    From CallCycle__c 
                                    Where Id = :CallCycleId];
        system.debug('##CCPC CallCycleModel: ' + CallCycleModel);        
        
        //get the activities
        List<CallCycleActivity__c> ccas = [Select Id, Name, Account__r.AccredoID__c, Account__r.Name, Account__r.AccountNumber, Account__r.OtherPartyCode__c,
                                           Account__r.ShippingStreet, Account__r.ShippingCity, Account__r.AccountGroup__c, Account__r.Account_Group_Description__c, 
                                           Account__r.LastMemoContent__c, Account__r.Project_Team_Leader__r.Name,
                                           CallCycleCategory__c, ActivityID__c, EventDateTime__c, JointVisit__c, 
                                           Client_EndUser__c, Client_EndUser__r.MailingStreet, Client_EndUser__r.MailingCity
                                           From CallCycleActivity__c
                                           Where CallCycle__c = :CallCycleModel.CallCycle.Id
                                           Order By EventDateTime__c];
        system.debug('##CCPC ccas: ' + ccas);        
        
        Map<Id, Event> activities = GetEvents(ccas);
        system.debug('##CCPC activities : ' + activities );        
        
        Map<Id, Contact> contacts = GetEventContacts(activities);
        system.debug('##CCPC contacts : ' + contacts );        
        
        Map<Id, Memo__c> alarms = GetAlarms(ccas);
        system.debug('##CCPC alarms: ' + alarms );        
        
        for(CallCycleActivity__c c : ccas){
            CallCycleActivityModel ccaModel = new CallCycleActivityModel();
            ccaModel.CallCycleActivity = c;
            
            system.debug('##CCPC ccaModel.CallCycleActivity: ' + ccaModel.CallCycleActivity);        
            //get the event and contact sObjects
            Event e = activities.get(c.ActivityID__c);
            ccaModel.CallCycleEvent = e;
            if(e != null){
                Contact eventContact = contacts.get(e.Id);
                ccaModel.CallCycleEventContact = eventContact;
                system.debug('##CCPC eventContact: ' + eventContact);  
            }
            Memo__c acctAlarm = alarms.get(c.Account__c);
            system.debug('##CCPC acctAlarm: ' + acctAlarm);        
            //            ccaModel.CallCycleEventActAlarm = acctAlarm;
            
            //get the contacts
            List<CallCycleActivityContact__c> ccacs = [Select Id, isSelected__c,Contact__r.AccredoCRMGroup__c, Contact__r.Name, Contact__r.Phone, 
                                                       Contact__r.MobilePhone, Contact__r.AccredoAlarms__c, Contact__r.Department, 
                                                       Contact__r.Title , Contact__r.LastMemoContent__c
                                                       From CallCycleActivityContact__c
                                                       Where CallCycleActivity__c = :c.Id
                                                       And isSelected__c = true];
            
            system.debug('##CCPC ccacs: ' + ccacs);        
            if(ccacs == null || ccacs.size() == 0){
                continue;
            }
            
            for(CallCycleActivityContact__c ccac : ccacs){
                CallCycleActivityContactModel ccacModel = new CallCycleActivityContactModel();
                ccacModel.CallCycleActivityContact = ccac;
                
                system.debug('##CCPC ccac: ' + ccac);        
                ccaModel.CallCycleActivityContacts.add(ccac);
            }
            
            CallCycleModel.CallCycleActivities.add(ccaModel);
            system.debug('##CCPC ccaModel: ' + ccaModel);        
        }
        
    }
    
    
    //-----------------------------------------------------------------------------------------
    
    public Map<Id, Event> GetEvents(List<CallCycleActivity__c> ccas){
        List<string> activityIds = new List<string>();
        
        for(CallCycleActivity__c c : ccas){
            if(c.ActivityID__c != null){
                activityIds.add(c.ActivityID__c);
            }
            
        }
        
        system.debug('##CCPC ccas: ' + ccas);        
        Map<Id, Event> events = new Map<Id, Event>([Select Id, ActivityDate, StartDateTime, Description, EventCategory__c,
                                                    Who.Name, Owner.Name
                                                    From Event Where Id In :activityIds]);
        
        return events;
    }
    
    //-----------------------------------------------------------------------------------------
    
    public Map<Id, Contact> GetEventContacts(Map<Id, Event> events){
        List<Id> contactIds = new List<Id>();
        
        for(Event e : events.values()){
            if(e.WhoId != null){
                contactIds.add(e.WhoId);
            }
            
        }
        
        system.debug('##CCPC events: ' + events);        
        Map<Id, Contact> contacts = new Map<Id, Contact>([Select Id, Name, Phone, MobilePhone, Department, Title,
                                                          AccredoMailoutCode__c, LastMemoContent__c
                                                          From Contact Where Id In :contactIds]); 
        
        //now create a map between events and contacts
        Map<Id, Contact> eventContacts = new Map<Id, Contact>();
        
        for(Event e : events.values()){
            if(e.WhoId != null){
                Contact c = contacts.get(e.WhoId);
                
                eventContacts.put(e.Id, c);
            }
            
        }
        
        return eventContacts;
    }
    
    
    //-----------------------------------------------------------------------------------------
    
    public Map<Id, Memo__c> GetAlarms(List<CallCycleActivity__c> ccas){
        List<string> acctIds = new List<string>();
        
        for(CallCycleActivity__c c : ccas){
            if(c.Account__c != null){
                acctIds.add(c.Account__c);
            }
            
        }
        
        system.debug('##CCPC ccas: ' + ccas);        
        Map<Id, Memo__c> memos = new Map<Id, Memo__c>([Select Id, Account__c, Subject__c, Memo_Notes__c, About_What__c
                                                       From Memo__c Where Account__c In :acctIds and Active__c=true and Type__c='Instruction']);
        
        return memos;
    }

    //-----------------------------------------------------------------------------------------
    
    /*///////
    //Models
    ///////*/
    public class CallCycleModel {
        public CallCycle__c CallCycle { get; set; }
        
        public List<CallCycleActivityModel> CallCycleActivities { get; set; }
        public CallCycleModel(){
            CallCycleActivities = new List<CallCycleActivityModel>();
            system.debug('##CCPC CallCycleModel:CallCycleActivities: ' + CallCycleActivities);        
        }
    }
    
    //-----------------------------------------------------------------------------------------
    public class CallCycleActivityModel {
        public CallCycleActivity__c CallCycleActivity { get; set; }
        public Event CallCycleEvent { get; set; }
        
        public string CallCycleEventTime {
            get{
                
                if(CallCycleEvent != null && CallCycleEvent.StartDateTime != null){
                    return CallCycleEvent.StartDateTime.format('HH:mm');
                }
                return '00:00';
            }
        }
        
        public Contact CallCycleEventContact { get; set; }
        
        public List<CallCycleActivityContact__c> CallCycleActivityContacts { get; set; }
        public List<CallCycleActivityAlarm__c> CallCycleActivityAlarms { get; set; }
        
        public CallCycleActivityModel(){
            CallCycleActivityContacts = new List<CallCycleActivityContact__c>();
            CallCycleActivityAlarms = new List<CallCycleActivityAlarm__c>();
            system.debug('##CCPC line 190 CallCycleActivityModel:CallCycleActivityContacts:' + CallCycleActivityContacts );        
        }
        
    }
    
    //-----------------------------------------------------------------------------------------
    public class CallCycleActivityContactModel {
        public CallCycleActivityContact__c CallCycleActivityContact { get; set; }
        
        public string Alarm {
            get {
                string a = CallCycleActivityContact.Contact__r.AccredoAlarms__c;
                system.debug('##CCPC line 202');        
                return a;
            }
        }
    }
    
    //-----------------------------------------------------------------------------------------
    public class CallCycleActivityAlarmModel {
        public CallCycleActivityAlarm__c CallCycleActivityAlarm { get; set; }
    }
      
    
}

My test class:
@isTest
private class TestCallCyclePrintController {

    //-----------------------------------------------------------------------------------------
    @isTest static void TestCallCyclePrintController() {

        PageReference pageRef = Page.CallCyclePrint;
        Test.setCurrentPage(pageRef);

        User u = [Select Id From User Where Id = :UserInfo.getUserId()];
        system.debug('@@@ u: ' + u);
                
		Id recType = Schema.SObjectType.Memo__c.getRecordTypeInfosByName().get('Account').getRecordTypeId();

        Account a = new Account();
        a.Name = 'Test';
        a.OtherPartyCode__c = '40';
        a.Owner = u;
        a.ShippingStreet = 'Street';
        a.AccountNumber = '040abcde';
        
        insert a;
        system.debug('@@@ a.Owner: ' + a.Owner);
        
        Contact c = new Contact();
        c.LastName = 'Test';
        c.AccountId = a.Id;
        c.AccredoCRMGroup__c = '001';
        c.CallCycleFrequency__c = '3 monthly';
        c.ConfirmAppointment__c = true;
        insert c;

        Contact c2 = new Contact();
        c2.AccountId = a.Id;
        c2.LastName = 'test';
        c2.AccredoCRMGroup__c = '002';
        c2.ConfirmAppointment__c = false;
        
        insert c2;
        
        CallCycle__c callCycle = new CallCycle__c();
        callCycle.Date__c = Date.today();
        callCycle.CycleStart__c = 10;
        callCycle.CycleEnd__c = 50;
        callCycle.SalesPerson__c = u.Id;

        insert callCycle;
        ApexPages.currentPage().getParameters().put('id', callCycle.Id);
        
        CallCycleActivity__c cca = new CallCycleActivity__c();
        cca.Account__c = a.Id;
        cca.CallCycle__c = callCycle.id;
        cca.EventDate__c = date.parse('05/11/2015');
		cca.CallCycleCategory__c = 'Sales Drop In';
        
        insert cca;     
       
//        ApexPages.StandardController sc = new ApexPages.standardController(callCycle);
        CallCyclePrintController controller = new CallCyclePrintController(new ApexPages.standardController(callCycle));
        

    }

}

 
I have a VF page with a repeating pageblock within which is an apex:detail section and a pageblockTable. Both the detail section and the table have inlineEdit support activated. The detail section displays the buttons correctly, but the Table doesn't display buttons at all. The editing feature becomes active when I double click, but the buttons don't show, so I can't Save. What am I doing wrong?
 
<apex:pageBlock title="Call Cycle Events">
            
			<apex:actionFunction name="rerenderDetail" rerender="detail"/>
            
            <apex:repeat value="{!CallCycleActivitiesEx}" var="activity">
                <apex:pageBlock >
                    <apex:outputPanel id="detail">
                    	<apex:detail subject="{!activity.CallCycleActivity.Id}" relatedList="false" inlineEdit="true" title="false"/>
                    </apex:outputPanel>
                    <apex:pageblockTable styleClass="cc_row" width="95%" rowClasses="odd,even" value="{!activity.CallCycleActivity.CallCycleActivityContacts__r}" var="contact">
                        <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" 
                                                changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
                        <apex:column styleclass="cc_col5" headerValue="CRM">
                            <apex:inputCheckbox title="{!contact.Id}" value="{!contact.IsSelected__c}" styleClass="checkContact"
                                                onclick="updateDisplay(this, '{!contact.Id}');" />{!contact.Contact__r.AccredoCRMGroup__c}
                        </apex:column>
                        <apex:column styleclass="cc_col8" headerValue="Contact Name">
                            <apex:outputLink value="{!URLFOR($Action.Contact.View, contact.Contact__r.Id)}" target="_blank">{!contact.Contact__r.Name}</apex:outputLink>
                        </apex:column>
                        <apex:column styleclass="cc_col5" headerValue="Phone Number" value="{!contact.Contact__r.Phone}"/>
                        <apex:column styleclass="cc_col8" headerValue="Mobile Phone" value="{!contact.Contact__r.MobilePhone}"/>
                        <apex:column styleclass="cc_col8" headerValue="Email" value="{!contact.Contact__r.Email}"/>
						<apex:column styleclass="cc_col5" headerValue="Department" value="{!contact.Contact__r.Department}"/>
                        <apex:column styleclass="cc_col5" headerValue="Title" value="{!contact.Contact__r.Title}"/>
                        
                    </apex:pageblockTable>
                </apex:pageBlock>
                
            </apex:repeat>
            
        </apex:pageBlock>
Below is a screen shot of the page - the only buttons shown are those related to the apex:detail section, and it shows these buttons both top and bottom (which is also confusing as it looks like the bottom buttons belong to the table, which they don't! I'd like the bottom buttons to not show for the detail section too).

User-added image
My VF page queries a custom object as the main object, and then has a repeating section of a child object which is displayed using apex:detail. This works very nicely for everything, except the delete, which redirects to the list page and not to the VF page.

I would like the delete button to delete the child section from the repeating part, and return to the parent page. 
User-added image
<apex:page StandardController="CallCycle__c" extensions="CallCycleController" title="Call Cycles" showHeader="true" sidebar="true">
    
    <style>
        .cc_row { padding: 7px 0px;  }
        .cc_margin{ margin:3px 8px 3px 8px; }        
        .cc_col3{ width: 3%; }
        .cc_col5{ width: 5%; }
        .cc_col8{ width: 8%; }
        .cc_col10{ width: 10%; }
        .cc_col15{ width: 15%; }
        .cc_col20{ width: 20%; }
        .clear-both{ clear: both; }
        .center{ text-align: center; }
        .title{ font-weight: bold;
        padding: 5px; }
    </style>
    
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script type="text/javascript">
        
        jCC$ = jQuery.noConflict();
    
    jCC$(document).ready(function() {
        
        jCC$(".hideContacts").click(function() {
            var isChecked = this.checked;
            
            if(isChecked){
                
                jCC$(".dataRow").each(function() {
                    var c = jCC$(this).find(".checkContact");
                    //var p = jCC$(this).find('.checkContact').val();
                    if(c != undefined && !c.is(":checked")){
                        jCC$(this).hide();
                    }
                });
            }
            else{
                jCC$(".dataRow").show();
            }
        });
                
    });
    
    function updateDisplay(checkbox, id){
        
        var checked = checkbox.checked;
        CallCycleControllerX.RemoteUpdateisSelected(id, checked, function(result, event){
            var foo = result;
        });
        
    }
    
    function updateEventDateTime(id, dateTime){ 
        var r = confirm("Are you sure you want to generate these events?");               
        updateEventDate(id, dateTime);
    }
    
    </script>
    
    <apex:form >
        
        <apex:sectionHeader title="Call Cycle Schedule" subtitle="{!CallCycle.Name}" />
        <apex:outputLink value="{!URLFOR($Action.CallCycle__c.Tab, $ObjectType.CallCycle__c)}">Back to list: CallCycles</apex:outputLink>
        
        <apex:pageBlock title="Call Cycle Detail">
            <apex:pageMessages />
            <apex:pageBlockButtons location="top">                
                <apex:commandButton id="PrintAdmin" action="PrintCallCycle" title="Print Call Cycle" value="Print Admin Call Cycle" onclick="window.open('/apex/CallCyclePrint?id={!CallCycle.Id}');return false;" />                
                <apex:commandButton id="PrintRep" action="PrintCallCycle" title="Print Call Cycle" value="Print Rep Call Cycle" onclick="window.open('/apex/CallCyclePrintRepTable?id={!CallCycle.Id}');return false;" />
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="" collapsible="false">
                <apex:outputField id="Name" value="{!CallCycle__c.Name}" />
                <apex:outputField id="Date" value="{!CallCycle__c.Date__c}" />
                <apex:outputField id="SalesPerson" value="{!CallCycle__c.SalesPerson__c}" />
                <apex:outputField id="CycleStart" value="{!CallCycle__c.CycleStart__c}" />
                <apex:inputCheckbox id="HideContacts" label="Hide Unselected Contacts" styleClass="hideContacts" value="{!HideContacts}" />
                <apex:outputField id="CycleEnd" value="{!CallCycle__c.CycleEnd__c}" />
            </apex:pageBlockSection>            
        </apex:pageBlock>        
        <apex:pageBlock title="Edit Call Cycle">
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton id="AddToCallCycle" action="{!AddToCallCycle}" title="Add New Account" value="Add New Account to Call Cycle" styleClass="center" />
                <apex:commandButton id="updateAllNewDate" action="{!UpdateCCADateAll}" title="Update All New Date" value="Update All Appointments with New Date" />
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="" collapsible="false">
                <apex:inputField id="Account" value="{!AddCallCycleActivity.Account__c}" label="Add a new Account" required="false"/>
                <apex:inputField label="New Appointment Date for All in Call Cycle" id="theAllDate" styleClass="theDate" value="{!UpdateCCADateAll.EventDate__c}" required="false"/>
                <apex:inputField id="NewDateTime" value="{!AddCallCycleActivity.EventDateTime__c}" label="Date/Time of Appointment for new Account" required="false"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock title="Call Cycle Events">                        
            <apex:repeat value="{!CallCycleActivitiesEx}" var="activity">
                <apex:pageBlock >
                    <apex:detail subject="{!activity.CallCycleActivity.Id}" relatedList="false" inlineEdit="true" title="false"/>
                    <apex:pageblockTable styleClass="cc_row" width="95%" rowClasses="odd,even" value="{!activity.CallCycleActivity.CallCycleActivityContacts__r}" var="contact">
                        <apex:column styleclass="cc_col5" headerValue="CRMGroup">
                            <apex:inputCheckbox title="{!contact.Id}" value="{!contact.IsSelected__c}" styleClass="checkContact" onclick="updateDisplay(this, '{!contact.Id}');" />{!contact.Contact__r.AccredoCRMGroup__c}
                        </apex:column>
                        <apex:column styleclass="cc_col8" headerValue="Contact Name">
                            <apex:outputLink value="{!URLFOR($Action.Contact.View, contact.Contact__r.Id)}" target="_blank">{!contact.Contact__r.Name}</apex:outputLink>
                        </apex:column>
                        <apex:column styleclass="cc_col5" headerValue="Phone Number" value="{!contact.Contact__r.Phone}"/>
                        <apex:column styleclass="cc_col8" headerValue="Mobile Phone" value="{!contact.Contact__r.MobilePhone}"/>
                        <apex:column styleclass="cc_col8" headerValue="Email" value="{!contact.Contact__r.Email}"/>
						<apex:column styleclass="cc_col5" headerValue="Department" value="{!contact.Contact__r.Department}"/>
                        <apex:column styleclass="cc_col5" headerValue="Title" value="{!contact.Contact__r.Title}"/>
                        <apex:column styleclass="cc_col3" headerValue="Confirm" value="{!contact.Contact__r.ConfirmAppointment__c}"/>
                        <apex:column styleclass="cc_col3" headerValue="Include" value="{!contact.Contact__r.IncludeinCallCycle__c}"/>
                        <apex:column styleclass="cc_col5" headerValue="Last Visit" value="{!contact.Contact__r.LastCallCycleVisit__c}"/>
                        <apex:column styleclass="cc_col5" headerValue="Pref Method" value="{!contact.Contact__r.PreferredContactMethod__c}"/>
                        <apex:column styleclass="cc_col8" headerValue="Pref Day" value="{!contact.Contact__r.Preferred_Day__c}"/>
                        <apex:column styleclass="cc_col5" headerValue="Pref Time" value="{!contact.Contact__r.Preferred_Time__c}"/>
                        <apex:column styleclass="cc_col8" headerValue="Pref Time Other" value="{!contact.Contact__r.Preferred_Time_Other__c}"/>
                        <apex:column styleclass="cc_col5" headerValue="Connect" value="{!contact.Contact__r.MailAgedCareConnect__c}"/>
						<apex:column headerValue="Alarm" value="{!contact.Contact__r.AccredoAlarms__c}"/>                        
                    </apex:pageblockTable>                    
                </apex:pageBlock>                
            </apex:repeat>            
        </apex:pageBlock>        
    </apex:form>    
</apex:page>

 
My VF page has a repeatable section and within each block there are 3 different updateable fields and an update button. I have some Javascript at the top of the page which is run when the update button in the section is clicked. This button sends the Id of the SF record to update, but I'm struggling with getting the values for the other fields. The function calls a remote function in my Apex class which does the actual updating.

This is my Javascript:
jCC$(document).ready(function() {

            jCC$(".newDateTime").click(function() {

                var ccid = this.id;
                
                var newdate = document.getElementsByClassName('theApxDate')[0].value;
                var newtime = document.getElementsByClassName('theTimes')[0].value;
                var ccat = document.getElementsByClassName('theCat')[0].value;

                if(newdate != '' && newtime != ''){
                    CallCycleController.RemoteNewEventDate(ccid, newdate, newtime, ccat, function(result, event){
                        var foo = result;
                        alert('CallCycle has been updated');
                });
                }
                else { alert('CallCycle NOT updated: Please enter a Date AND Time');
                }
                return false;
            });
});
And this is my VF page section:
<apex:pageBlock title="Call Cycle Events">

	<apex:repeat value="{!CallCycleActivitiesEx}" var="activity">

		<apex:pageBlock title="{!activity.CallCycleActivity.Account__r.Name + ' (' + activity.CallCycleActivity.Account__r.AccredoID__c + ')'}">
			<apex:pageBlockSection >
				<apex:inputField label="Appointment Date" id="theApDate" styleClass="theApxDate cc_margin" value="{!activity.CallCycleActivity.EventDate__c}"/>
				<apex:selectList label="Category" id="eventCategory" multiselect="false" size="1" value="{!activity.Memo}" styleClass="theCat cc_margin" >
					<apex:selectOptions value="{!EventCategories}"/>
				</apex:selectList>
				<apex:selectList id="theTime" multiselect="false" size="1" value="{!activity.CallCycleActivity.EventTime__c}" styleClass="theTimes cc_margin">
					<apex:selectOptions value="{!TimeBlocks}"/>
				</apex:selectList>
				<button class="newDateTime cc_margin" id="{!activity.CallCycleActivity.Id}">Update Call Cycle Event</button>
				<button class="remCCA cc_margin" id="{!activity.CallCycleActivity.Id}">Remove Call Cycle Event</button>
			</apex:pageBlockSection>
			<apex:pageblockTable styleClass="cc_row" width="95%" rowClasses="odd,even" value="{!activity.CallCycleActivity.CallCycleActivityContacts__r}" var="contact">
				<apex:column styleclass="cc_col10" headerValue="Phone Number" value="{!contact.Contact__r.Phone}"/>
				<apex:column styleclass="cc_col10" headerValue="Mobile Phone" value="{!contact.Contact__r.MobilePhone}"/>
				<apex:column styleclass="cc_col10" headerValue="Department" value="{!contact.Contact__r.Department}"/>
				
			</apex:pageblockTable>

		</apex:pageBlock>

	</apex:repeat>

</apex:pageBlock>

As it is now, if there are 3 repeating blocks on the VF page and I update the 3rd one, it picks up the correct Id as that is passed via the button, but it picks up the values from the 1st block for the fields. 

How do I code it to pick up the values from 'this' block?
We have an integration running hourly from our accounting system to upload data into Salesforce. What I would like to know is, other than manually checking log files, is there an automated way to receive notification if an error occurred, and what the error is?

Currently the only way we can tell is if a user picks up that data which should be in SF isn't there, because they have a document from the accounting system (ie a reference to a quote), and this quote is not in SF (but should be).

Debug logs in SF stop after 20 runs, then one has to refresh, and this can't be reset automatically either, which would be a great thing if it did, as with hourly runs the sync uses up the 20 limit more than once a day!

It would be great if an email could be sent to the Administrator if there were any errors in the sync process. Is this possible to do?
I have a VF page which lists a repeating block of data (a custom object). I can add a new object or delete one. When I add a new one the page displays the newly added object on return from the remote call. When I delete an object however, it does not seem to refresh the page and remove the deleted one.

How do I get it to refresh the page after having deleted something on the page?

This is what my page looks like. When I click on the 'Remove Call Cycle Event' button it runs the Javascript below the image, which calls the @RemoteAction in my controller. What do I need to do for it to remove the block I clicked the button on?
User-added image
In my VF page:
            jCC$(".remCCA").click(function() {
                var ccaId = this.id;
                if(ccaId != ''){
                    CallCycleController.RemoveCallCycleActivity(ccaId, function(result, event){
                        var foo = result;
                        alert('CallCycle Activity has been deleted');
                });
                return false;
            });

In my Controller:
  @RemoteAction
  public static void RemoveCallCycleActivity(string remId){
    CallCycleActivity__c delCCA = [Select Id, ActivityId__c From CallCycleActivity__c Where Id=:remId];
    delete delCCA; 
  }
I need to loop through a table I have on a VF page and hide every row where a checkbox isn't ticked. The first col in each row has the checkbox. How can I do this - help please?

I have some Javascript on the page that used to do this before the table data was in a table, so it was easier then to do it per row, but it didn't look very nice. The table looks great but now I can't hide a row!
I have Salesforce for Outlook setup with the configuration set to 'Sync both ways' and conflict settings to 'Salesforce always wins'. Field mappings are correct.

We auto generate Tasks for Opportunities - a Sales Rep is assigned to follow-up an Opp and is assigned a Task for this. A custom field on the Task sets a flag to indicate that this is a 'follow-up' task. This flag is to separate it from any other Tasks that might be created for the same Opp that are not related to the 'follow-up', and this flag is controlled by trigger code only (or the Administrator manually).

A Sales Rep may not mark this type of Task as 'Completed' - the system trigger does this when the Stage is set to a 'Closed' stage. My problem is that the Sales Reps use mostly Outlook for updating their Tasks, and I can't control them clicking the 'Completed' option in Outlook. 

I created a 'before update' trigger on Tasks in SF, which checks the 'follow-up' custom field flag. If this is still set to 'active' if a Task is marked as 'Completed', it resets the Status field to 'In progress' and generates an error. 

The trigger catches the Outlook update and resets the SF Status to 'In progress' correctly in the SF Task when Outlook has changed it to 'Completed', but my problem is it doesn't reset the Outlook Task's status. It leaves it as 'Completed' in Outlook. I would expect the 'Salesforce always wins' conflict settings to update the Outlook Task with what's in SF, but it doesn't.

The Sync log says this:
2015-03-16 10:45:16,344 INFO  Time zone details -> Salesforce Region: Pacific/Auckland. Salesforce Identifier: (GMT+13:00) New Zealand Daylight Time (Pacific/Auckland). Windows Offset: 13:00:00. Windows Identifier: New Zealand Standard Time. Is Windows Daylight Savings: True
2015-03-16 10:45:16,346 INFO  [Task] *********** Starting Sync *********** 
2015-03-16 10:45:16,347 INFO  [Sync] Direction:Sync Conflict Setting:SFDCWins
2015-03-16 10:45:16,349 INFO  [Task]SyncEngine status changed to GettingSalesforceChanges
2015-03-16 10:45:16,353 INFO  [Task]SyncEngine Status: received 0 creates, 0 updates, 0 deletes, and 0 errors from Sfdc Sync Connector
2015-03-16 10:45:16,354 INFO  [Task]SyncEngine status changed to GettingOutlookChanges
2015-03-16 10:45:16,407 INFO  [Task]SyncEngine Status: received 2 creates, 1 updates, 0 deletes, 0 unmapped items, and 0 errors from Outlook Sync Connector
2015-03-16 10:45:16,409 INFO  [Task]SyncEngine status changed to Matching
2015-03-16 10:45:16,410 INFO  Matching 2 Outlook records to Salesforce records by stored SFDC Record ID.
2015-03-16 10:45:16,411 INFO  Retrieving 0 SFDC Records by ID for matching by ID.
2015-03-16 10:45:16,433 INFO  [Task]SyncEngine status changed to DoingConflictDetection
2015-03-16 10:45:16,435 INFO  [Task]SyncEngine status changed to ApplyingSalesforceChanges
2015-03-16 10:45:16,436 INFO  [Task] Filtered 2 Outlook creates based on selective sync settings.
2015-03-16 10:45:16,436 INFO  [Task] Applying changes to Salesforce: 0 creates, 1 updates, 0 deletes
2015-03-16 10:45:17,195 ERROR [Task] Update  to SFDC gave error(s) Sfdc.Server.SfdcServerCreateUpdateException: This Task cannot be completed while it is still active for a Follow-Up!
 for Outlook record Follow-Up on Quote: Quote 535853
2015-03-16 10:45:17,197 INFO  [Task]SyncEngine status changed to ApplyingOutlookChanges
2015-03-16 10:45:17,199 INFO  [Task]Applying changes to Outlook: 0 creates, 0 updates, 0 deletes
2015-03-16 10:45:17,200 INFO  [Task] 1 records being updated with post-sync updates
2015-03-16 10:45:17,214 INFO  [Task]SyncEngine status changed to Finished
2015-03-16 10:45:17,318 INFO  [Task] *********** Finished Sync *********** 

Outlook's Status does not change to 'In Progress' as it is in SF.

User-added image
User-added image

Every subsequent run of the sync process thows the same conflict error and leaves the 2 Tasks NOT synced. 
What am I doing wrong or what should I do to have this working correctly?
My Opportunity Product related list is sorting the Products by Product, not by the sort order I select, which is a unique number. When I view the related list on my Opportunity however, it ignores this and lists the Products by Product instead. I've searched but have not found an answer to this or how to fix it, other than this sort order is fixed by SF and cannot be changed. Why have the option to sort then?

In my searching for a solution the options that have been suggested are to use a custom VF page. Does anyone have a template for this, or is there a better solution?
User-added imageUser-added image
In my Contact trigger I've created a Map based on a query where the Map stores the Account object. It is meant to find the corresponding Account based on the foreign key field customerId, and from which I need to insert the Account's ID and another custom field into the new Contact. When I check on accMap being null, it says it is, but when I use 'isEmpty' it goes into the subsequent code, yet it says there are no values (ie it fails when accessing the values in 'a.Id', saying this statement 'c.AccountId = a.Id;' is referencing a null value).

Can someone tell me what is wrong please?

    Set<string> customerIds = new Set<string>();

    for(Contact c : trigger.new){
        string customerId = c.AccredoCustomerID__c;
        if(!customerIds.contains(customerId)){
            customerIds.add(customerId);
        }
    }

    List<Account> accs = [Select AccredoID__c, Id, AccredoPrimaryContact__c From Account Where AccredoID__c In :customerIds];
    Map<string, Account> accMap = new Map<string, Account>(accs);

    for(Contact c : trigger.new){
        string customerId = c.AccredoCustomerID__c;

       Account a = accMap.get(customerId);

        if(!accMap.isEmpty()){
                Account a = accMap.get(customerId);
                c.AccountId = a.Id;
                if (a.AccredoPrimaryContact__c == c.AccredoId__c){
                    c.Primary_Contact__c = true;
               }
            }
        }
    }
I created a Flow Trigger that is run from a Workflow in my Sandbox, but now that I'm ready to implement it in my live instance, I see that Flow Triggers are no longer supported. How do I go about running the Flow Trigger when my Workflow rules are met now?
Being new to Flows I would like to know how to handle an error in a Flow Trigger. I have a Workflow rule set up which triggers a Flow Trigger, passing the Opportunity record to the Flow Trigger. In this Flow Trigger I loop through Opp Team Members and update a flag, then update these and adding a new entry. What I need to capture however is if no record is found and the Lookup User step to find the new person to add to the OTMs returns a null value. 

I get the error email:
Encountered unhandled fault when running process Update_Opp_TM/301O00000004Ltt exception by user/organization: 00DO0000000VuvS/{4} Source organization: 00D90000000tgIp (null) UPSERT --- UPSERT FAILED ---  ERRORS :  (REQUIRED_FIELD_MISSING) Required fields are missing: [UserId] ---  for SFDC record with ID : null,
 
caused by element : FlowRecordCreate.Create_FollowUp_OTM
 
caused by: UPSERT --- UPSERT FAILED ---  ERRORS :  (REQUIRED_FIELD_MISSING) Required fields are missing: [UserId] ---  for SFDC record with ID : null, 

This is my Flow Trigger:
User-added image
Before it does the Record Create I need to handle the error - it just needs to ignore the error and stop the flow. 
I would like to update the parent record of a master-child relationship when adding a new child (or editing an existing one to update), where the master record is a standard object (Opportunity) and the child record is a custom object (Memo).

I found this code : 
https://help.salesforce.com/apex/HTViewSolution?id=000005280&language=en_US
but it does nothing - doesn't throw any errors, but doesn't do the update either. Can anyone tell me why not, or whether this is the code to use or should it be done differently? This is what I have now, based on the SF code in the article from the link above:

trigger updateOpportunityWithMemoDate on Memo__c (after insert, before update) {
  
     List<Opportunity> opps = new List<Opportunity>();
     Opportunity oppty;

     for(Memo__c memo: Trigger.new)
      {
           oppty = new Opportunity(Id=memo.Opportunity__c);
           oppty.Last_Memo_Date__c = memo.CreatedDate;   //this is a custom DateTime field in Memo
           oppty.Last_Memo__c = memo.Subject__c;             //this is a custom text field
           oppty.Most_Recent_Memo__c = memo.id;              //this is a custom lookup field
           opps.add(oppty);
       }
      
      if(opps.size() > 0)
      Update opps;

}

}

I would like to also do the same when updating/adding an Opportunity Team Member, since this object doesn't have the ability like for example Product, where one can use roll-up summaries etc, so the only way to update something on the Opportunity parent seems to be via a trigger.
When I create an Opportunity Team Member with a specific role, I have a trigger that creates a Task for the Member who is assigned that role (see below). I also have Salesforce for Outlook set up and everything is working nicely in that the Task is created for the user, and the sync between SF and Outlook is working nicely. The only problem is the Outlook Task does not have a link back to the SF Opportunity. I need to somehow get the Opp Name in the Subject or some link back to the Opportunity so the person knows which one the task links to!

The Opp Id is not a very friendly value and the user receiving the notice wouldn't know what to do with it. Does my trigger have to get really complicated and need to do a lookup on the Opp in order to get that info? Is there any way I can insert a url link from the Outlook task back to the Opp in SF?


trigger OpportunityTeamMemberAfterInsert on OpportunityTeamMember (after insert, after update) {

    list<Task> taskNewTask= new list<Task>();
   
    if(trigger.IsInsert)
        {
        for(OpportunityTeamMember oppTeam : trigger.new){
            if (oppTeam.TeamMemberRole == 'Follow-up'){
                Task tasksInsert = new Task();
                tasksInsert.WhatId = OppTeam.Opportunityid;
                tasksInsert.OwnerId = oppTeam.Userid;
                tasksInsert.Subject = 'Follow-Up on Quote: ';
                tasksInsert.ActivityDate = date.today()+7;
                tasksInsert.Priority = 'Normal';
                tasksInsert.ReminderDateTime = date.today()+6;
                tasksInsert.IsReminderSet = true;

                taskNewTask.add(tasksInsert);
                }
            }
        }
    Database.insert(taskNewTask);
 }
I created a VisualForce email template that includes building up an attachment. If I test it from the template it all works nicely and includes the attachment when sending the email.

I then created a custom button on my Order object detail page with a URL (have also tried Javascript) that runs this template. The email is sent but the attachment is nowhere to be found. Debug log doesn't tell me anything so I have no idea what's happening. 
<apex:page standardController="Order" showHeader="false" applyHtmlTag="false" applyBodyTag="false" renderas="pdf">
    <head>
        <style>
            body { 
            font-size:10px;
            font-family: Verdana, Tahoma, sans-serif}
            
            h2 {
            font-size:14px; 
            font-weight: bold; 
            line-height: 16px}
            
            h3 {
            font-size:12px; 
            font-weight: bold; 
            line-height: 14px }
            
            h4 {
            font-size:11px; 
            font-weight: bold; 
            line-height:13px}
            
            table, th, td {
            border-collapse: collapse;
            }
            
            th { font-weight: bold; }
                        
            @page {
                counter-increment: pages;
                @top-center {content: counter(page) " of " counter(pages);}
                @bottom-center {content: element(footer);}
            }
            div.footer {position: running(footer)}
            #pageNum: before {content: counter(pages);}
        </style>        
    </head>
    
    <div class="footer" style="font-size:8pt;text-align:center">

		<p align="center"><i>Copyright {!$Organization.Name}</i></p>
         
        <apex:outputText value="Printed: {! NOW() }"/>
        
    </div>
    <!--Logo and RMA number -->
    <table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
        <tr>
            <td>
                <img src='{!URLFOR($Resource.xx_address)}' title="logo" />
            </td>
        </tr>
        <hr/>
    </table>
    <table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
        <tr>
            <td>
                This number must be attached to all items being returned<br/>
            </td>
            <td align="right">
                <h2>Return Authorisation #: {!Order.OrderNumber}</h2>
            </td>
        </tr>
        <hr/>
    </table>
    
    <!--Addresses -->
    <table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
        <tr>    
            <td width="48%">
                <h4>Customer Details</h4>
                <h3>{!Order.Account.Name}</h3>
                {!Order.Account.BillingStreet}<br/>
                {!Order.Account.BillingPostalCode} {!Order.Account.BillingCity}
                <br/><br/>
                <b>Account Number: </b>{!Order.Account.AccountNumber}<br/>
            </td>
            <td width="4%">&nbsp;</td>
            <td>
		        <apex:outputText value="Date: {0,date,dd' 'MMMM', 'yyyy}">
                    <apex:param value="{!TODAY()}" />
                </apex:outputText><br/>
                <h4>Delivery Address for Return</h4>
                {!$Organization.Name}<br/>
                {!$Organization.Street}<br/>
                {!$Organization.PostalCode} {!$Organization.City}<br/>
                {!$Organization.Country}<br/>
            </td> 
        </tr>
    </table>
    <br/>
    <hr/>
    
    <table border="0" width="100%" id="table2">
        <tr>
            <td>
                <b>Contact name:</b> {!Order.CustomerAuthorizedBy.Name}<br/>
                <b>Contact email:</b> {!Order.CustomerAuthorizedBy.Email}<br/>
                <b>Contact phone:</b> {!Order.CustomerAuthorizedBy.Phone}
            </td>
            <td>
                <b>Created by:</b> {!Order.CreatedBy.Name}<br/>
                <b>Source Order :</b> {!Order.RMA_Source_Order__r.OrderNumber}<br/>
                <b>Source Invoice:</b> {!Order.RMA_Source_Invoice__r.Name}<br/>
                <b>Case:</b> {!Order.RMA_Source_Document__c}
            </td>
        </tr>    
    </table>
    <br/>
    <hr/>
    <table border="0" width="100%" id="table3">
        <tr>
            <td bgcolor="#C0C0C0"><h4>Product</h4></td>
            <td bgcolor="#C0C0C0"><h4>Description</h4></td>
            <td bgcolor="#C0C0C0"><h4>Quantity</h4></td>
            <td bgcolor="#C0C0C0"><h4>Unit</h4></td>
        </tr>
        <apex:repeat value="{!Order.OrderItems}" var="line">
            <tr>
                <td>{!line.PricebookEntry.ProductCode}</td>
                <td>{!line.Description}</td>
                <td>{!line.Quantity}</td>
                <td>{!line.Unit__c}</td>
            </tr>
        </apex:repeat>  
    </table>
    <br/>
    <hr/>
    <br/>
    <p>{!Order.Description}</p>
    <br/>
    <hr/>
    <table width="100%" id="table5">
        <tr>
            <td><b>This is your RMA (Return Maintenance Authority) return form as requested.<br/>
                THE RMA NUMBER ABOVE MUST BE CLEARLY MARKED ON THE OUTSIDE OF THE PARCEL BEING RETURNED</b>
                <br/>
                Please ensure that the goods are sufficiently packaged to ensure that no damage occurs during transit.<br/>
                If you have any queries or, want to follow up on the collection relating to this return, please contact
                xx on <b>0800 xxxxx</b> or <b>email sales@xx.com</b>
            </td>
        </tr>
        <tr>
            <td alight="center">
                <h3>Return Reason - please complete</h3>
			    <table border="1" width="95%" height="100px">
                    <tr><td height="100px"></td></tr>
                </table>
            </td>
        </tr>
    </table>
</apex:page>

Button URL is as below, the template id taken from the above email template.
/_ui/core/email/author/EmailAuthor?p2_lkid=001O000000NYJbV&rtype=003&p3_lkid={!Order.Id}&retURL=%2F{!Order.Id}&template_id=00XO0000000Ek5M
I have a batch job which used to run fine, but since end of last week is throwing an error: 'FATAL ERROR Internal Salesforce Error' every time. 

Developer script from .... exception  : 'OrderItemCleanup' : common.exception.SfdcSqlException: ORA-20145:  ORA-06512: at "DOPEY.BORDERITEM", line 1830 ORA-06512: at line 1   SQLException while executing plsql statement: {call bOrderItem.check_delete_o...

Apex script unhandled exception by user/organization: .../...
Failed to process batch for class 'OrderItemCleanup' for job id '7079000005qLkrQ'

It's a batch job that runs through existing OrderItems and deletes those of a certain type, then updates the parent Order with text and a roll-up summary field.
I tried to log a case but it seems I can't do so anymore, and am directed to the Community here. Having read other posts, it seems to be something I need to log with SF, but I can't. 
Is it possible to display a multiline select or text box on a Visualforce page in a 2 column pageblocksection, without it creating a gap in the other column? Something like a row merge for the 2nd column only. I would like to use the space effeciently - keep all the checkboxes on one side and the multi-select on the other side.
User-added image
I have 2 buttons that toggle between 2 different views (detail and list) of an object (ie all calls for a sales rep) using the sam Controller for both.

In the list view the sales rep or the date can be changed to retrieve for another rep or for another date. When I click the toggle button however to display the detail view again, it displays the original record selected, not the new one I selected in the list view, as the ID parameter in the URL doesn't change when I select a new record.

How do I get it to change the ID in the URL to the latest one, or to pick it up regardless of the URL parameter? In my commandbutton I put in the new ID as below, yet when it loads the detail view through the controller it loads the old one.
<apex:commandButton id="CCActivitiesView" action="{!view}" title="Call Cycle Activities View" value="Call Cycle Activities Detail View" 
        onclick="location.href=('/apex/CallCycleView?id={!CallCycle.Id}')" />
And the code in my Controller is as follows:
public CallCycleController(ApexPages.StandardController std) {

stdCtrl=std;        
CallCycle = (CallCycle__c)std.getRecord();
date ccDate = CallCycle.Date__c;

if(CallCycle != null && CallCycle.Id != null){
    CallCycle = [Select Id, OwnerId, Name, Date__c, CycleStart__c, CycleEnd__c, SalesPerson__c, SalesPerson__r.Name
                 From CallCycle__c Where Id = :CallCycle.Id];
    LoadModel();
}
I've been looking for an answer to this for a while and one person suggested 'move the redirection code into server side', but I don't know what's meant by that (have asked but no reply and am getting a bit more desperate now). 
Hi
I am trying to create a custom clone button on Order Product.

The code I am using is as follows
/{!OrderItem.Id}/e?clone=1

All appears to function correctly until such time as I try to save this new record. I then get the following error:

User-added image
Of which the URL is: https://cs81.salesforce.com/802/e

Is there any way I could reference the OrderId in the RetURL? I think that may fix the problem.

Thanks

Jane
 
We have an integration running hourly from our accounting system to upload data into Salesforce. What I would like to know is, other than manually checking log files, is there an automated way to receive notification if an error occurred, and what the error is?

Currently the only way we can tell is if a user picks up that data which should be in SF isn't there, because they have a document from the accounting system (ie a reference to a quote), and this quote is not in SF (but should be).

Debug logs in SF stop after 20 runs, then one has to refresh, and this can't be reset automatically either, which would be a great thing if it did, as with hourly runs the sync uses up the 20 limit more than once a day!

It would be great if an email could be sent to the Administrator if there were any errors in the sync process. Is this possible to do?
I have a VF page which lists a repeating block of data (a custom object). I can add a new object or delete one. When I add a new one the page displays the newly added object on return from the remote call. When I delete an object however, it does not seem to refresh the page and remove the deleted one.

How do I get it to refresh the page after having deleted something on the page?

This is what my page looks like. When I click on the 'Remove Call Cycle Event' button it runs the Javascript below the image, which calls the @RemoteAction in my controller. What do I need to do for it to remove the block I clicked the button on?
User-added image
In my VF page:
            jCC$(".remCCA").click(function() {
                var ccaId = this.id;
                if(ccaId != ''){
                    CallCycleController.RemoveCallCycleActivity(ccaId, function(result, event){
                        var foo = result;
                        alert('CallCycle Activity has been deleted');
                });
                return false;
            });

In my Controller:
  @RemoteAction
  public static void RemoveCallCycleActivity(string remId){
    CallCycleActivity__c delCCA = [Select Id, ActivityId__c From CallCycleActivity__c Where Id=:remId];
    delete delCCA; 
  }
I need to loop through a table I have on a VF page and hide every row where a checkbox isn't ticked. The first col in each row has the checkbox. How can I do this - help please?

I have some Javascript on the page that used to do this before the table data was in a table, so it was easier then to do it per row, but it didn't look very nice. The table looks great but now I can't hide a row!
Hi,

I have written following class which I want to -
1) run every 10 mintues
2) write a test method to get the 100% code coverage 
3) want to test this code before scheduling to make sure it works as expected.

Will appreciate your help as I am new to Apex.

global class UpdateKBArticleNoOnCase_sched implements Schedulable{

    global void execute(SchedulableContext SC) {
       
       //New Version 2.0
            
      DateTime rightNow =  DateTime.now();
      DateTime d24hAgo = rightNow.addHours(-24);
      
      // Get unique cases for which articles were added....
      
      Set<Id> setid = new Set<Id>();
    
      // for (CaseArticle CasesWithArticle : [Select CaseId from CaseArticle where CreatedDate = YESTERDAY])
      for (CaseArticle CasesWithArticle : [Select CaseId from CaseArticle where CreatedDate > :d24hAgo])
      { setid.add(CasesWithArticle.CaseId); }

      // for (Case cases : [Select Id, KB_Article__c from Case IN CasesWithArticle])
      for (Case cases : [Select Id, KB_Article__c from Case WHERE Id IN :setid])
      {
        
        String AllArticleNos;
        Integer i=0;
        
        List<String> ArticleNumbers = new List<String>();
        for (CaseArticle Articles : [Select KnowledgeArticle.ArticleNumber FROM CaseArticle 
             where CaseId = :cases.Id])
        { ArticleNumbers.add(Articles.KnowledgeArticle.ArticleNumber); 
          if (i == 0)
             AllArticleNos = Articles.KnowledgeArticle.ArticleNumber;
          else
             AllArticleNos += ', '+Articles.KnowledgeArticle.ArticleNumber;
          i++;
        }
        
        System.debug(cases.id + ' ' + AllArticleNos);
                 
        // Update Case
        
        cases.KB_Article__c = AllArticleNos;
        update cases;
    
       }
       
    }
}
I have Salesforce for Outlook setup with the configuration set to 'Sync both ways' and conflict settings to 'Salesforce always wins'. Field mappings are correct.

We auto generate Tasks for Opportunities - a Sales Rep is assigned to follow-up an Opp and is assigned a Task for this. A custom field on the Task sets a flag to indicate that this is a 'follow-up' task. This flag is to separate it from any other Tasks that might be created for the same Opp that are not related to the 'follow-up', and this flag is controlled by trigger code only (or the Administrator manually).

A Sales Rep may not mark this type of Task as 'Completed' - the system trigger does this when the Stage is set to a 'Closed' stage. My problem is that the Sales Reps use mostly Outlook for updating their Tasks, and I can't control them clicking the 'Completed' option in Outlook. 

I created a 'before update' trigger on Tasks in SF, which checks the 'follow-up' custom field flag. If this is still set to 'active' if a Task is marked as 'Completed', it resets the Status field to 'In progress' and generates an error. 

The trigger catches the Outlook update and resets the SF Status to 'In progress' correctly in the SF Task when Outlook has changed it to 'Completed', but my problem is it doesn't reset the Outlook Task's status. It leaves it as 'Completed' in Outlook. I would expect the 'Salesforce always wins' conflict settings to update the Outlook Task with what's in SF, but it doesn't.

The Sync log says this:
2015-03-16 10:45:16,344 INFO  Time zone details -> Salesforce Region: Pacific/Auckland. Salesforce Identifier: (GMT+13:00) New Zealand Daylight Time (Pacific/Auckland). Windows Offset: 13:00:00. Windows Identifier: New Zealand Standard Time. Is Windows Daylight Savings: True
2015-03-16 10:45:16,346 INFO  [Task] *********** Starting Sync *********** 
2015-03-16 10:45:16,347 INFO  [Sync] Direction:Sync Conflict Setting:SFDCWins
2015-03-16 10:45:16,349 INFO  [Task]SyncEngine status changed to GettingSalesforceChanges
2015-03-16 10:45:16,353 INFO  [Task]SyncEngine Status: received 0 creates, 0 updates, 0 deletes, and 0 errors from Sfdc Sync Connector
2015-03-16 10:45:16,354 INFO  [Task]SyncEngine status changed to GettingOutlookChanges
2015-03-16 10:45:16,407 INFO  [Task]SyncEngine Status: received 2 creates, 1 updates, 0 deletes, 0 unmapped items, and 0 errors from Outlook Sync Connector
2015-03-16 10:45:16,409 INFO  [Task]SyncEngine status changed to Matching
2015-03-16 10:45:16,410 INFO  Matching 2 Outlook records to Salesforce records by stored SFDC Record ID.
2015-03-16 10:45:16,411 INFO  Retrieving 0 SFDC Records by ID for matching by ID.
2015-03-16 10:45:16,433 INFO  [Task]SyncEngine status changed to DoingConflictDetection
2015-03-16 10:45:16,435 INFO  [Task]SyncEngine status changed to ApplyingSalesforceChanges
2015-03-16 10:45:16,436 INFO  [Task] Filtered 2 Outlook creates based on selective sync settings.
2015-03-16 10:45:16,436 INFO  [Task] Applying changes to Salesforce: 0 creates, 1 updates, 0 deletes
2015-03-16 10:45:17,195 ERROR [Task] Update  to SFDC gave error(s) Sfdc.Server.SfdcServerCreateUpdateException: This Task cannot be completed while it is still active for a Follow-Up!
 for Outlook record Follow-Up on Quote: Quote 535853
2015-03-16 10:45:17,197 INFO  [Task]SyncEngine status changed to ApplyingOutlookChanges
2015-03-16 10:45:17,199 INFO  [Task]Applying changes to Outlook: 0 creates, 0 updates, 0 deletes
2015-03-16 10:45:17,200 INFO  [Task] 1 records being updated with post-sync updates
2015-03-16 10:45:17,214 INFO  [Task]SyncEngine status changed to Finished
2015-03-16 10:45:17,318 INFO  [Task] *********** Finished Sync *********** 

Outlook's Status does not change to 'In Progress' as it is in SF.

User-added image
User-added image

Every subsequent run of the sync process thows the same conflict error and leaves the 2 Tasks NOT synced. 
What am I doing wrong or what should I do to have this working correctly?
I got this error when i use salesforce connect offline 2.0.
In my Contact trigger I've created a Map based on a query where the Map stores the Account object. It is meant to find the corresponding Account based on the foreign key field customerId, and from which I need to insert the Account's ID and another custom field into the new Contact. When I check on accMap being null, it says it is, but when I use 'isEmpty' it goes into the subsequent code, yet it says there are no values (ie it fails when accessing the values in 'a.Id', saying this statement 'c.AccountId = a.Id;' is referencing a null value).

Can someone tell me what is wrong please?

    Set<string> customerIds = new Set<string>();

    for(Contact c : trigger.new){
        string customerId = c.AccredoCustomerID__c;
        if(!customerIds.contains(customerId)){
            customerIds.add(customerId);
        }
    }

    List<Account> accs = [Select AccredoID__c, Id, AccredoPrimaryContact__c From Account Where AccredoID__c In :customerIds];
    Map<string, Account> accMap = new Map<string, Account>(accs);

    for(Contact c : trigger.new){
        string customerId = c.AccredoCustomerID__c;

       Account a = accMap.get(customerId);

        if(!accMap.isEmpty()){
                Account a = accMap.get(customerId);
                c.AccountId = a.Id;
                if (a.AccredoPrimaryContact__c == c.AccredoId__c){
                    c.Primary_Contact__c = true;
               }
            }
        }
    }
Being new to Flows I would like to know how to handle an error in a Flow Trigger. I have a Workflow rule set up which triggers a Flow Trigger, passing the Opportunity record to the Flow Trigger. In this Flow Trigger I loop through Opp Team Members and update a flag, then update these and adding a new entry. What I need to capture however is if no record is found and the Lookup User step to find the new person to add to the OTMs returns a null value. 

I get the error email:
Encountered unhandled fault when running process Update_Opp_TM/301O00000004Ltt exception by user/organization: 00DO0000000VuvS/{4} Source organization: 00D90000000tgIp (null) UPSERT --- UPSERT FAILED ---  ERRORS :  (REQUIRED_FIELD_MISSING) Required fields are missing: [UserId] ---  for SFDC record with ID : null,
 
caused by element : FlowRecordCreate.Create_FollowUp_OTM
 
caused by: UPSERT --- UPSERT FAILED ---  ERRORS :  (REQUIRED_FIELD_MISSING) Required fields are missing: [UserId] ---  for SFDC record with ID : null, 

This is my Flow Trigger:
User-added image
Before it does the Record Create I need to handle the error - it just needs to ignore the error and stop the flow. 
Hi,

Since a developer is not allowed to create cases with Salesforce directly I was wondering how one can request a pilot to be activated on his development org.
It concerns the pilot "Managing Flow Triggers for Workflow (Pilot)" 

https://help.salesforce.com/HTViewHelpDoc?id=customize_wf_flow_actions.htm&language=en_US

Flow trigger workflow actions are currently available through a pilot program. Available in: Enterprise, Performance, Unlimited, and Developer Editions
For information on enabling this feature in your organization, contact salesforce.com.

Any ideas!?