Home

Format list view => icon if attachment

%3CLINGO-SUB%20id%3D%22lingo-sub-1261329%22%20slang%3D%22en-US%22%3EFormat%20list%20view%20%3D%26gt%3B%20icon%20if%20attachment%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1261329%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20formatted%20a%20sharepoint%20list%20with%20JSON.%20Now%20I%20want%20to%20show%20up%20an%20icon%20if%20there%20is%20an%20attachment%20attached%20to%20the%20item.%20I%20have%20tried%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3E%22children%22%3A%20%5B%0A%20%20%7B%0A%20%20%20%22elmType%22%3A%20%22span%22%2C%0A%20%20%20%20%22style%22%3A%20%7B%7D%2C%0A%20%20%20%20%22attributes%22%3A%20%7B%0A%20%20%20%20%22iconName%22%3A%20%22%3Dif(%5B%24Attachments%5D%20%3D%3D%20'1'%2C%20'Attach'%2C%20'FieldEmpty')%22%2C%0A%20%20%20%7D%0A%20%20%7D%2C%0A%5D%3C%2FCODE%3E%3C%2FPRE%3E%3CDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EIf%20I%20fill%20in%20this%20code%20into%20my%20whole%20JSON%20Code%2C%20then%20all%20my%20items%20dissapear%20and%20the%20list%20is%20empty.%3C%2FDIV%3E%3CDIV%3EWhat%20am%20I%20doing%20wrong%3F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3ECan%20someone%20help%20me%20please%3F%3CBR%20%2F%3EGreetings%20from%20Germany.%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1261329%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ELists%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1264058%22%20slang%3D%22en-US%22%3ERe%3A%20Format%20list%20view%20%3D%26gt%3B%20icon%20if%20attachment%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1264058%22%20slang%3D%22en-US%22%3EHi%2C%3CBR%20%2F%3EIf%20you%20just%20want%20to%20show%20an%20icon%2C%20why%20dont%20you%20use%20the%20inbuilt%20attachment%20column%20which%20does%20the%20same.%20Is%20there%20any%20other%20feature%20you%20are%20trying%20to%20built%20based%20on%20the%20icon%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1265791%22%20slang%3D%22en-US%22%3ERe%3A%20Format%20list%20view%20%3D%26gt%3B%20icon%20if%20attachment%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1265791%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F144422%22%20target%3D%22_blank%22%3E%40Sudharsan%20K%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3Emy%20problem%20is%20that%20I%20dont%20know%20how%20I%20can%20read%20out%20the%20attachments%20column.%20If%20I%20use%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%22txtContent%22%3A%20%22%5B%24Attachments%5D%22%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Enothing%20happens.%20Is%20that%20the%20right%20internal%20name%20for%20the%20Attachment%20list%3F%20And%20I%20want%20to%20show%20how%20many%20Attachments%20are%20behind%20a%20list%20item.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hello,

 

I have formatted a sharepoint list with JSON. Now I want to show up an icon if there is an attachment attached to the item. I have tried this:

 

"children": [
  {
   "elmType": "span",
    "style": {},
    "attributes": {
    "iconName": "=if([$Attachments] == '1', 'Attach', 'FieldEmpty')",
   }
  },
]
 
If I fill in this code into my whole JSON Code, then all my items dissapear and the list is empty.
What am I doing wrong?
 
Can someone help me please?
Greetings from Germany.
2 Replies
Highlighted
Hi,
If you just want to show an icon, why dont you use the inbuilt attachment column which does the same. Is there any other feature you are trying to built based on the icon?
Highlighted

@Sudharsan K 

 

Hi,

my problem is that I dont know how I can read out the attachments column. If I use

 

"txtContent": "[$Attachments]"

 

nothing happens. Is that the right internal name for the Attachment list? And I want to show how many Attachments are behind a list item.