Skip to main content
Ben Patterson (Pentair) 님이 #Data Management에 질문했습니다
I have a button that executes javascript.  I want it to check a field to see if it contains "pend" (I'm looking for pending, pending3, 3pending, etc.).  The code below finds "pend" and "PEND", but if you throw in other characters it doesn't work.  Any ideas?

 

{!REQUIRESCRIPT("/soap/ajax/27.0/connection.js")}

 

{!REQUIRESCRIPT("/soap/ajax/27.0/apex.js")}

 

if ( {!ISBLANK( SVMXC__Service_Group__c.QADCode__c )} ){

 

alert('This team has no customer code, so we can not ship to them');

 

}

 

else if ({!CONTAINS("PEND", UPPER (SVMXC__Service_Group__c.QADCode__c))} ) {

 

alert('pend error');

 

}

 

else{

 

document.location.href="/apex/SVMX_Create_SalesOrder_ST?id={!SVMXC__Service_Group__c.Id}";

 

}
답변 3개
  1. 2013년 4월 17일 오후 4:36
    Use this:

     

    var pendTest = '{!SVMXC__Service_Group__c.QADCode__c}';

     

    if(pendTest.indexOf("pend") !== -1){

     

        alert("pend found");

     

    }else{

     

        alert("pend not found")

     

    }
0/9000