Regards, Satish Kumar Please mark my answer as a solution if it was helpful so it is available to others as a proper solution. If you felt I went above and beyond, please give me Kudos by clicking on the star icon.
@john4sfdc This is clearly outside my skills. I am not really sure where I would put that in the Java Script:
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")} var metadata = sforce.connection.describeSObject('OpportunityLineItem'); var dontdo = ['TotalPrice']; //Add fields to blank here. Total price or Unit price is needed at minimum var fields = []; for (var i = 0; i < metadata.fields.length; i++) { if (metadata.fields[i].createable == "true" && dontdo.indexOf(metadata.fields[i].name) == -1){ fields.push(metadata.fields[i].name) } } fieldlist = fields.join([separator = ',']) var cloner = sforce.connection.query("SELECT " + fieldlist + " from OpportunityLineItem where id ='{!OpportunityLineItem.Id}' limit 1");
records = cloner.getArray("records");
delete records[0].Id; //records[0].Product_Stage__c = 'Closed Won'; // Manually override any fields down here
result = sforce.connection.create(records); var editparams = ''; //var editparams = "&00N34000004DVHD=Closed%20Won&00X64000002DBDS=&00N24000006XBDp=&ServiceDate=&VT00S53000003CFSA=&DW00D52000002FXGs="; // Any url hacking style parameters you want added to the edit window when we open the cloned object. Can be used to blank a field that was required forcing the agent to override the default. window.location = '/' + result[0]['id'] + "/e?&retURL=" + result[0]['id'] + editparams;
There is a Salesforce article for exactly this requirement.
http://help.salesforce.com/apex/HTViewSolution?id=000003862&language=en_US
Regards,
Satish Kumar
Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.
var url = "{!$Setup.CustomSettingName__c.CustomFieldName__c}";
alert(url);
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
var metadata = sforce.connection.describeSObject('OpportunityLineItem');
var dontdo = ['TotalPrice']; //Add fields to blank here. Total price or Unit price is needed at minimum
var fields = [];
for (var i = 0; i < metadata.fields.length; i++) {
if (metadata.fields[i].createable == "true" && dontdo.indexOf(metadata.fields[i].name) == -1){
fields.push(metadata.fields[i].name)
}
}
fieldlist = fields.join([separator = ','])
var cloner = sforce.connection.query("SELECT " + fieldlist + " from OpportunityLineItem where id ='{!OpportunityLineItem.Id}' limit 1");
records = cloner.getArray("records");
delete records[0].Id;
//records[0].Product_Stage__c = 'Closed Won'; // Manually override any fields down here
result = sforce.connection.create(records);
var editparams = '';
//var editparams = "&00N34000004DVHD=Closed%20Won&00X64000002DBDS=&00N24000006XBDp=&ServiceDate=&VT00S53000003CFSA=&DW00D52000002FXGs="; // Any url hacking style parameters you want added to the edit window when we open the cloned object. Can be used to blank a field that was required forcing the agent to override the default.
window.location = '/' + result[0]['id'] + "/e?&retURL=" + result[0]['id'] + editparams;