function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Neelam BasakNeelam Basak 

I have to write javascript for UI Wizard. Please help!

Hi Experts,

As I don't know much about JavaScript. Please help me on the below issues.

Below are the steps where I need help:
a. When I click on search supplier without entering any keywords the error is displayed "Please provide the supplier name" - which is correct.
b. When the keyword is entered and clicks on search supplier, the result is displayed. - correct
c. Remove the search keyword and click on search supplier button, the validation message and result table are displayed simultaneously. - which is not good. (Expected: only the validation message should be displayed.)

Please help me how to write a proper javascript UI for this as I am new to this.

If required I can share my code.

Thanks.
Jolly_BirdiJolly_Birdi
Hello @Neelam

Can you please share your code.

Thanks
Jolly Birdi
Neelam BasakNeelam Basak
Hi Jolly,

Please find the below codes:

---Vf page---

<div class="slds-form-element__row">
    <div class="slds-form-element slds-size_1-of-5">
         <label class="slds-form-element__label slds-text-title_caps" >
              <h style="color:red;">*</h>Supplier</label>
          <apex:inputtext id="SupplierId" value="{!srchaccnt}" Styleclass="slds-input" />
     </div>
     <div class="slds-form-element slds-size_2-of-5">
           <!--<button class="slds-button slds-button_neutral" >Search Supplier</button>-->
           <div style="padding-top:21px;">
                 <!-- <apex:commandButton value="Search Supplier" onclick="getAccountsfunc()" styleClass="slds-button slds-button_neutral"/> -->
                <input type="button" value="Search Supplier" onclick="getAccountsfunc()" style="background-color: rgba(27, 82, 151, 1.0);border-                                    color:rgba(27, 82, 151, 1.0);color:white;border-radius: 3px;"/>
                <input type="button" id="CreateNewSupplier" value="Create New Supplier" onclick="newsupplier();" style="background-color: rgba(27,
                         82, 151, 1.0);border-color:rgba(27, 82, 151, 1.0);color:white;border-radius: 3px;"/>
                        <!-- <button class="slds-button slds-button_brand" onclick="getAccountsfunc()">Search Supplier</button> -->
             </div>
      </div>
</div>
<div id="errorDiv" style="padding-top: 10px;" >
         <label class="slds-form-element__label slds-text-title_caps" ><h style="color:red;">
                <apex:pageMessages />
          </h></label>
</div>
<!-- data table -->
           <div class="slds-form-element__row" style="display: {!if(showContent,'block','none')};">
                     <div class="slds-form-element slds-size_1-of-1">
                             <body>
                                   <div class="slds .slds-grid">
                                            <table id="table-1">
                                                     <thead>
                                                             <th></th>
                                                             <th>Id</th>
                                                             <th>Name</th>
                                                             <th>Account Number</th>
                                                             <th>Phone</th>
                                                             <th>NDA</th>
                                                       </thead>
                                                       <tbody>
                                                            <apex:repeat value="{!accList}" var="acc">
                                                                    <tr>
                                                                        <td></td>
                                                                        <td>{!acc.Id}</td>
                                                                        <td>{!acc.Name}</td>
                                                                        <td>{!acc.AccountNumber}</td>
                                                                        <td>{!acc.Phone}</td> <!--
                                                                        <td><apex:inputcheckbox value="{!acc.APTS_Valid_Active_NDA__c}" disabled="true"/></td> -->
                                                                        <td><apex:inputcheckbox value="{!acc.APTS_Valid_Active_NDA__c}" rendered="                                                                                                                    {!acc.APTS_Valid_Active_NDA__c}" disabled="true"/></td> </tr> </apex:repeat> </tbody>                                                     </table>
                                    </div>
                         </body>
                    </div>
           </div>

---Apex Class---

public void getAccounts(){
        system.debug('Supplier text'+srchaccnt);
        if(srchaccnt!=null && srchaccnt!=''){
          //  string searchvariable ='%'+srchaccnt+'%';
             string searchvariable =srchaccnt+'%';

            accList = [SELECT Name, AccountNumber, Phone,APTS_Valid_Active_NDA__c FROM Account where name like : searchvariable LIMIT 1000];
            if(accList!=null){
               showContent=true; 
            }
        }else{
            //accList.clear();
             ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Please provide the name of Supplier'));
        }
    }