Skip to main content
Hello . I have an object "Human resource request", where I want to have a Detailed page button Javascript, when clicked on by user, to direct them to another object "Retirements and Benefits"  - to either take me to the object, or start creating a new request in the Retirements and Benefits object. Could I get some help? I found this code, modified it but I get errors. 

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

getDate = function(dateObj)

{

var day = dateObj.getDay() < 9 ? '0'+dateObj.getDay() : dateObj.getDay();

var month = dateObj.getMonth() < 9 ? '0'+dateObj.getMonth() : dateObj.getMonth();

return dateObj.getFullYear()+'/'+month+'/'+day;

}

var rbcase = new sforce.SObject('Retirements_and_Benefits__c');

rbcase.CreatedBy = "{!User.Id}";

rbcase.Stage__c = 'Draft';

rbcase.CreatedDate = getDate(new Date();

result = sforce.connection.create([rbcase]);

if(result[0].success == 'true')

{

alert('A New Retirements and Benefits case with Record ID -' +rbcase.ID+ 'was Created Successfully.');

}
2 Antworten
0/9000