Concatenate a URL followed by a Field Name Using Calculate Field

667
3
Jump to solution
08-21-2017 08:49 AM
Highlighted
Occasional Contributor III

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

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
MVP Esteemed Contributor

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
Highlighted
Regular Contributor

Saroj,

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

~Shan

Reply
0 Kudos
Highlighted
Occasional Contributor III

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

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

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