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
salesforce@reserveadvisors.comsalesforce@reserveadvisors.com 

Javascript GETRECORDIDS on Contract to Return Account Ids

Hi All, I was using the Find Nearby app in the appexchange. We use contracts extensively so I wanted to add a button to access the find nearby mapping. Effectively I retreive the contract Ids and then convert them into account Ids to pass to Find Nearby. I had been using what I believe to be SOQL or AJAX to accomplish this:

 

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} 
var checked = {!GETRECORDIDS($ObjectType.Contract)}; 
var q = "Select Contract.AccountId From Contract Where Contract.Id In " + "('" + checked.toString().replace(/,/g, "','") + "')"; 
var result = sforce.connection.query(q); 
var records = result.getArray("records"); 
var accountids = ""; 
var first = true; 
for (var i=0; i < records.length; i++) { 
var record = records[i]; 
if (first) { 
first = false; 
} else { 
accountids = accountids + ","; 
} 
accountids = accountids + record.AccountId; 
} 
window.location= "/apex/FN__FindNearbymap?alids="+escape(accountids);

 

 

Unfortunately, my button does not work anymore. We use professional edition and we had temporary access to data loader. Due to this fact, we also had API access when we normally shouldn't. I programmed the button unknowingly ignoring the fact that we would lose API access eventually. I am unable to figure out a way to get the account Ids to return. Whatever Objecttype I use, it returns the contract Ids.

salesforce@reserveadvisors.comsalesforce@reserveadvisors.com

I didn't notice my old thread was still "active"... http://boards.developerforce.com/t5/Java-Development/Map-Nearby-Map-Contracts/td-p/432213

 

Is it just me or are these boards just not very active? I feel like this should be a simple question to answer, but yet I spend hours trudging through salesforce help and guides geared towards enterprise and above with no help for professional edition users.

SuperfellSuperfell

It might help if you asked in the ajax  forum which would be more relevant.

salesforce@reserveadvisors.comsalesforce@reserveadvisors.com

Thanks for the reply SimonF.

 

We use the professional edition and as far as I know it is unable to use AJAX. I had programmed the button using information from the AJAX guide, but as I mentioned, we do not have API access anymore.

salesforce@reserveadvisors.comsalesforce@reserveadvisors.com

I would like to just do something like this:

 

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} 
var checked = {!GETRECORDIDS($ObjectType.Contract.Account.AccountId)}; 
window.location= "/apex/FN__FindNearbymap?alids="+checked;

 

It doesn't like the Object Type though obviously.

salesforce@reserveadvisors.comsalesforce@reserveadvisors.com

No help? Is this even possible?

Zachary Alexander 30Zachary Alexander 30
Here is a Javascript button I used. It starts with GETRECORDIDS and moves on to replace that array string with another field's values. Is used to store said list to localStorage.

Please note, the "cycleAccounts" terminology is a misnomer -- should read "cycleCandidates" instead.

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")}
 
var cycleAccounts = new Array();
 
//get parent strings array
var result = {!GETRECORDIDS($ObjectType.Application__c)}.toString().replace(/,/g , "','"); 
var myquery = "SELECT Id, Candidate_ID__c FROM Application__c WHERE Id in ('"+result+"')";
var queryResults = sforce.connection.query(myquery);
var records = queryResults.getArray("records");
 
for (i=0; i < records.length ; i++)

var parent = queryResults.records[i].Candidate_ID__c;
 
cycleAccounts.push(parent);
 
 }
 
if(cycleAccounts.length >= 1){
   localStorage['CycleAccounts'] = cycleAccounts;
   location.replace('/' + cycleAccounts[0]);
}