function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
falfadlifalfadli 

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.

 

Thanks

 

 

//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;

top.location.replace("https://"+window.location.host+"/a06/e?"+opptyField+salesRepField+leadUwField+"&retURL="+oppty);
 

werewolfwerewolf
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.