How to specify include field in member function


If I want to get value of a field inside the member function, I could do

data = this.get('myField');
// data.myField will contain value of myField

Is it possible we could put some annotation when declaring member function, so that value of myField is automatically available on this, and we don’t need to do this.get('myField')?

P.S., I tried below annotations, but none of them work

myFunction: member function(): js server
myFunction: member function(): js server


The get function, as you observed does allow you to specify an include spec. Without the include spec, all fields that are part of the obj (e.g. fkey arrays are not included and external references return only the id). If you are defining your own function you can of course have an include parameter as well or do whatever you want in your function.



@trothwein to follow-up on this, very often we start the body of a function foo(arg1: string, arg2: SomeType, arg3: SomeOtherType) with something like:

if (arg2.some_other_field_that_we_need == undefined) {
arg2 = arg2.get(“this, some_other_field_that_we_need, …”) ;
if (arg3.some_other_field_that_we_need == undefined) {
arg3 = arg3.get(“this, some_other_field_that_we_need, …”) ;

this adds complexity to the code.

Would that make sense to add a functionality on function declaration so that:

  1. We require some fields on some of the parameters in order to run the function. Otherwise an error message will be thrown (similar to !)
  2. The platform will automatically check that the objects passed contained required fields, if not it will include them automatically.