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 respuestas
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