2

Issue

How can I redirect a user to a custom list view button with a specific set of records? Was hoping for something like this

{!URLFOR($Action.Account.List_View_Button, accountIds)}

Background

We're adding some usage tracking to some custom buttons in the org that create some conga documents. Our approach has been to create a second button that sends the user to a visualforce page and then redirects the user to the original button. The advantage of this is the tracked button can be modified or changed without messing with the usage tracking.

<apex:page standardController="Account" extensions="AB_LogACallJump" action="{!logUsage}">

<apex:outputPanel rendered="{!usageLogged}">
<script>
    window.top.location.href = '{!URLFOR($Action.Account.Log_A_Call, account.id)}';
</script>
</apex:outputPanel>

</apex:page>

The button above can be launched from the detail page of an account, or from an account list view with multiple selections. We're trying to add tracking for the list view button, but have gotten stuck due to the inability (or ignorance of how) to use URLFOR with list view buttons.

List View Button

// STEP 1: CHANGE THE NEXT LINE TO THE TYPE OF RECORDS YOU'RE ACCESSING ON THE VIEW 
var idArray = {!GETRECORDIDS( $ObjectType.Account )}; 

// STEP 2: CHANGE THE NEXT LINE TO THE API NAME OF THE FIELD THAT CONTAINS THE POINTMERGE URL 
var urlFieldName="Log_A_Call_Pointmerge_Url__c"; 

// DO NOT MODIFY ANYTHING BELOW THIS POINT ******************** 

// YOU MAY PASS UP TO 50 IDS 

var CongaURL = "https://conductor.appextremes.com/apps/Conga/Conductor/LaunchCC.aspx" + 
"?MOID=" + idArray + 
"&SessionId={!$Api.Session_ID}" + 
"&ServerUrl={!$Api.Partner_Server_URL_160}"+ 
"&UrlFieldName="+urlFieldName; 

window.open( CongaURL, "Conga", "width=700,height=450,menubar=0" );
5
  • This is a tricky one, as far as I am aware and recent doc checking seems to indicate, you cannot pass the list of Id's. The issue is going to be that your doing a client side redirect via window.top.location.href and loosing the page state containing the list of records selected. You need to do a server side redirect to maintain this. Do you have any other need to use URLFOR or will another solution that does not use it be ok? Mar 19, 2013 at 5:14
  • Can you update your question with code behind the list view button your wanting to redirect to please. The Log_A_Call one? Mar 19, 2013 at 5:34
  • We have other options, 1) Move code for list view button into the visualforce page and 2) Move code for usage tracking into list view button. I'd like to avoid 1) since it means editing code to change the button behavior and I'd like to avoid 2) since it means the button could be edited and break the usage tracking. Mar 19, 2013 at 5:37
  • Added button text. That said, I'm more curious to find out if there is a way to hack the button post (sounds like no). If that's the case feel free to answer as such "This isn't possible" Mar 19, 2013 at 5:41
  • Ok placed some thoughts in an answer for you. Hope this helps! Mar 19, 2013 at 6:42

1 Answer 1

2

Investigation and Thoughts. I have spent some time noodling this for you...

The core issue is the page state (as in the selected records) is lost once you attempt to redirect to the Conga button via HTTP GET. In your detail page example you could address this by passing the Id in the way in which Salesforce expects it. As you say you may be able to hack output the HTTP logic (whatever GETRECORDIDS requires) from the list view page and emulate this as well. Though this is much more fragile in my view. And is not something I would want to risk putting behind such a mission critical button.

Conclusion. I have to conclude that doing what you want is not possible and that either of your two options from your comments above (copied here for reference) are the only way to retain the selected list of records and retain some semblance of the current button implementations (Conga JS buttons).

  • 1) Move code for list view button into the visualforce page
  • 2) Move code for usage tracking into list view button

My personal preference would be option 1 on balance, since it requires less JavaScript hacking and Web Service exposure of your logging Apex code. Maybe you could have people place the Conga JS snippet code in a Visualforce Component you reference from you page. That way the two stay separate?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.