I need help inserting data into hyperlink in custom popup. Anyone?

4307
5
Jump to solution
05-17-2016 09:21 AM
MatthewSyvertson
Occasional Contributor II

I am having trouble creating a custom popup in ArcGIS Portal.  What I want is a hyperlink to an external page that is filled with data from the clicked feature.  The hyperlink looks like this: "http://www.co.richland.nd.us/RCIMS/Parcel.html?parcel=13-0000-02582.001" where the bold red part would come from the following data field: {RICHLAND.DBO.RC_Parcels.PIN_TXT}.

Thanks for any advice you may have.  I tried to construct in the HTML mode, but couldn't get it to insert the data correctly into the HTML string.

0 Kudos
1 Solution

Accepted Solutions
KarstenRank
Occasional Contributor III

Hi Matthew,

you should mark your text, open the link properties and append the data field in braces, e.g like Parcel ...co.richland.nd.us/RCIMS/Parcel.html?parcel={RICHLAND.DBO.RC_Parcels.PIN_TXT}.

This work fine for me.

Greetings Karsten

View solution in original post

5 Replies
KarstenRank
Occasional Contributor III

Hi Matthew,

you should mark your text, open the link properties and append the data field in braces, e.g like Parcel ...co.richland.nd.us/RCIMS/Parcel.html?parcel={RICHLAND.DBO.RC_Parcels.PIN_TXT}.

This work fine for me.

Greetings Karsten

MatthewSyvertson
Occasional Contributor II

This worked splendidly.  It is just like me to make this harder than it had to be.

0 Kudos
PaulDavidson1
Regular Contributor

Using Hyperlinks—Help | ArcGIS for Desktop 

Try using the hyperlink script option?

Set the parser to Python and see if this code will work for you.

I pulled  your parcel ID into tId out of habit (debugging outside the hyperlink)

import webbrowser

def OpenLink ( [RICHLAND.DBO.RC_Parcels.PIN_TXT]):

    tId = [RICHLAND.DBO.RC_Parcels.PIN_TXT]

    parcelId = '' if (tId is None ) else tId.strip('\r\n\t ')  # trims CR, NL, TAB or spaces

   

    basePath = 'http://www.co.richland.nd.us/RCIMS/Parcel.html?parcel='

    if parcelId: # make sure you don't have an empty parcel id

        tPath = basePath + parcelId

        webbrowser.open(tPath)

    return

or in short form with no attempt at error checking:

import webbrowser

def OpenLink ( [RICHLAND.DBO.RC_Parcels.PIN_TXT]):

    webbrowser.open('http://www.co.richland.nd.us/RCIMS/Parcel.html?parcel='+[RICHLAND.DBO.RC_Parcels.PIN_TXT])

    return

Here's an example of more complex scripting where we have a flag that indicates if there's an attached image and we have a previous and current project Id.

We want to use current project Id if it exists, otherwise the current prj ID and if neither project ID exists, we have an empty string and we do nothing.

Note that Python treats an empty string as a False

import webbrowser

def OpenLink ( [IR_IMAGE], [CURRENT_PROJECT_NUMBER], [ORIGINAL_PROJECT_NUMBER]  :(

    # need to insert code to check that a project number exists, swap between current and original?

    if [IR_IMAGE] ==  'NO' or [IR_IMAGE] ==  'N' :  # should show up in here as NO but just in case, check against N

        return

    cP = [CURRENT_PROJECT_NUMBER]

    oP = [ORIGINAL_PROJECT_NUMBER]

    cPrj = '' if (cP is None ) else cP.strip('\r\n\t ')  # trims CR, NL, TAB or spaces

    oPrj = '' if (oP is None) else oP.strip('\r\n\t ')

    #  this can give you an empty string for thisProjId (if both current and previous project IDs are empty)

    thisProjId = cPrj if (cPrj) else oPrj 

   

    if thisProjId: # make sure you don't have an empty prj id (either current or original)

        path = 'http://srvrname.domain.com/Default.aspx?GISProject=' + thisProjId

        webbrowser.open(path)

    return

NOTE: I have only recent started trying the hyperlink in Layer Properties in an mxd.

My long time habits typically have me doing things like:

    basePath = 'http://srvrname.domain.com/Default.aspx?GISProject='

    path = basePath + thisProjId   

In these hyperlink scripts, I'm not sure this buys you anything since you can only debug outside of the script.

I'm guessing or assuming that anything in [] is treated as a string regardless of it's type?

Or does it come in as the field type.  I'm playing with that now to try to understand it but you really can't get interactive in the script that I'm aware of yet...

Dan?  Can I pull in arcpy and use messaging or print to stdout?

0 Kudos
MatthewSyvertson
Occasional Contributor II

Paul,  I assume your solution would have worked just fine, but I tried the easy answer first and it worked.  Thanks.

Matt

0 Kudos
PaulDavidson1
Regular Contributor

Easiest is always best....

I also missed that you were in Portal (even though it's right up front.)  My solution is down at the ArcMap mxd level.

Which I am not sure about how it will work when it comes to Portal but it's on my list of things to try.

We've found all sorts of interesting behavior when we go from map services to Feature Services, to hosted Feature Services, etc...

0 Kudos