Skip to main content

Working on a ticket check-in Salesforce1 app. My relevant page code is:

<apex:inputField required="true" styleClass="detail" id="agreementField" value="{!Release_Form__c.DTCI_Agreement__c}">

<apex:param name="Type" value="{!Release_Form__c.DTCI_Agreement__c}" assignTo="{!agreement}"/>

</apex:inputField>

<br/>

<apex:commandButton styleClass="btn" action="{!saveRelease}" value="Submit" title="Submit" immediate="false" />

<br/>

This works great in my sandbox if I'm on my PC, I cannot click the Submit button without checking the box, and if I try to do so, I get the appropriate error message. However, in our demo, we discovered that in Salesforce1, the user could submit and move on without checking the box.

Does anyone know why this might be happening and what workaround I could create? (I'm pretty rough at Javascipt, so if the workaround is Javascript, extra syntax would be awesome)

I can't imagine that this issue is by design.

 

 

 

4 answers
  1. Aug 9, 2015, 3:42 PM
    For whatever reason the javascript solution worked fine on my personal ipad, but failed to work on the organization ipads that would be using the app.

    My ipad is a couple of years old, and was running 7.something.

    The work ipads are Air2 and running iOS 8.4

    But I found another, more elegant solution. Part of the reason I was having so many issues with the different apex solutions I'd been trying was because they were not re-querying my extension controller. 

    I had a 'well, duh' moment when I was testing a different aspect of the app, and tried a simple if-then solution in the "saveRelease" function, so the code now looks like this (I was also unfamiliar with the 'addError' option):

    Page Code:

    <title2>I agree to the above: </title2>

    <apex:inputField required="true" styleClass="detail" id="agreementField" value="{!Release_Form__c.DTCI_Agreement__c}">

    <apex:param name="Type" value="{!Release_Form__c.DTCI_Agreement__c}" assignTo="{!agreement}" />

    </apex:inputField>

    <br/>

    <apex:commandButton styleClass="btn" action="{!saveRelease}" value="Submit" title="Submit" immediate="false" />

    <br/>

    and the extension Controller code looks like this:

    //Release Form Save Button

    public PageReference saveRelease(){

    agreement = releaseForm.DTCI_Agreement__c;

    parentGuardianName = releaseForm.DTCI_Parent_or_Guardian__c;

    if(agreement == FALSE) {

    releaseForm.DTCI_Agreement__c.addError('Please check the agreement box to proceed.');

    return null;

    } else {

    Release_Form__c newRel = new Release_Form__c(DTCI_Attendee__c = attendeeId,

    DTCI_Parent_or_Guardian__c = parentGuardianName,

    DTCI_Agreement__c = agreement);

    insert newRel;

    }

    It works beautifully.

     
0/9000