Custom field renderer snippet in static resource not getting expected arguments.

  • 1
  • Problem
  • Updated 4 years ago
  • Solved
So, here's my field renderer I dropped in a static resource. You'll notice that I'm expecting arguments such that I can set field = arguments[0] and value = arguments[1]. Instead, I'm just getting a field object for arguments.

What am I doing wrong here?


(as an aside, I'm using $r as a shortcut for skuid.snippet.registerSnippet)
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,470 Points 10k badge 2x thumb
"arguments" has special meaning in javascript. I would recommend against using "arguments" as a parameter name.  When you do that I believe it overrides the standard behavior of the arguments array.
(Edited)
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,470 Points 10k badge 2x thumb
$r('renderUserId', function (field,value) {
  
});

and

$r('renderUserId', function () {
  field = arguments[0];
  value = arguments[1];
});

are exactly the same logically
Photo of J.

J., Official Rep

  • 7,470 Points 5k badge 2x thumb
Matt,

Try removing arguments from the function declaration:
$r('renderUserName',function() {
...
});


Alternatively, specify the two arguments and then you don't need the "var field = arguments[0], value =..." bit:
$r('renderUserName',function(field,value) {
...
});
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Sweet! Thanks, Ben and J.