Getting JSDoc data of a caclulated field in runtime

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Getting JSDoc data of a caclulated field in runtime

Postby andre1506345542 » Thu Jan 11, 2024 5:15 pm

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
andre1506345542
 
Posts: 42
Joined: Mon Sep 25, 2017 3:19 pm

Re: Getting JSDoc data of a caclulated field in runtime

Postby mboegem » Thu Jan 11, 2024 7:03 pm

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;
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1752
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Getting JSDoc data of a caclulated field in runtime

Postby andre1506345542 » Mon Jan 15, 2024 10:38 am

Thanks Marc,
Just what I needed. So you learn everyday. :-)
Andre
andre1506345542
 
Posts: 42
Joined: Mon Sep 25, 2017 3:19 pm


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 26 guests