Hello !

I created an web application and on a page I want to integrate a custom personnal component. The component is a the timeline from vis.js but extended. I integrated my timeline from vis.js and with my javascript file( the extension) but when I try to use my timeline, a lot of functions are not known.

I got these errors : 

"Uncaught TypeError: item.saveStart.setHours is not a function"

"Uncaught TypeError: item.onTaskResizing is not a function" 

where "onTaskResizing" is one of my function defined in my javascript file. And it's the same for all my function defined in this javascript file. But the file is read because the initiliasation of the timeline (made at the beginning of this file) is done.

Do you have an idea why my functions are not recognized?

Hi Adrien,

For all we know it could be a bug in your code :). I'd advise you to use your browser's development tools to see whether the JavaScript file is indeed loaded, and inspect the components via the Console. That'll give you a lot of information to infer why you get these errors.

Thanks for your answer !

But in the console I can see my script and my function. I have something like that :

At the begining I call the "prepareItems" function. In this one, I do : 

item.onTaskResizing = _onTaskResizing.bind(self);

and after that, in the initialization, I tried to do :

if (item.onTaskResizing(item)) {

And I have this function :

function _onTaskResizing(resizingTask) {
    //do something

I think, maybe, the problem is that "item" has a structure with some fields but none is the function name.

Do you think is could be the problem and if yes, how I could fix it ?

Well, again, if you use the console properly, you can quickly check what fields "item" has. You could set a breakpoint at the "if (item.onTaskResizing(item))", and then inspect item in the console.

Yes, I can see the fields of "item" and I know them.

But what I don't know is how I could do something like "item.functionName". I think "item" can just have data in the defined fields (in the structure) and we can not add a function to the item. Do am I wrong ?

Hi Adrien,

Well, the easy answer would be that you're trying to use JavaScript while you're not very knowledgeable on JavaScript :). In JavaScript, objects are just containers of dynamic key/value pairs, so yes, you can add new key/value pairs on the fly. If it wasn't possible to do "item.onTaskResizing = _onTaskResizing.bind(self);", you'd see an error in the console, and nothing would run at all.

I thought maybe with Outsystems it was not possible... But if you say it should work normally, I don't understand why I have my errors... The functions should be call normally. So, you don't have a proposition of solution ?

Hi Adrien,

Not directly. If you were experienced in JavaScript, you could probably find the problems yourself, but since you are not, there could be all kinds of things wrong with it. JavaScript is basically not something you should try if you don't know it well.

But I think the problem doesn't come from Javascript but from Outsystems or its way to work. Because I use my javascript file in another project (without outsystems) and it works well.

Since you are not trying to integrate your JavaScript with OutSystems JavaScript, I see no reason it shouldn't work then. But again, set breakpoints, inspect your objects, see what's happening. If you don't know how to do that there's little I can do.

Thanks for your answer ! 

I will see and come back if I need !

Just as a side note, 

If the exactly same javascript works in another project, I would say that your adaptation to OutSystems is not correct.

For example, you may be trying to use the "functions" before they are really defined.

Eduardo Jauch