+ Start a Discussion

getting some server url properties dynamically for related list custom button

Hi all,


I am creating a custom button on a related list off the Opportunity object. The button is to open the edit fields of a new related object and pass in a few default fields. 


The code below works, but I want to try and avoid hard coding the  '/a06/e?'string while building the URL. It does not appear to be part of the 'window.location.host'.....any advice how to get this dynamically would be appreciated.





//define fields to obtain from Opportunity to be sent to the case edit page
var opptyName="{!Opportunity.Name}";
var oppty ="{!Opportunity.Id}";
var salesRep = "{!Opportunity.OwnerFullName}";
var leadUw = "{!Opportunity.Lead_UW__c}";

//define default fields to set for redirect
var opptyField = "CF00N300000039AI6="+opptyName;
var salesRepField ="&CF00N300000039QwI="+salesRep;
var leadUwField ="&CF00N300000039AIY="+leadUw;


That 3-char ID is called the ID Prefix, and it is available via the web services API, but I don't think it's exposed in the AJAX Toolkit so you may have a hard time getting to it from Javascript.