+ Start a Discussion
Angela SchloederAngela Schloeder 

Custom button - OnClick JavaScript

I have a custom button on the Event to open a pdf with info from event and related task notes. I need to recreate it as an OnClick JavaScript, so that if the Event field '"Approved by:" is blank they receive an alert, but I cannot seem to get to right. I have tried several different senarios and keep getting different errors.

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

IF(ISPICKVAL(!Event.Approved_by__c, "NULL")){ 
   alert("Pre Meeting Notes Need to be Approved First");
}
 else 
{
    window.location = 'apex/EventMeetingNotes';
}
Naveen Rahul 26Naveen Rahul 26
Hello Angela Schloeder,

you can access Picklist field value by using {!Event.Approved_by__c}
directly

highlighted the chnaged part,Check below is working??
 
{!REQUIRESCRIPT("/soap/ajax/36.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/36.0/apex.js")} 
var status = "{!Event.Approved_by__c}";
IF(status!=""){ 
   alert("Pre Meeting Notes Need to be Approved First");
}
 else 
{
    window.location = 'apex/EventMeetingNotes';
}
Thanks
D Naveen Rahul.
 
Angela SchloederAngela Schloeder
I keep getting an error - Unexpected token {
Naveen Rahul 26Naveen Rahul 26
{!REQUIRESCRIPT("/soap/ajax/36.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/36.0/apex.js")} 
var status = "{!Event.Approved_by__c}";
if(status!=""){ 
   alert("Pre Meeting Notes Need to be Approved First");
}
 else 
{
    window.location = 'apex/EventMeetingNotes';
}
the above codes works for me.

i hope this button is used in details screen correct ??.  and Event.Approved_by__c  is in same object right??.

Thanks
D Naveen Rahul.
Angela SchloederAngela Schloeder
User-added image
Angela SchloederAngela Schloeder
[cid:image001.png@01D2DAE1.8B3CA570]
Angela SchloederAngela Schloeder
This Link is on the Event but is a visualforce page that renders as a pdf.
Naveen Rahul 26Naveen Rahul 26
Angela ,

please create a button and select  Behaviour  as Execute Javascript. like below
User-added image
Thanks
Naveen