You need to sign in to do that
Don't have an account?

Visual Force Save Button Inactive After Error
Hello All,
The 'Save' button on my VF page is inactive if a user does not complete all of the required field.
Also, can I chnage the location of the error message? The Save button is at the bottom the screen(mobile) and the user will not see the error at the top of the page.
Thanks,
M
VF Page
The 'Save' button on my VF page is inactive if a user does not complete all of the required field.
Also, can I chnage the location of the error message? The Save button is at the bottom the screen(mobile) and the user will not see the error at the top of the page.
Thanks,
M
VF Page
<apex:page docType="html-5.0" standardController="Account" extensions="SourcingAuditAccountController" standardStylesheets="true" lightningStylesheets="true" showheader="false"> <div id="startLat"> </div> <div id="startLon"> </div> <script> window.onload = function() { var startPos; var geoSuccess = function(position) { startPos = position; document.getElementById('{!$Component.inpform.pb.pbs.startLat}').value=startPos.coords.latitude; document.getElementById('{!$Component.inpform.pb.pbs.startLon}').value=startPos.coords.longitude; //alert('@@@ ' + document.getElementsByClassName('findclass')[0].value); document.getElementsByClassName('Latclass')[0].value =startPos.coords.latitude; document.getElementsByClassName('Lonclass')[0].value =startPos.coords.longitude; }; navigator.geolocation.getCurrentPosition(geoSuccess); }; </script> <script type='text/javascript' src='/canvas/sdk/js/publisher.js'/> <script> Sfdc.canvas.publisher.subscribe({name: "publisher.showPanel", onData:function(e) { Sfdc.canvas.publisher.publish({name:"publisher.setValidForSubmit", payload:"true"}); }}); Sfdc.canvas.publisher.subscribe({ name: "publisher.post", onData: function(e) { Sfdc.canvas.publisher.publish({name:"publisher.setValidForSubmit", payload:"false"}); saveActivity(); }}); </script> <div> <apex:form id="inpform" > <apex:outputPanel id="out"> <apex:actionFunction action="{!Save}" name="saveActivity" rerender="out"/> <div style="display: none;"> <apex:inputField value="{!SourcingAudit.Account__c}" /> ['Name'='Sourcing Audit for {!Account.Name} on system.today().format())' ], true)}"> </div> <apex:outputPanel > <label style="display:block;margin-top:12px;margin-left:10px" for="account_name">Account</label> <span style="margin-left:10px;" id="account_name">{!Account.Name}</span> <label style="display:block;margin-top:12px;margin-left:10px;" for="Contact__c">Select a Contact</label> <apex:inputField style="margin-left:10px;" id="Contact__c" value="{!SourcingAudit.Contact__c}" required="true"/> </apex:outputPanel> <br></br> <apex:outputLabel style="margin-left:10px;" value="Bale Quality Issue"/> <apex:selectRadio required="true" value="{!SourcingAudit.Quality_Bale_Issue__c}" > <apex:selectOption itemValue="Yes" itemlabel="Yes"/> <apex:selectOption itemValue="No" itemlabel="No"/> </apex:selectRadio> <br></br> <apex:outputLabel style="margin-left:10px;" value="Bale Inspected"/> <apex:selectRadio required="true" value="{!SourcingAudit.Bales_Inspected__c}" > <apex:selectOption itemValue="Yes" itemlabel="Yes"/> <apex:selectOption itemValue="No" itemlabel="No"/> </apex:selectRadio> <br></br> <apex:outputLabel style="margin-left:10px;" value="Volume Review"/> <apex:selectRadio required="true" value="{!SourcingAudit.Volume_Reviewed__c}" > <apex:selectOption itemValue="Yes" itemlabel="Yes"/> <apex:selectOption itemValue="No" itemlabel="No"/> </apex:selectRadio> <br></br> <apex:outputLabel style="margin-left:10px;" value="Weight Issue"/> <apex:selectRadio required="true" value="{!SourcingAudit.Weight_Issues__c}" > <apex:selectOption itemValue="Yes" itemlabel="Yes"/> <apex:selectOption itemValue="No" itemlabel="No"/> </apex:selectRadio> <br></br> <apex:outputLabel style="margin-left:10px;" value="Admin Review"/> <apex:selectRadio required="true" value="{!SourcingAudit.Admin_review__c}" > <apex:selectOption itemValue="Yes" itemlabel="Yes"/> <apex:selectOption itemValue="No" itemlabel="No"/> </apex:selectRadio> <br></br> <apex:outputLabel style="margin-left:10px;" value="Referral"/> <apex:selectRadio required="true" value="{!SourcingAudit.Referral__c}" > <apex:selectOption itemValue="Yes" itemlabel="Yes"/> <apex:selectOption itemValue="No" itemlabel="No"/> </apex:selectRadio> <apex:outputPanel > <label style="display:block;margin-top:12px;margin-left:10px;" for="comments">Comment</label> <apex:inputTextarea style="margin-left:10px;" id="Audit_Comment__c" rows="3" cols="30" value="{!SourcingAudit.Audit_Comment__c}" /> </apex:outputPanel> </apex:outputPanel> </apex:form> </div> </apex:page>
public class SourcingAuditAccountController{ private Sourcing_Audit__c SourcingAudit; private Account Account; public String defaultCheck{get;set;} public string calljavascript {get; set;} public string message {get; set;} public SourcingAuditAccountController(ApexPages.StandardController controller) { Account = [SELECT Id, Name FROM Account WHERE Id =: controller.getId()]; SourcingAudit = new Sourcing_Audit__c(); SourcingAudit.Account__c = Account.Id; if(defaultCheck==NULL) {defaultCheck='Winchester';} } public string PostSaveMessage {get; set;} public string Close {get; set;} public Sourcing_Audit__c getSourcingAudit() { return SourcingAudit ; } public Account getAccount() { return Account; } public PageReference Save() { RecordType rt; if(SourcingAudit.Audit_Location__c!= null) rt = [Select Id From RecordType Where DeveloperName = 'Warehouse' And sObjectType = 'Sourcing_Audit__c']; else rt = [Select Id From RecordType Where DeveloperName = 'Facility' And sObjectType = 'Sourcing_Audit__c']; SourcingAudit.RecordTypeId = rt.Id; System.debug('In Save method.'); try { Insert SourcingAudit; PageReference pg = new PageReference('/'+SourcingAudit.Id); pg.setRedirect(true); return pg; } catch (Exception ex) { string message = ex.getMessage(); ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Fatal, message)); return null; } } }
All Answers
Thanks,
M