Columns list from a custom table class name

Novice User asked on March 2, 2022 01:23

Is there a way through macros or sql to get list of columns of a specified custom table ?

Correct Answer

vasu yerramsetti answered on March 2, 2022 04:37

Novice User - Please check the following custom table macros (Tested from Kentico 12) -

  1. CMSContext.Current.GlobalObjects.CustomTables - it returns list of custom tables
  2. CMSContext.Current.GlobalObjects.CustomTables[0].ClassShowColumns - It returns columns names from first custom table of list

You can also play with macros from System--> Macros --> Console and it is interface to verify all Kentico objects as a Macro.

Reference URLs -

  1. https://www.mattnield.co.uk/blog/testing-macros-in-kentico/

Hope it helps you!!

0 votesVote for this answer Unmark Correct answer

Recent Answers


Novice User answered on March 3, 2022 18:32 (last edited on March 4, 2022 17:54)

Thank you Vasu that worked. I am also trying to get the columns dynamically and I am trying this to no avail

var index ;
var index = 0;
CMSContext.Current.GlobalObjects.CustomTables[index].ClassShowColumns

Is this even possible in macros expression of a dropdown data source? Its wroking perfectly when I replaced index with 0

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.