Skip to main content
Nadeem Anwar 님이 #Data Management에 질문했습니다
Hi All,

 

I need to throw an error message while click of button if one text field is empty.

 

My button is updating picklist field along with current date. Just need to add error message if one field(Text__c) is empty.

 

sharing the code.

 

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

 

var newRecords = [];

 

var c = new sforce.SObject("Opportunity");

 

c.id ="{!Opportunity.Id}";

 

c.opportunity_Status__c = 'On Hold';

 

c.Date__c = new Date();

 

newRecords.push(c);

 

result = sforce.connection.update(newRecords);

 

window.location.reload();
답변 3개
  1. 2014년 2월 6일 오전 8:42
    Hi,

     

    Please try following code:

     

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

     

    var newRecords = [];

     

    var text = "{!Opportunity.Text__c}"

     

    if(text != "" && text != null)

     

    {

     

    var c = new sforce.SObject("Opportunity");

     

    c.id ="{!Opportunity.Id}";

     

    c.opportunity_Status__c  = 'On Hold';

     

    c.Date__c = new Date();

     

    newRecords.push(c);

     

    result = sforce.connection.update(newRecords);

     

    window.location.reload();

     

    }

     

    else

     

    {

     

      alert('Text field is empty');

     

    }

     

    Thanking you,

     

    Arun
0/9000