Adding attachments for each feature in Flex??????

459
9
08-12-2013 09:51 AM
BradenPierson1
New Contributor
Hello all,

I am using the application builder in ArcGIS Viewer for Flex(v.3.3) as a student. I would like attach a different excel spreadsheet for each pop-up within a layer. Is there a way to do this? I know you can add general attachments that affect the whole layer, but is
there a way to specifically add different ones to each feature within the layer?

Thanks,
Braden Pierson
Tags (2)
0 Kudos
9 Replies
MattPohl
Occasional Contributor II
Braden-

Yes this can be done. You need to have a field calculated with fully qualified urls for that particular layer. For example if you had a parcel layer that had 5 features and each one of the parcels had its own Excel report, you would have 5 Excel files. I would create a folder somewhere inside the wwwroot folder, call it 'reports' and then put all your Excel files inside it. Then calculate the field as:

http://YourMachineName/reports/....    to get the appropriate file name at the end of the url I always have a field (reportID) that corresponds the feature to the report. For instance parcel 1 would have a reportID value of 1, parcel 2 would have a reportID value of 2, etc. I then make sure the reports are all named the same with the unique ID at the end. For instance: ExcelReport1.xls for parcel 1, ExcelReport2.xls for parcel 2, ExcelReport3.xls for parcel 3, etc. This way I can use a statement like this in the field calculator:

reportID=
"http://YourMachineName/reports/ExcelReport"&[reportID]&".xls"

**When creating this field, make sure it is type: text with a length that will hold the entire url. I usually just go with 200 for a length.

Than just use that field in your popup config and each feature will have it own unique attachment. I don't use the app builder but it looks like you would use the Custom tab when configuring you popup. You than would use HTML formatting to configure the popup. The Field containing your url will need the <a href= tag. This is well documented here: http://resources.arcgis.com/en/help/flex-viewer/concepts/index.html#/Configuring_pop_ups_in_Applicat...


~Matt
0 Kudos
BradenPierson1
New Contributor
Matt,

Because I am using the app builder, wouldn't I use \\YourMachineName\webrootfolder\Reports\ExcelReport"&[reportID]&".xls" instead of "http://YourMachineName/reports/ExcelReport"&[reportID]&".xls" since I am referencing the directory that holds the information? The site is not online yet so there is technically no real http to reference. Or am I mistaken?

Should I wait until it is implemented into the site to add these attachments, so that I can then reference "http://YourMachineName/reports/ExcelReport"&[reportID]&".xls"?

Thanks,
Braden
0 Kudos
MattPohl
Occasional Contributor II
Braden-

I would still be using a fully qualified url. As long as your attachments (excel files) are inside your wwwroot folder somewhere it will resolve just fine. I would stay away from the UNC path as they are problematic in popups. If you migrate your app to a different server/machine when going live then just recalculate the field to reflect the new machine name or add another field and reference it in the popup.xml file.

~Matt
0 Kudos
DougBrowning
MVP Esteemed Contributor
I prefer the URL method listed above but you can also use the Attachment Manger and attach the files directly into the geodatabase.
0 Kudos
BradenPierson1
New Contributor
I've tried it both ways, and both times, I get the following message:

Server Error - The remote server returned an error: (404) Not Found.

For the create attachments way, they attached just fine within ArcMap, however, when opening them up in Flex, I get that message. I pulled the files from a subfolder within my www root folder.

The URL option did the same thing, and I made sure my URL was correct as well.

Thanks,
Braden
0 Kudos
MattPohl
Occasional Contributor II
Braden-

In ArcMap try using the Identify tool and click on one of your features. Then see if you can open the link from the Identify popup window. If not, than you know that you have the url setup wrong. If it does open, we can work from there.

Matt
0 Kudos
BradenPierson1
New Contributor
Hey guys,

It must be the URL that is a problem.
I got this:
404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

The path to the Excel Reports are Z:\SBALP_2013\SBALP\Reports with Z being my mapped drive to the my machine.
So thus, I figured it would be for instance, http://mymachinename/SBALP_2013/SBALP/Reports/ExcelReport1.xls as the resulting URL.
0 Kudos
MattPohl
Occasional Contributor II
Braden-

To test.... open windows explorer and navigate to your wwwroot folder (C:\inetpub\wwwroot). Create a folder in the wwwroot folder called reports. Copy and past your excel files into the new folder. Then open a web browser and in the address bar type:
http://localhost/reports/TheReportName.xls    This should open the excel file (of course if it is a .xlsx you will use that as the file extension). You then can substituent the localhost part of the url with your computers name and see if that works. If you are not sure of your computers name, go to: Start, Control Panel, Administrative Tools, and then Internet Information Services (IIS) Manager. Once the IIS manager opens your computer's name will be listed on the top with the word 'Home' next to it. So if your computer's name is Lab01 the url: http://Lab01/reports/TheReportName.xls  should work as well. Once you get this working just use that url for your field in ArcMap.

Matt
0 Kudos
RhettZufelt
MVP Frequent Contributor
Braden,

Kind of depends on which method you use.  If you add them as attachments to the FC in the FGDB, then you would use the popup config files and enable attachments.  Then, through the service, when one clicks on the feature with attachemnts, you will have the ability to open them.

For the other method, you are putting the path to the standalone files themselves.  In this case, you would set up a virtual directory on your server that "points" to the location of the files.  Then, you would use an URL (http://yourserver/folder/filename.ext) as the attribute value and set this up as a hyperlink in the popupconfig.

R_
0 Kudos