You need to sign in to do that
Don't have an account?
Sagar104
A problem with the OnClick JavaScript for this button or link for the below code
Hi All
Im getting the below code error (A problem with the OnClick JavaScript for this button or link for the below code. aX63....(salesforce id) is not defined) for the execute javascript on the button
Original Code :
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
if('{!$Profile.Name}' == '1234') {
alert("This feature is reserved for Administrators and Managers, Please Contact your supervisor...");
}else{
var r = confirm("Are you sure you want to reject this request? It will be removed from the Events Calendar.");
if(r == true){
try{
var result;
result = sforce.apex.execute("TechEvetLineRejectClass", "LineReject",{TELID:"{!Technician_Event_Lines__c.Id}"});
alert("Successfully Calendar Event Deleted... ");
window.location.reload();
} catch(ex) {
alert({!Technician_Event_Lines__c.Id});
alert(ex);
}
}
}
SECONDLY i need to add a logic here that
if Timeoff(a field with date value) is Less than todays date , Then need to throw an alert and the button on click should not work.
Kindly help
Im getting the below code error (A problem with the OnClick JavaScript for this button or link for the below code. aX63....(salesforce id) is not defined) for the execute javascript on the button
Original Code :
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
if('{!$Profile.Name}' == '1234') {
alert("This feature is reserved for Administrators and Managers, Please Contact your supervisor...");
}else{
var r = confirm("Are you sure you want to reject this request? It will be removed from the Events Calendar.");
if(r == true){
try{
var result;
result = sforce.apex.execute("TechEvetLineRejectClass", "LineReject",{TELID:"{!Technician_Event_Lines__c.Id}"});
alert("Successfully Calendar Event Deleted... ");
window.location.reload();
} catch(ex) {
alert({!Technician_Event_Lines__c.Id});
alert(ex);
}
}
}
SECONDLY i need to add a logic here that
if Timeoff(a field with date value) is Less than todays date , Then need to throw an alert and the button on click should not work.
Kindly help
Please try out this and let me know if it works.
thanks for your efforts here, but its not working as expected.
below is the error im geeting
first its population the page id like a6XV00000008UkS
after Ok Click then the attached file error msg im getting.
The class for error is mentioned below;
global class TechEvetLineRejectClass {
Public static Technician_Event_Lines__c TEL;
Public static Event Evnt;
webservice static void LineReject(ID TELID) {
System.debug('------TELID--------'+TELID);
TEL =[Select Id ,Technician_Event__c, Request_Event_Line_Status__c from Technician_Event_Lines__c where ID =: TELID];
TEL.Request_Event_Line_Status__c ='Rejected';
Update TEL;
Evnt=[Select Id, Subject,WhatID,StartDateTime,EndDateTime,Operation_Line_ID__c,Description From Event Where Operation_Line_ID__c=: TELID];
Delete Evnt;
}
}
The main requirement here is if click of button this salesforce event shall get rejected and that event from calender also shall be deleted.
part two is if the time off date is less than today date, then that button shouldnt execute ..
can you plz share your email, for further conversation if you don mind.
Apex Class JavaScript Code Please feel free to ask if you still have doubts.
I have landed in No Man's land :P
firstly is your given code had compile issues so i just changed as per the below;
Secondly in javascript when i saved your code , after click of reject event its giving Are sure you want to delete.....
After Ok click then the below ;
({message:'The Technician Event Line has been marked as rejected. No Event(s) were found that needs to be deleted.', status:'true', })
Third during my investigation in Events in not getting this field Operation_Line_ID__c .. may be it exists or not exists..
Now how do i proceed??
Modified Class :
global class TechEvetLineRejectClass {
global class Response {
webService String message;
webService Boolean status;
public Response( Boolean status, String message ) {
this.message = message;
this.status = status;
}
}
webService static Response rejectEventLine( String evtLineId ) {
try {
List<Technician_Event_Lines__c> techEventLines = new List<Technician_Event_Lines__c>();
List<Event> events = new List<Event>();
techEventLines = [Select Id ,Technician_Event__c, Request_Event_Line_Status__c from Technician_Event_Lines__c where ID =: evtLineId];
if( !techEventLines.isEmpty() ) {
techEventLines[0].Request_Event_Line_Status__c = 'Rejected';
UPDATE techEventLines;
events = [Select Id, Subject,WhatID,StartDateTime,EndDateTime,Operation_Line_ID__c,Description From Event Where Operation_Line_ID__c=:techEventLines[0].Id];
if( !events.isEmpty() ) {
DELETE events;
return new Response( TRUE, 'The Technician Event Line has been marked as rejected and the Event has been deleted.' );
}
return new Response( TRUE, 'The Technician Event Line has been marked as rejected. No Event(s) were found that needs to be deleted.' );
}
return new Response( FALSE, 'No Technician Event Line record was found!' );
}
catch( Exception ex ) {
return new Response( FALSE, ex.getMessage() );
}
}
}
Modified Javascript :
{!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/39.0/apex.js")}
if( "{!$Profile.Name}" === "XYZ" ) {
alert( "This feature is reserved for Administrators and Managers. Please contact your Supervisor." );
}
else if( new Date( "{!Technician_Event_Lines__c.TimeOff__c}" ) < new Date() ) {
alert( "<INSERT YOUR MSG HERE>" );
}
else {
var choice = confirm( "Are you sure you want to reject this request ? It will be removed from the Events Calendar." );
if( choice ) {
var result = sforce.apex.execute(
"TechEvetLineRejectClass",
"rejectEventLine",
{
evtLineId : "{!Technician_Event_Lines__c.Id}"
}
);
alert( result.message );
if( result.status ) {
location.reload();
}
}
}
Kindly let me how to proceed
faheem.sayed13@gmail.com