Select to view content in your preferred language

Concatenate a URL followed by a Field Name Using Calculate Field

2175
3
Jump to solution
08-21-2017 08:49 AM
SarojThapa1
Frequent Contributor

I am trying to concatenate a domain URL followed by a field name using Calculate Field tool. In the Expression field in the Calculate Field window, the sql expression looks like:

PHOTO_URL =

<a href=DomainURL/FolderName/&" "&!PHOTO!>Photo</a>

However, in the attribute table, the PHOTO_URL's values are populated as

<a href=''DomainURL/FolderName/PhotoName.jpg''''>Photo</a>

I get an extra " at the end of the href. When opening the map service using the arcgis online, when the PHOTO_URL atttribute is clicked, it reloads the current web URL instead of redirecting to the photo url.

Any help or suggestions are greatly appreciated.

Thanks

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

python syntax

PHOTO = 'somephoto.jpg'
'DomainURL/FolderName/{}'.format(PHOTO)  # syntax line‍‍‍‍

yields

'DomainURL/FolderName/somephoto.jpg'

Field calculator syntax

'DomainURL/FolderName/{}'.format(!PHOTO!)  # syntax line‍‍‍‍

just put exclamation marks around PHOTO in the syntax line above so that it reads ... !PHOTO!

View solution in original post

3 Replies
shan_sarkar
Frequent Contributor

Saroj,

Can you share one record from your data so that I can test the issue?

~Shan


~Shan
0 Kudos
SarojThapa1
Frequent Contributor

Thanks for your response, Shantonu. The issue is resolved now. 

0 Kudos
DanPatterson_Retired
MVP Emeritus

python syntax

PHOTO = 'somephoto.jpg'
'DomainURL/FolderName/{}'.format(PHOTO)  # syntax line‍‍‍‍

yields

'DomainURL/FolderName/somephoto.jpg'

Field calculator syntax

'DomainURL/FolderName/{}'.format(!PHOTO!)  # syntax line‍‍‍‍

just put exclamation marks around PHOTO in the syntax line above so that it reads ... !PHOTO!