Getting field names of an object

Hello Community,


We have a requirement for fetching all the column names of an object using source code.


I have taken this community post as reference and tried.


As per the article, the below code is used for fetching the column names after fetching the entity collection.

 titleColumnCaption = entity.Schema.Columns.GetByName("Title").Caption.Value;

But the code returns the null value.


Kindly let us know whether the above line of code is correct or not?

If not, suggest us an other way to achieve the functionality.




Like 0



Hello Sivaranjani,


It happens because the code above returns the "Title" column caption only and if your object doesn't have the column with such a name the result is null.


You need to use something like:

var columnCaptionsArray = activityEntity.Schema.Columns;
    foreach (var columnCaption in columnCaptionsArray)
    	var captionForColumn = columnCaption.Caption.Value;

and use the captionForColumn in your logic furhter.


Best regards,


Oscar Dylan,

Thanks for the reply. The above code is working.

Show all comments