Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!
The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.
Hi All,
I am trying to use indexing for type " List of Text String " but the output i am getting not the expected output i am adding the screenshots here for reference.
Thanks In advance,
SSP
Discussion posts and replies are publicly visible
Can you share your code? I am sure I understand what you do and what your goal is.
Hi Stefan,Here is my code.
a!localVariables( local!exceldata: readexcelsheet( excelDocument: cons!IT_SAMPLE_FILE, sheetNumber: 0, startRow: 0, /*stopReadingAtFirstBlankRow: false(),*/ /*pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 0)*/ ), local!datalength: length( index(local!exceldata, "result", "values", {}) ), local!headers: index(local!exceldata, "result", "values", 1, {}), local!filecdt: a!forEach( items: local!headers[1], expression: { fv!item & " : " & a!forEach( items: 2, /*enumerate(local!datalength - 1) + 2,*/ expression: a!forEach( items: index( local!exceldata, "result", "values", fv!item, {} ), expression: a!forEach( items: fv!item, expression: a!forEach( items: fv!item, expression: fv!item ) ) ) ) } ), local!filecdt )
This is confusing. Why do you use more than three parameters with the index function? The behaviour with more than three parameters is undefined.
index(local!exceldata, "result", "values", 1, {}) is equivalent toindex(index(index(local!exceldata, "result",{}),"values",{}),1,{})
Sorry, but again, while this behaviour works most of the times, it is no documented and has edge cases in which it does not work and is super difficult to debug.
Could you please help me in with the issue I am facing ?"I am trying to use indexing for type " List of Text String " but the output i am getting not the expected output"
What is the input and what output you are expecting?
The input is like : "How","Are","You" (which is of type list of text strings),I am trying to get only 1 at a time using indexing (either "How" or "Are" or "You"), But I am getting the "H","A","R" if i am using index 1
a!localVariables( local!text:{"How","Are","You"}, index(local!text,2,{}))
It will work?
IN the code you provided, you are using some excel file. What you want to get from that and what is there in that file.
I am trying to create a dynamic excel reader and use the data in a grid.
Oh you want to create a grid based on dynamic Excel. Let me write the code and will let you know ASAP.
a!localVariables( local!excelData: index(readexcelimportfile( excelDocument: todocument(57745), /*put excel document id instead of 57745*/ sheetNumber:0, startRow:0 ),"result",{}), a!gridField( data: remove(local!excelData,1), columns: { a!forEach( items: local!excelData[1].values, expression: a!gridColumn( label: fv!item, value: index(fv!row.values,fv!index,{}) ) ) } ) )
Please refer this code and see if it works.
a!localVariables( local!exceldata, a!sectionLayout( contents: { a!fileUploadField( label: "Upload a File :", target: cons!IT_FOLDER, fileNames: "File Reading-File Uploaded on " & text(now(), "ddmmyyhhmmss"), fileDescriptions: "File Reading Interface Testing on File Uploaded on " & text(now(), "ddmmyyhhmmss"), maxSelections: 1, value: ri!uploadedFile, saveInto: { ri!uploadedFile, a!save( local!exceldata, index( readexcelsheet( excelDocument:todocument(ri!uploadedFile), sheetNumber:0, startRow: 0 ), "result", {} ) ) }, required: true(), validations: if( contains({ "csv", "xlsx" }, fv!files.extension), {}, "Only CSV,XLSX formats files should be uploaded but uploaded file is of format ." & fv!files.extension ) ), a!gridField( label: "Excel Data :", emptyGridMessage: "Please Upload a File with Values", data: remove(local!exceldata, 1), columns: a!forEach( items: local!excelData[1].values, expression: a!gridColumn(label: fv!item, value: index(fv!row,fv!index,{})) ), showWhen: not(a!isNullOrEmpty(ri!uploadedFile)) ) } ) )