Page 1 of 1

Getting JSDoc data of a caclulated field in runtime

PostPosted: Thu Jan 11, 2024 5:15 pm
by andre1506345542
Hi

Is het possible to get JSDoc data of a calculated field at runtime.
For superuser we have a datamodel solution, where the get information about all the tables and fields. It also show the description we typed in at a particular field.
But for calculated field we do not have that. Although we have a the info in the JSDoc.
Is there a way to get this JSDoc info of calculated field on runtime.

Thanks for your help
Andre

Re: Getting JSDoc data of a caclulated field in runtime

PostPosted: Thu Jan 11, 2024 7:03 pm
by mboegem
Hi Andre,

something like this should do the job:
Code: Select all
   var _sResult = null;
   
   var _jsDs = solutionModel.getDataSourceNode('db:/<DB_NAME>/<TABLE_NAME>');
   
   if(_jsDs) {
      var _jsCalc = _jsDs.getCalculation('<CALC_NAME>');
      if(_jsCalc) {
         var _sCode = _jsCalc.code;
         var _aMatch = _sCode.match(/\/\*\*([\s\S]*?)\*\//);
         
         if(_aMatch && _aMatch.length) {
            _sResult = _aMatch[0].replace(/@properties.*(\r?\n|$)/g, '');
         }
      }
   }
   
   return _sResult;

Re: Getting JSDoc data of a caclulated field in runtime

PostPosted: Mon Jan 15, 2024 10:38 am
by andre1506345542
Thanks Marc,
Just what I needed. So you learn everyday. :-)
Andre