Skip to main content
sowmyak2554
New Participant
Apr 2, 2024 1:22 PM UTC
Question

Please explain how we can use index function with cdt? want explanation with example.

Hi Team,

I understood how index function works, but can someone please write a code(with example) using index function with cdt.

3 replies

konduruc733182
Inspiring
Apr 2, 2024 1:30 PM UTC

Hello [mention:777c883886684872a83b0b712bb7e036:e9ed411860ed4f2ba0265705b8793d05] 

Please refer the below documentation

index()

Interface Recipes : Set the value of a CDT field based on a user input

kalpeshg0081
Participating Frequently
Apr 2, 2024 2:27 PM UTC

Hi [mention:777c883886684872a83b0b712bb7e036:e9ed411860ed4f2ba0265705b8793d05] ,

Lets assume you have 3 column in a CDT EmployeeData as "Name", "Number", "City". now if you want to fetch all the values of City column, you need to use the index function as below:

Index(Your_CDT,column_Name,default_Value)

Index(EmployeeData, "City", null)

And in case of Record type, code syntax will be same. but you can not index it directly by giving the column name, you need to pass the column name as below

Index(EmployeeData, recordType!yourRecordName.fields.yourField, null)

mikes0011
Brainy
Apr 2, 2024 2:55 PM UTC

For readability I continue to recommend people use "property()" when attempting to get a dot property, and reserve "index()" for finding the index (position) of an array.  The two functions are interchangeable but that doesn't mean readability isn't muddled when one is overused.

The Expression Guru