0

In the first execution checkNumber takes the value from visualforce page properly.But after that sometimes checkNumber takes null value and shows the 'Please enter at least one search criteria' error message.Is there something wrong with my code and is there another reason for something like this to happen?


Visualforce Page code block

<div class="slds-col">
                                <div class="slds-form-element">
                                    <div class="slds-form-element__control slds-input-has-icon slds-input-has-icon--left slds-m-around--medium">
                                        <svg aria-hidden="true" class="slds-input__icon slds-icon-text-default">
                                            <use xlink:href="{!URLFOR($Resource.SLDS103,'/assets/icons/utility-sprite/svg/symbols.svg#search')}"></use>
                                        </svg>
                                        <input id="number" value="{!checkNumber}" class="slds-input" type="text" placeholder="Check Number"/>
                                    </div>
                                </div>
                            </div>


Controller

public String checkNumber { get; set; }
public List<DME_WrapperCheck> doGenerate() {

    system.debug('***checkNumber***'+checkNumber);

        //general query string for paid items without filter criteria by check date or number
        String queryString = 'SELECT Order__r.DME_Injury__r.Person__r.LastName, Order__r.DME_Injury__r.Person__r.FirstName, '
                        + 'Bill_Line_Item__r.Bill__r.ProviderInvoice__c, DOS_From__c, Product__r.ProductCode, Product__r.Name, '
                        + 'Quantity__c, Bill_Line_Item__r.Linecharge__c, Discount_Amount__c, APR__c, Bill_Line_Item__r.Name, '
                        + 'Bill_Line_Item__r.Denial_Reason__c, Bill_Line_Item__r.Bill__r.Id, Bill_Line_Item__r.Bill__r.Trading_Partner__r.Name, '
                        + 'Check_Number__c, Check_Paid_Amount__c, Check_Paid_Date__c, Bill_Line_Item__r.Bill__r.Trading_Partner__r.Id, '
                        + 'Bill_Line_Item__r.Bill__r.Trading_Partner__r.RA_Doc_Type_Preference__c, Bill_Line_Item__c, '
                        + 'Bill_Line_Item__r.Compliance_Reason__c, Bill_Line_Item__r.Duplicate_Check_Amount__c, Bill_Line_Item__r.Duplicate_Check_Number__c, '
                        + 'Bill_Line_Item__r.Bill__r.Trading_Partner__r.RA_Delivery_Preference__c, Bill_Line_Item__r.Reasoncode__c '
                        + 'FROM DME_Service_Item__c '
                        + 'WHERE (Paid__c = TRUE) AND (Check_Paid_Amount__c <> null AND Check_Paid_Amount__c <> 0 AND Check_Number__c <> \'\') '
                        + 'AND ';

        //append check date and number filter to query string
        if(this.checkDate != null) {

            if(this.checkNumber != '' && this.checkNumber != null) {

                queryString += '(Check_Paid_Date__c = ' + formattedStringDate + ' AND Check_Number__c = \''+ checkNumber + '\') ';
                run = true;

            } else {

                queryString += '(Check_Paid_Date__c = ' + formattedStringDate + ') ';
                run = true;

            }

        } else if(this.checkNumber != '' && this.checkNumber != null) {  

            queryString += '(Check_Number__c = \'' + checkNumber + '\') ';
            run = true;

        } else {

            showError = true;
            errorMsg = 'Please enter at least one search criteria';

        }
3

I would have used apex:input here; AFAIK a plain HTML input won't be bound to the controller field when the page is posted to the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.