Skip to main content
Nintex Community Menu Bar
Question

Rock, Rock, Rockaway... Uncaught TypeError: Cannot read property 'length' of undefined


Forum|alt.badge.img+11

Who doesn’t like an Uncaught TypeError after installing a new package?

bfcdfd993bc6fcccb9c8a34273a62049a0bd872a.png

Translate
Did this topic help you find an answer to your question?

19 replies

Forum|alt.badge.img+6
  • Nintex Employee
  • 401 replies
  • July 10, 2024

Page XML? Some idea of what that page is trying to do? Give us something to go on here!

Translate

Forum|alt.badge.img+11

Hey J.,

Yup, probably related to a page XML/model definition.  Experiencing this across two Orgs and different pages. Unfortunately, the stack trace doesn’t give me much to go on, otherwise, I would troubleshoot myself.

I’ve given you login access to one org.  What is the proper channel to provide more context to you?

Thanks, Irvin

Translate

Forum|alt.badge.img+6
  • Nintex Employee
  • 401 replies
  • July 10, 2024

Shoot an email to support@skuid.com with the Org ID, the name of the page that’s giving you problems, any steps to replicate (sounds like previewing the page does it), and anything else you think would be important for us to know. Thanks!

Translate

Forum|alt.badge.img+11

Cool, will do.  Thanks.

Translate

Forum|alt.badge.img+6
  • Nintex Employee
  • 401 replies
  • July 10, 2024

I see the issue, and it’s a bug in Rockaway. It has to do with model subquery conditions that have no sub conditions. Basically, if you don’t have any, you’ll get the error. Adding a sub condition that always returns true (e.g. Id != null) is a workaround. I’ve replicated the issue in my dev org, and logged the bug. The fix looks pretty easy, so I think we can get this turned around pretty quickly. Thanks for helping find issues like this!

Edit: This issue has been resolved in Rockaway Point Release - Iteration 1 (and subsequent releases), available from the Skuid Releases page.

Translate

Forum|alt.badge.img+11

No worries and thanks for the quick turnaround.  I’ll spend more time with the release soon.  Thanks again.

Translate

Forum|alt.badge.img+8

Irvin - I’m experiencing a similar problem from this bug. Would you be willing to paste a sample of what you did to resolve it?

Translate

Forum|alt.badge.img+11

Hi Griffin, Since I only encountered this in a Sandbox, I have not implemented the workaround as J suggested.  Instead, I will wait for the patch.

Workaround: Adding a sub condition that always returns true (e.g. Id != null) is a workaround. 

Translate

Forum|alt.badge.img+8

Irvin - you are a wise and patient soul. I wanted the performance boost too much, I believe. Thanks for the lightning quick response!

Translate

Forum|alt.badge.img+8

J - can you should me an example of what that code would look like?

Translate

Forum|alt.badge.img+6
  • Nintex Employee
  • 401 replies
  • July 10, 2024

I took a look at your other post, and I’m pretty sure that it’s not the same issue as Irvin’s. Your issue is in your snippet. Irvin’s issue is completely a declarative Skuid thing: the error is surfacing from within Skuid code. See this tutorial for our official writeup on how those are specified in the Skuid Composer. I’ll check in on your other post here next, but I wanted to close the loop here first.

Translate

Forum|alt.badge.img+8

I’m having the same issue.  Uncaught TypeError: Cannot read property ‘getSelectedItems’ of undefined.  Has this been resolved?  Thanks!

Translate

Forum|alt.badge.img+8

I think this may be the model that’s causing issues for me. I have a sub-query where the sub-condition is a filter. This is the model that’s referenced in the “getSelectedItems” part of my snippet.

Any suggestions for how I should update this model so I don’t get the error?

Translate

Forum|alt.badge.img+6
  • Nintex Employee
  • 401 replies
  • July 10, 2024

Elissa,

Irvin’s issue had to do with subquery conditions that had no subconditions, and it was resolved in Rockaway - Iteration 1. He was getting…

Uncaught TypeError: Cannot read property 'length' of undefined 

…but you are getting…

Uncaught TypeError: Cannot read property 'getSelectedItems' of undefined

Do you have any custom JavaScript on the page? It’s just a guess, but we’ve seen a couple reports of snippets that needed to be updated for Rockaway and the symptom was this same error message.

Translate

Forum|alt.badge.img+8

Yup, and it looks like the “getSelectedItems()” function is at fault.  

Here’s my snippet: 

var params = arguments[0];var $ = skuid.$;
var records = skuid.$.map(arguments[0].list.getSelectedItems(),function(item){ 
    return item.row.Id; 
    });
    
var models = skuid.model.map();
var cases = models.CasesToCover;
var User = models.CoveringUser;
var newTeamMembers = models.NewCoverageTeam;

    for(var n in records){
        var row = cases.getRowById(records[n]);
    
        if(row !== false){
            var newRow = newTeamMembers.createRow({
                additionalConditions: [
                    { field: ‘ParentId’, value: row.Id },
                    { field: ‘MemberId’, value: User.getFieldValue(User.getFirstRow(),“CoverageUser”) },
                    { field: ‘TeamRoleId’, value: ‘0B7E0000000PBOT’ } ]
            });
        }
    }

newTeamMembers.save();



Do I just need to update this part? 

var records = skuid.$.map(arguments[0].list.getSelectedItems(),function(item){ 
    return item.row.Id; 
    });

Translate

Forum|alt.badge.img+6
  • Nintex Employee
  • 401 replies
  • July 10, 2024

Unless, you’ve got another snippet on that page that’s calling getSelectedItems that is the culprit, that is where it’s breaking down (arguments[0].list is undefined). The advice that JD gave at the end of that other post should work for you.

Translate

Forum|alt.badge.img+8

Still having trouble.  I’ve got this now.  Can you help me figure out where I might be going wrong?  (I know I still have the ‘getSelectedItems’ piece in here, but if I understand the last post correctly, it should be okay so long as I call the table by unique ID first.)


var params = arguments[0];var $ = skuid.$;

    
var table = skuid.$(‘sk-v30sc-347’),
   list,
   items;
if (table.length) {
   list = table.data(‘object’).list;
   items = list.getSelectedItems();
}  
    
    
var models = skuid.model.map();
var cases = models.CasesToCover;
var User = models.CoveringUser;
var newTeamMembers = models.NewCoverageTeam;

    for(var n in items){
        var row = cases.getRowById(items[n]);
    
        if(row !== false){
            var newRow = newTeamMembers.createRow({
                additionalConditions: [
                    { field: ‘ParentId’, value: row.Id },
                    { field: ‘MemberId’, value: User.getFieldValue(User.getFirstRow(),“CoverageUser”) },
                    { field: ‘TeamRoleId’, value: ‘0B7E0000000PBOT’ } ]
            });
        }
    }

newTeamMembers.save();

Translate

Forum|alt.badge.img+6
  • Nintex Employee
  • 401 replies
  • July 10, 2024

I think you’re really close. Check JD’s response again:

table.element.data(‘object’).list

Translate

Forum|alt.badge.img+8

Still no luck.  I’m trying a combo of JD’s and Zach’s earlier response.  Here’s what I have.  I don’t think that the function list.getSelectedItems() is actually getting anything, as when I try to log rows in the console nothing appears. 



var params = arguments[0];
var $ = skuid.$;
    
    
var models = skuid.model.map();
var cases = models.CasesToCover;
var User = models.CoveringUser;
var newTeamMembers = models.NewCoverageTeam;


var table = skuid.$(‘sk-v30sc-347’),
   list,
   items;
   
if (table.length) {
   list = table.element.data(‘object’).list;
   items = list.getSelectedItems();
}  

    for(var n in items){
        var row = cases.getRowById(items[n]);
            console.log('Row: ’ + row);
            console.log('Row Id: ’ + row.Id);
    
        if(row !== false){
            var newRow = newTeamMembers.createRow({
                additionalConditions: [
                    { field: ‘ParentId’, value: row.Id },
                    { field: ‘MemberId’, value: User.getFieldValue(User.getFirstRow(),“CoverageUser”) },
                    { field: ‘TeamRoleId’, value: ‘0B7E0000000PBOT’ } ]
            });
        }
    }

newTeamMembers.save();

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings