+ Start a Discussion
Angela SchloederAngela Schloeder 

Inline edit: text has to turn orange to save???

When editing the field I have to click out of the field so it turns orange, only then will the change save. Hope that makes sense. I really am not sure what I'm doing. I'm trying to fix and clean up what a freelance developer created.

Any ideas or help is greatly appriciated.

VF Page:

<apex:page controller="MeetingBacklogController" tabStyle="Event">
    <apex:sectionHeader title="Event" subtitle="Meeting Backlog" />
    <apex:form id="form">
    <apex:pageBlock mode="inlineedit" >
            <apex:pageBlockButtons >
                <apex:commandButton rendered="{!eventsList.size>0}" value="Save" action="{!save}" reRender="form" status="status" />
                <apex:commandButton value="Refresh" action="{!refresh}" reRender="form" status="status" />
                <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
                <apex:actionStatus startText="Updating..." id="status" />
            </apex:pageBlockButtons>
            
            <apex:pageMessages />
            <apex:pageMessage severity="info" rendered="{!eventsList.size=0}">
                No records found
            </apex:pageMessage>
            <apex:pageBlockTable rendered="{!eventsList.size>0}" value="{!eventsList}" var="event">
                <apex:column headerValue="{!$ObjectType.Event.fields.Set_By__c.Label}" value="{!event.Set_By__c}" />
                <apex:column headerValue="{!$ObjectType.Event.fields.Attendee__c.Label}" >
                <apex:outputField value="{!event.Attendee__c}" />
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Event.fields.Meeting_Progression__c.Label}">
                <apex:outputField value="{!event.Meeting_Progression__c}" />
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Event.fields.Client_Invites__c.Label}">
                    <apex:outputField value="{!event.Client_Invites__c}" />
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Event.fields.Exec_Invites__c.Label}">
                    <apex:outputField value="{!event.Exec_Invites__c}" >
                         </apex:outputField>
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Event.fields.Meeting_Status__c.Label}">
                    <apex:outputField value="{!event.Meeting_Status__c}" >
                         </apex:outputField>
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Event.fields.Location.Label}" >
                <apex:outputField value="{!event.Location}" >
                         </apex:outputField>
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Event.fields.StartDateTime.Label}" >
                <apex:outputField value=" {!event.StartDateTime}" >
                <apex:inlineEditSupport />
                 </apex:outputField>
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Account.fields.Name.Label}" value="{!event.AccountId}" />
                <apex:column headerValue="{!$ObjectType.Contact.fields.Name.Label}" value="{!event.WhoId}" />
                <apex:column headerValue="{!$ObjectType.Contact.fields.Title.Label}" value="{!relatedRecords[event.WhoId]['Title']}" />
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex Controller:

public with sharing class MeetingBacklogController
{

    public String events { get; set; }
    public List<Event> eventsList{get; set;}
    public Map<Id, sObject> relatedRecords{get; set;}
    
    private Map<Id, Event> originalEventsMap;
    
    public MeetingBacklogController()
    {
        init(true);
    }
    
    private void init(Boolean updateUI)
    {
        Set<String> meetingProgressionValues=new Set<String>();
        for(PicklistEntry entry: Event.Meeting_Progression__c.getDescribe().getPicklistValues())
        {
            if(entry.getValue().startsWithIgnoreCase('M') || entry.getValue().startsWithIgnoreCase('Conf'))
            {
                meetingProgressionValues.add(entry.getValue());
            }
        }
        
        originalEventsMap=new Map<Id, Event>([
            SELECT Id, Set_By__c, Attendee__c, Meeting_Progression__c, Exec_Invites__c,
                Client_Invites__c, Meeting_Status__c,
            ActivityDate, StartDateTime, AccountId, Account.Name, WhoId, Who.Name, Who.Title,
            Location, IsChild
            FROM Event
            WHERE StartDateTime=NEXT_N_DAYS:90
            AND Meeting_Progression__c IN :meetingProgressionValues
            AND Meeting_Status__c NOT IN ('CCLP','CP','CC','MP','MC','AM')
            AND IsChild=false
        ]);
        
        relatedRecords=new Map<Id, SObject>();
        for(Event record: originalEventsMap.values())
        {
            relatedRecords.put(record.WhoId, Null);
        }
        relatedRecords.putAll([SELECT Title FROM Lead WHERE Id IN :relatedRecords.keySet()]);
        relatedRecords.putAll([SELECT Title FROM Contact WHERE Id IN :relatedRecords.keySet()]);
        relatedRecords.put(Null, new Contact());
        
        eventsList=new List<Event>();
        if(updateUI)
        {
            eventsList=originalEventsMap.values().deepClone(true, true, true);
            eventsList.sort();
        }
    }
    
    public void refresh()
    {
        init(true);
    }
    
    public void save()
    {
        List<Event> eventsToBeUpdateList=new List<Event>();
        
        for(Integer i=0; i<originalEventsMap.values().size(); i++)
        {
            for(Integer j=0; j<eventsList.size(); j++)
            {
                if(originalEventsMap.values()[i].Id==eventsList[j].Id && originalEventsMap.values()[i]!=eventsList[j])
                {
                    eventsToBeUpdateList.add(eventsList[j]);
                    system.debug('eventsList[j]---->'+eventsList[j]);
                    break;
                }
            }
        }
        Boolean updateUI=true;
        
        try
        {
            Integer numberOfRecordsUpdated=0;
            for(Database.SaveResult result: Database.update(eventsToBeUpdateList, false))
            {
                updateUI&=result.isSuccess();
                if(result.isSuccess())
                {
                    numberOfRecordsUpdated=numberOfRecordsUpdated+1;
                }
            }
            
            init(updateUI);
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, numberOfRecordsUpdated+' record'+(numberOfRecordsUpdated==1?'':'s')+' saved.'));
        }
        catch(Exception e)
        {
            ApexPages.addMessages(e);
        }
    }
}
Abhishek BansalAbhishek Bansal
Hi,

You can use the "changedStyleClass" attribute of InlineEdit support.
May be that can help you to achieve what you want.

Let me know if i can help you more on this.

Thanks,
Abhishek