Question

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 https://community.creatio.com/questions/get-title-columns-esq 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.

 

Thanks,

Sivaranjani

Like 0

Like

2 comments

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

Oscar Dylan,

Thanks for the reply. The above code is working.

Show all comments