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
bkmmspbkmmsp 

Javascript Error on simple List Button

I have created an example list view button and when I click it, I am getting a javascript error:

" A problem with the OnClick Javascript for this button or link was encountered: Expected ';'

The button code is quite simple:

newArray = {!GETRECORDIDS($ObjectType.Task)};
alert(newArray);

This list button works in Contacts and the Activity List View records, BUT NOT for Accounts.  The only thing non-standard is that I am using record types with the accounts.  I have added the button to all list views for all record type layouts.  I am using IE6. 

I think this might be a bug...

Any ideas?

Thanks,

BKM
PBS_IC786PBS_IC786
Try this...

newArray = "{!GETRECORDIDS($ObjectType.Task)}";
alert(newArray);

The double quotes might help since you are bringing in a merge field...

HTHs
sfdcfoxsfdcfox
Double-quotes around the "merge field" won't help, since that's not the problem (actually, you'd get a string that looks like a JavaScript function instead of a list of ID values). My guess is that you have a mismatched quote somewhere else in your code (although I don't see it here, that's the only valid explaination I have). Check your code for an errant quote or double-quote character. I just tested the original code and it worked:

Code:
newArray = {!GetRecordIds($ObjectType.Task)}
alert(newArray)
So... There's a missing or extra quote. If your code looks identical to mine, then I'd view the source code and find the button to figure out what the code looks like "under the hood". Here's what mine looks like:

Code:
 <script  type="text/javascript"></script><script  type="text/javascript">this.__sfdcSessionId = '<my session id is here>'</script><script  type="text/javascript">window.invokeOnClickJS_00b40000000s6Fz = function(element) {
  function getRecordIds(keyPrefix) { return Scontrol.prototype.getSelectedRecordIdsFromForm(element.form, keyPrefix); }

  element.invokeAction = function() { 
    try { eval('newArray = getRecordIds(\'00T\')\r\nalert(newArray)') } catch (e) { alert('A problem with the OnClick JavaScript for this button or link was encountered:\n\n' + (e.message — e.message : e)) }
  };
element.invokeAction();

}</script><input value=" test "  class="btn" name="test" onclick="if (window.invokeOnClickJS_00b40000000s6Fz) window.invokeOnClickJS_00b40000000s6Fz(this); else if (parent.window.invokeOnClickJS_00b40000000s6Fz) parent.window.invokeOnClickJS_00b40000000s6Fz(this); return false" title="test" type="button" />
Looking at the source, it's easy to identify if there's a run-away quote and if it's your fault or not. Check there if all else fails.

~ sfdcfox ~
 

Message Edited by sfdcfox on 07-12-2007 06:04 PM

bkmmspbkmmsp

sfdcfox,

 

Thanks - I will look into as you dexcribe..

BKM