I am creating a custom button on a custom object A. The custom object A has multiple accounts related to it. Custom object A has a lookup relation to Account.
In the button logic I am using Button or Link URL option to set the url of button. I wish to pass all the IDs of accounts which are part of custom object A. like:
https://test.salesforce.com/apex/AVisualForcePage?accid="all account id should be passed here"&scontrolCaching=1&sfdc.override=1....
I am trying to figure out how all the account id's(accid parameter) can be passed in this URL. The Javascript code in my Visualforce page has this function to parse the accid parameter:
Question: how can I pass multiple accountid values in the same parameter dynamically? Can you use a custom field on custom object A to store all the id's and set it in URL parameter?
// init method to load appropriate javascript!
var init = function() {
// adds custom contains method
addContainsToString();
// loads the tree based on JSON data
loadTree({!jsonData});
var key = getUrlParameter("accid");
nodeSelection(key);
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
}