cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

How to Get the count of Number of Field in a Infotable

pshashipreetham
17-Peridot

How to Get the count of Number of Field in a Infotable

I have situation were based on the Field count I need to do the Logic so  "How to Get the count of Number of Fields in a Infotable"

Thanks
Shashi

Shashi Preetham,
Email: psp316r@outlook.com,
Mobile: +91 8099838001.
ACCEPTED SOLUTION

Accepted Solutions
M4RC
14-Alexandrite
(To:pshashipreetham)

Hello, 

the getFieldCount() method returns the number of fields in the DataShape of this InfoTable as int.

 

 

View solution in original post

5 REPLIES 5
DanWolf
14-Alexandrite
(To:pshashipreetham)

You can get the fields from an InfoTable using .dataShape.fields, like below.  It will print the field name and the table's first row field value in the scriptlog.

 

let infoTableFields = infotable.dataShape.fields; // where "infotable" is the variable containing your InfoTable.

for (let fieldName in infoTableFields) {

    logger.info(fieldName + ": " + infotable[fieldName]);

}

 

To just get the number of fields, infotable.dataShape.fields.length should work (assuming the InfoTable exists and has data).

hi @DanWolf ,

In this situation, the input infotable is not having the data shape, it is created manually and fields were added dynamically based on the criteria's, when this dynamically added, need the length of the Field Names such that to proceed further Logic.

Thanks,
Shashi

Shashi Preetham,
Email: psp316r@outlook.com,
Mobile: +91 8099838001.

Hi @pshashipreetham.

 

We're a little confused.  You indicated in your initial post that you needed the count of the number of fields in the infotable.  In your last response, you indicated you needed the length of the field names.

 

To clarify the request, please provide details of the use case so we can get a better understanding of what is needed.  How are you dynamically passing the fields?

 

Regards.

 

--Sharon

Hi @slangley ,

Apologies for the confusion, the use case is, the service generate/AddFields Dynamically based on the requirement. Once Dynamically generated, based on the Fields Count need to do some other operation !!

hope you understand !!

Thanks,
Shashi Preetham 

Shashi Preetham,
Email: psp316r@outlook.com,
Mobile: +91 8099838001.
M4RC
14-Alexandrite
(To:pshashipreetham)

Hello, 

the getFieldCount() method returns the number of fields in the DataShape of this InfoTable as int.

 

 

Announcements


Top Tags