You need to sign in to do that
Don't have an account?
Mike_M_2
Quick Save not saving. Visualforce /Apex (Simple example)
I have a custom object (Revenue_Amount__c) that is the child on a master-detail relationship with Opportunity.
My goal is to have the ability to modify data on the Revenue_Amount__c without leaving the Opportunity screen.
To this end I have created a Visualforce page and an Apex class.
The VF:
When I change an amount and then click on QuickSave, the panel (shown above) refreshes and the new amount value is shown. The behaviour is like you would expect when you do an update. But, when you view the actual Revenue_Amount__c record, the old value is still there.
the log
My goal is to have the ability to modify data on the Revenue_Amount__c without leaving the Opportunity screen.
To this end I have created a Visualforce page and an Apex class.
The VF:
<apex:page standardController="Opportunity" extensions="OpportunityActualList" sidebar="false" showHeader="false"> <apex:form > <apex:pageBlock > <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="QuickSave" action="{!quicksave}"/> <apex:commandButton value="Save" action="{!save}"/> </apex:pageBlockButtons> <input id="theHiddenInput" type="hidden" name="{!Opportunity.Name}" /> <apex:outputPanel layout="block" style="overflow:auto;width:600px;height:606px" > <apex:pageBlockTable value="{!amounts}" var="x" id="list"> <apex:column headerValue="Id"> <apex:inputField value="{!x.Id}"/> </apex:column> <apex:column headerValue="Type"> <apex:inputField value="{!x.Type__c}"/> </apex:column> <apex:column headerValue="Date"> <apex:inputField value="{!x.Fiscal_Date__c}"/> </apex:column> <apex:column headerValue="Amount"> <apex:inputField value="{!x.Dollar_Amount__c}"/> </apex:column> <apex:column headerValue="Show"> <apex:inputField value="{!x.Show_On_Report__c}"/> </apex:column> <apex:column headerValue="Opp"> <apex:inputField value="{!x.Name}"/> </apex:column> </apex:pageBlockTable> </apex:OutputPanel> </apex:pageBlock> </apex:form> </apex:page>Opportunity Controller extension
public class OpportunityActualList { private final Opportunity opp; public OpportunityActualList(ApexPages.StandardController stdController) { this.opp = (Opportunity)stdController.getRecord(); } public ApexPages.StandardSetController setCon { get { if(setCon == null) { setCon = new ApexPages.StandardSetController(Database.getQueryLocator( [SELECT id, MonthlyRevenueAmounts__r.name , Dollar_Amount__c, type__c, Fiscal_Date__c, Show_On_Report__c, Revenue_Amount__c.Name FROM Revenue_Amount__c WHERE MonthlyRevenueAmounts__r.name = :opp.Name and Show_On_Report__c = 'SHOW' and Type__c = 'Actual' order by Fiscal_Date__c desc ])); } return setCon; } set; } public List<Revenue_Amount__c> getAmounts() { return (List<Revenue_Amount__c>) setCon.getRecords(); } }Opportunity screen image. In reality I only need the Date and Amount column.
When I change an amount and then click on QuickSave, the panel (shown above) refreshes and the new amount value is shown. The behaviour is like you would expect when you do an update. But, when you view the actual Revenue_Amount__c record, the old value is still there.
the log
46.0 APEX_CODE,DEBUG;APEX_PROFILING,NONE;CALLOUT,NONE;DB,INFO;NBA,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,NONE 11:08:17.0 (455361)|USER_INFO|[EXTERNAL]|00580000003ZDZy|mmoore@quinstreet.com.mike|(GMT-07:00) Pacific Daylight Time (America/Los_Angeles)|GMT-07:00 11:08:17.0 (497720)|EXECUTION_STARTED 11:08:17.0 (503871)|CODE_UNIT_STARTED|[EXTERNAL]|066220000000ReR|VF: /apex/Opportunity_YoY_Actuals 11:08:17.0 (1228336)|VF_DESERIALIZE_VIEWSTATE_BEGIN|066220000000ReR 11:08:17.0 (8968923)|VF_DESERIALIZE_VIEWSTATE_END 11:08:17.9 (9763059)|SYSTEM_MODE_ENTER|true 11:08:17.10 (10437964)|SYSTEM_MODE_ENTER|true 11:08:17.0 (10999702)|SYSTEM_MODE_ENTER|true 11:08:17.77 (77859418)|SYSTEM_MODE_ENTER|true 11:08:17.0 (85970297)|CODE_UNIT_STARTED|[EXTERNAL]|VF Controller Save 11:08:17.0 (85991440)|SYSTEM_MODE_ENTER|false 11:08:17.0 (134521244)|CODE_UNIT_STARTED|[EXTERNAL]|Validation:Opportunity:00622000002jJP3 11:08:17.0 (134542832)|VALIDATION_RULE|03d80000000PY2P|B2B_Campaign_Objectives_Required 11:08:17.0 (134842407)|VALIDATION_FORMULA|Probability >= 0.5 && RecordTypeId = '01280000000BpSv' && isPickVal (Campaign_Objectives__c ,'--None--' )|RecordTypeId=01280000000Hqet , Campaign_Objectives__c=null , Probability=10.0 11:08:17.0 (134851463)|VALIDATION_PASS 11:08:17.0 (134854689)|VALIDATION_RULE|03d80000000PY2F|B2B_Enhancements_Additions_Required 11:08:17.0 (134952606)|VALIDATION_FORMULA|Probability >= 0.50 && RecordTypeId = '01280000000BpSv' && isBlank ( Enhancements_Additions__c )|Enhancements_Additions__c=null , RecordTypeId=01280000000Hqet , Probability=10.0 11:08:17.0 (134958799)|VALIDATION_PASS 11:08:17.0 (134961891)|VALIDATION_RULE|03d800000006Txv|B2B_MustBeNotNullWhenAccountIsAgency 11:08:17.0 (135194241)|VALIDATION_FORMULA|NOT(ISPICKVAL(Account.Originating_System__c, 'ITBE')) && ISPICKVAL(Category__c, 'Business to Business') && LEN(Client_Name__c) = 0 && ISPICKVAL(Account.Type, 'Agency')|Account.Type=null , Client_Name__c=null , Category__c=null , Account.Originating_System__c=<Not Migrated> 11:08:17.0 (135205236)|VALIDATION_PASS 11:08:17.0 (135208369)|VALIDATION_RULE|03d800000006Txq|B2B_MustBeNullWhenAccountIsClient 11:08:17.0 (135401165)|VALIDATION_FORMULA|NOT(ISPICKVAL(Account.Originating_System__c, 'ITBE')) && ISPICKVAL(Category__c, 'Business to Business') && LEN(Client_Name__c) > 0 && ISPICKVAL(Account.Type, 'Client')|Account.Type=null , Client_Name__c=null , Category__c=null , Account.Originating_System__c=<Not Migrated> 11:08:17.0 (135413060)|VALIDATION_PASS 11:08:17.0 (135416218)|VALIDATION_RULE|03d80000000PY2K|B2B_Topic_Segment_Required 11:08:17.0 (135544996)|VALIDATION_FORMULA|and( Probability >= 0.50 , RecordTypeId = '01280000000BpSv', or (isBlank (Topic_Segment__c),isNull(Topic_Segment__c) ) )|RecordTypeId=01280000000Hqet , Probability=10.0 , Topic_Segment__c=null 11:08:17.0 (135552711)|VALIDATION_PASS 11:08:17.0 (135555512)|VALIDATION_RULE|03d80000000Tidg|Check_CompanyId_Value 11:08:17.0 (135653731)|VALIDATION_FORMULA|AND( (LID__LinkedIn_Company_Id__c <> NULL), NOT(ISNUMBER(LID__LinkedIn_Company_Id__c)) )|LID__LinkedIn_Company_Id__c=null 11:08:17.0 (135661258)|VALIDATION_PASS 11:08:17.0 (135664131)|VALIDATION_RULE|03d80000000TfFC|CSD_user_Stage_restriction 11:08:17.0 (137741521)|VALIDATION_FORMULA|( ISPICKVAL( StageName , 'Close Within (1) Week') || ISPICKVAL(StageName, 'Closed Won') ) && $UserRole.Name = 'B2B Tech Rep' && ISCHANGED( StageName )|StageName=Advanced Negotiations , $UserRole.Name=System Admin 11:08:17.0 (137756366)|VALIDATION_PASS 11:08:17.0 (137759931)|VALIDATION_RULE|03d80000000LHtS|EDU_Product_Month_is_Day_1_of_Month 11:08:17.0 (137871970)|VALIDATION_FORMULA|DAY(EDU_Product_Month__c) <> 1|EDU_Product_Month__c=2019-05-01 00:00:00 11:08:17.0 (137885584)|VALIDATION_PASS 11:08:17.0 (137888747)|VALIDATION_RULE|03d80000000Thle|no_change_account_after_platform_push 11:08:17.0 (138000798)|VALIDATION_FORMULA|PRIORVALUE( AccountId ) <> AccountId && billing_io_key__c <> NULL|AccountId=0012200000IrAZe , billing_io_key__c=null 11:08:17.0 (138007160)|VALIDATION_PASS 11:08:17.0 (138009936)|VALIDATION_RULE|03d80000000TXwy|no_change_system_IO_number 11:08:17.0 (138101947)|VALIDATION_FORMULA|PRIORVALUE( I_O__c ) = AutoIO__c && I_O__c != AutoIO__c|AutoIO__c=234955 , I_O__c=234955 11:08:17.0 (138107478)|VALIDATION_PASS 11:08:17.0 (138110350)|VALIDATION_RULE|03d80000000TZ79|Rep_no_change_total_after_contract_sent 11:08:17.0 (138269689)|VALIDATION_FORMULA|ISCHANGED(Opportunity_Total__c ) && $UserRole.Name = 'B2B Tech Rep' && ( ISPICKVAL(StageName , 'Contract Sent') || ISPICKVAL(StageName , 'Close Within (1) Week') || ISPICKVAL(StageName , 'Closed Won') || ISPICKVAL(StageName , 'Closed Lost') || ISPICKVAL(StageName , 'Void/Cancel') )|StageName=Advanced Negotiations , $UserRole.Name=System Admin , Opportunity_Total__c=null 11:08:17.0 (138279929)|VALIDATION_PASS 11:08:17.0 (138282683)|VALIDATION_RULE|03d80000000TUZK|ValueInPickList 11:08:17.0 (138419726)|VALIDATION_FORMULA|NOT(CONTAINS("Business to Business:Careers:Education:Financial Services:Home Services:Medical and Health:Travel:Advertising", TEXT(Category__c)))|Category__c=null 11:08:17.0 (138427087)|VALIDATION_PASS 11:08:17.0 (138429779)|VALIDATION_RULE|03d80000000Tc5i|B2BTech_Closed_Lost_Description_Required 11:08:17.0 (138598236)|VALIDATION_FORMULA|AND( ISPICKVAL(Account.Sub_category__c,'Business to Business - Tech'), Closed_Lost_Description__c ='', OR(ISPICKVAL(StageName, 'Closed Lost')) )|Closed_Lost_Description__c=null , StageName=Advanced Negotiations , Account.Sub_category__c=null 11:08:17.0 (138606373)|VALIDATION_PASS 11:08:17.0 (138609219)|VALIDATION_RULE|03d80000000Tc5Y|B2BTech_Reason_Lost_Required 11:08:17.0 (138783050)|VALIDATION_FORMULA|AND( ISPICKVAL(Account.Sub_category__c,'Business to Business - Tech'), ISPICKVAL(Reason_Lost__c,''), OR(ISPICKVAL(StageName, 'Closed Lost'),ISPICKVAL(StageName,'Void/Cancel')) )|Reason_Lost__c=null , StageName=Advanced Negotiations , Account.Sub_category__c=null 11:08:17.0 (138793120)|VALIDATION_PASS 11:08:17.0 (138797149)|VALIDATION_RULE|03d80000000TUci|Deal_Type_Total 11:08:17.0 (139156264)|VALIDATION_FORMULA|AND ( Probability >= 0.50, RecordTypeId != '01280000000QEuM', RecordTypeId != '01280000000Bp05', RecordTypeId != '01280000000Bp03', RecordTypeId != '01280000000Bp06', RecordTypeId != '01280000000Bp07', RecordType.Name != 'EDU_BUDGET', ISPICKVAL (Account.Sub_category__c , 'Business to Business - Tech'), NOT(ISPICKVAL(Account.Originating_System__c, 'ITBE')), ( NULLVALUE(Deal_Type_Click__c, 0) + NULLVALUE(Deal_Type_CPA__c, 0) + NULLVALUE(Deal_Type_Display__c, 0) + NULLVALUE(Deal_Type_eSeminar_percent__c, 0) + NULLVALUE(Deal_Type_other_percent__c, 0) + NULLVALUE(Deal_Type_Lead__c, 0) ) != 1 )|Deal_Type_CPA__c=null , Deal_Type_other_percent__c=null , RecordTypeId=01280000000Hqet , Deal_Type_Display__c=null , Probability=10.0 , Account.Originating_System__c=<Not Migrated> , RecordType.Name=EDU Budget , Deal_Type_Lead__c=null , Deal_Type_Click__c=null , Account.Sub_category__c=null , Deal_Type_eSeminar_percent__c=null 11:08:17.0 (139178030)|VALIDATION_PASS 11:08:17.0 (139180862)|VALIDATION_RULE|03d80000000TdkB|InvoiceNotesMax240Chars 11:08:17.0 (139246906)|VALIDATION_FORMULA|LEN(Invoice_Notes__c) > 240|Invoice_Notes__c=null 11:08:17.0 (139252236)|VALIDATION_PASS 11:08:17.0 (139254856)|VALIDATION_RULE|03d80000000Aptd|StageNameIsNotNone 11:08:17.0 (139300766)|VALIDATION_FORMULA|ISPICKVAL(StageName , '--None--')|StageName=Advanced Negotiations 11:08:17.0 (139305707)|VALIDATION_PASS 11:08:17.0 (139313558)|CODE_UNIT_FINISHED|Validation:Opportunity:00622000002jJP3 11:08:17.0 (200133293)|CODE_UNIT_STARTED|[EXTERNAL]|Workflow:Opportunity 11:08:17.0 (227360016)|CODE_UNIT_FINISHED|Workflow:Opportunity 11:08:17.0 (238675011)|CODE_UNIT_FINISHED|VF Controller Save 11:08:17.241 (241425173)|SYSTEM_MODE_ENTER|true 11:08:17.241 (241638407)|SYSTEM_MODE_ENTER|true 11:08:17.0 (242121504)|SYSTEM_MODE_ENTER|true 11:08:17.269 (269720864)|SYSTEM_MODE_ENTER|true 11:08:17.269 (269929739)|SYSTEM_MODE_ENTER|true 11:08:17.0 (339122653)|VF_SERIALIZE_VIEWSTATE_BEGIN|066220000000ReR 11:08:17.0 (342512976)|VF_SERIALIZE_VIEWSTATE_END 11:08:17.0 (346352402)|CODE_UNIT_FINISHED|VF: /apex/Opportunity_YoY_Actuals 11:08:17.0 (347540377)|EXECUTION_FINISHED
Call from visualforce page like:
All Answers
Use pagereference as return type and return null in your action quicksave.
Sorry, I'm not following you. I thought !quicksave is a method on the standard controller. Thanks.
Call from visualforce page like: