TypeError: undefined is not a function.

Jazz4
Tera Contributor

We recently did a clone from Prod to Dev and before the clone happened the Flow Designer process  was working just fine. Now after the clone the call to a script include in the Global scope is failing with the error "TypeError: undefined is not a function.". The script Include has Accessible from set to "All Application Scope". The statements making the call are as follows:-

                                XFC = new global.DTH_ImportAttUtil(); // This is where it is failing
                                XFC.importAtt(inputs.datasource);  

I have checked out the scope privileges and compared to another similar class instantiation which works just fine but don't see anything glaring. Even checked the Runtime Access Tracking setting on the Scoped Application and it is set to "Enforcing". Re-cloning the instance is not an option. I have recreated the script include a dozen times but nothing seems to do it. 

 

Any clues that would help me?

Thx

 

 
 
 
6 REPLIES 6

TJLillo
Kilo Guru
Normally when I run into that error, it's because I copied another script include and changed the name but not the class name and type. Notice that the name shows up twice at the top of the script and once at the bottom, are those exactly the same as the script include is named?

Jazz4
Tera Contributor

I have checked every word of the code and there is nothing that is amiss. I even tried creating a new script include with all the boxes checked ("All application scopes", "Client Callable") and it still does not work. Seems like I will have to drop the application and redo everything. This makes no sense at all because prior to cloning the instance the exact same code worked just fine.

Does the application still exist in the sys_app table? I've also had issues when I was still doing dev on an app and after a clone I realized I had to pull it back down from source control since it wasn't installed in prod. Or things that pulled down from prod had to be reinstalled from source control because they pulled down as read only since it was installed from the my company apps repo.

Robert Smith
Tera Expert

Sadly this is a pretty generic error (TypeError: "x" is not a function). Here is some useful info from the javascript bible MDN that further explains why you might see this. 

Although, you mentioned a clone. Here are some things that come to mind when I think of clones.

-- During cloning as a dev I have to pull out anything I'm working on in the lower environments, and then replace them back into the instance after the clone. 

           -- This is only a problem if I didn't capture what I think I did in my update set šŸ˜ž and when the script include is run, it doesn't see a script/method at all or something.

-- Another one is if I have a typo somewhere from a different version in my update set. 

Either way, it seems like when you call the Script Include JS doesn't know where to look because JS doesn't think it exists.