Dynamic Choice list items using JavaScript?

martinrobinson
Kilo Contributor

I have noticed in the baseline that some Choice list items have javascript labels like:

javascript:"System (" + gs.getSysTimeZone() + ")"

My question is if it's possible to have JavaScript call a function in a script include the same way?

I cannot get this to work using the usual syntax:

javascript: new scriptInclude().getfunction();

I have tried different amalgamations of the two without any success.

Thanks

4 REPLIES 4

ahaz86
Mega Guru

On the script include do you have "Client Callable" checked?


Hello Alex, yes the Client callable checkbox is ticked.


Greg42
Mega Guru

Hi Martin,



You can use either a function or a class.



For functions use:


javascript:myFunction(current)


and name your script include as myFunction with function myFunction(){}



or create a class


var myClass = Class.create();


myClass.prototype = {


  test : function() {


  gs.log("classTest");


  },


  type: "myClass"


}


call your script include as myClass and use it: javascript:new myClass().test()




Cheers



Greg


Hello Greg,



Yep the Script Include is coded ok, there's no issues with that. The issue is with the calling, I wanted to know if people have used this kind of concept then naming Choice list labels and values in the Choice List record.



There is an OOB javascript call in this syntax: javascript:"System (" + gs.getSysTimeZone() + ")"



That works well and I understand the syntax.



My one is something like this: javascript: new scriptInclude().functionName()


or


javascript:'System (' + new scriptInclude().functionName() + ')'



and it's not working.