Select to view content in your preferred language

Query FC for value and hide or show link in popup

357
6
Jump to solution
05-01-2023 08:25 AM
kapalczynski
Occasional Contributor III

I have an odd question.  

  1. I have a Feature Class that is in Oracle SDE, published to ArcGIS Server, Registered in Portal
  2. I edit this FC using Field Maps.
  3. In the Webmap that Field Map uses I have a link that opens a Survey123 Form and allows the user to create/edit a record in a 2nd Feature Class which is also in Oracle SDE, published to ArcGIS Server, Registered in Portal.
  4. There is no current relationship set up with these 2 Feature Classes....although when the S123 Form is opened the GlobalID of the 1st FC is passed and stored in the 2nd FC.  So I can query on this...

In Field Maps I want to be able to click a feature and have the popup open (works fine)

  1. I want to be able to click the link and open S123 to add/edit the 2nd FC (works fine)
  2. BUT I want to be able to HIDE the link if it already has a record in the 2nd Feature Class..
  3. NOTE the 2nd Feature Class has Its GlobalID and the Global ID from the 1st FC.  So I can technically query for the Global ID and see if it exists.... BUT I am not sure how to do this in a Popup...

I assume this would be an Arcade Expression?  But can you query a FC in a popup?  If I get a YES I can show a link and if it is NO then I can show the link

I hope that makes sense....

 

0 Kudos
1 Solution

Accepted Solutions
kapalczynski
Occasional Contributor III

I was able to hide one or the other with this example...

https://community.esri.com/t5/arcgis-online-questions/using-arcade-or-html-to-hide-display-hyperlink...

Scroll down to comment by by JohannesLindner 

 

'My code that worked for me is below

Based on == or != in an IF I created to expressions... 

Then the DIV and html in the popup showed me either one or the other.

 

POPUP:
<tr style="background-color: rgb(255, 255, 255);" valign="top">
<td style="padding: 2px;padding-bottom: 5px;border: 1px solid rgb(203, 203, 203);padding-right: 5px;color:rgb(74, 74, 74);">Inspection Form
</td>
<td>
          <div style="display:{expression/expr1};">
<a href="arcgis-survey123://?itemID= cb33fcxxxxxxx50722440146&amp;portalUrl=https://url.gov/portal&amp;action=edit&amp;folder=inbox&amp;update=true&amp;filter=REL_GLOBALID:{GLOBALID}&amp;callback=arcgis-fieldmaps://?itemID=1cf5c7a0xxxxxxxx2c308a2" rel="nofollow ugc" target="_blank">Inspection Form 1</a>
            </div>
            <div style="display:{expression/expr2};">
<a href="arcgis-survey123://?itemID= cb33fc9a378xxxxxxxxxxxx0722440146&amp;field:REL_GLOBALID={GLOBALID}&amp;field:GEOGRAPHICAL_LOCATION={LATITUDE},{LONGITUDE}" rel="nofollow ugc" target="_blank">Inspection Form 2<br /></a>
              </div>
  </td>
  </tr>

 

 

EXPRESSION 1

 

var globalIDValue = $feature.GLOBALID
var relGlobalIDValue = FeatureSetByName($map,"Inspection Form",['REL_GLOBALID'], false)
var status = "none"
for (var i in relGlobalIDValue) {
    var compareValue = Text(i.REL_GLOBALID)
    var currentValue = globalIDValue
    if (currentValue != compareValue){  
        status = "inline"
      }
}
return status

 

 

EXPRESSION 2

 

var globalIDValue = $feature.GLOBALID
var relGlobalIDValue = FeatureSetByName($map,"Inspection Form",['REL_GLOBALID'], false)
var status = "none"
for (var i in relGlobalIDValue) {
    var compareValue = Text(i.REL_GLOBALID)
    var currentValue = globalIDValue
    if (currentValue == compareValue){  
        status = "inline"
     }
}
return status

 

 

 

 

 

 

View solution in original post

0 Kudos
6 Replies
kapalczynski
Occasional Contributor III

It appears that I can access the WebMap from expression builder for popups ...  I can see the 2nd Table in there but not sure how to access the attributes from it?

 

In the expression builder I can see the webmap that has the FC I am looking to query.

kapalczynski_0-1682955784964.png

 

Here is the Table I want to query for a specific value ... if exists return true if not return false

kapalczynski_1-1682955861561.png

 

How do I query it with Arcade Expression....

 

EX:  If $feature.fieldValue == "something"

              return True

        else

              return false

 

0 Kudos
kapalczynski
Occasional Contributor III

I think I can walk to the WebMap and Feature Class as such

     var relGlobalID = ($map,"Inspection Form FC")

BUT How do I query this Feature Class in the webmap looking for a specific value in the attribute field?

the attribute field name is relGlobalID

 

 

 

0 Kudos
kapalczynski
Occasional Contributor III
0 Kudos
kapalczynski
Occasional Contributor III

nah still having issues...Anyone see what I am doign wrong... I think the FOR loop should be going through all the values in the "Inspection Form FC" in the webmap 

 

var globalIDValue = $feature.GLOBALID
var relGlobalIDValue = FeatureSetByName($map,"Inspection Form FC",['REL_GLOBALID'], false)
var didIFindIt = ""

for (var i in relGlobalIDValue) {
    var compareValue = i
    var currentValue = globalIDValue
    //return currentValue

    if (currentValue == compareValue){
        didIFindIt = "Found It"
    }
}
return didIFindIt

  

0 Kudos
kapalczynski
Occasional Contributor III

OK I can do this :  Based on if there is a record in the 2nd Feature Classes it returns YES or NO in the popup....

But what I want to do is show NO in Text and if YES show a link to a S123 form...

HOW do I define the below URL into a link and show that in the popup ONLY if YES

<a href="arcgis-survey123://?itemID= cb33fc9a3xxxxxxxxxxxxx40146&amp;portalUrl=https://website.gov/portal&amp;action=edit&amp;folder=inbox&amp;update=true&amp;filter=REL_GLOBALID:..." rel="nofollow ugc" target="_blank">Inspection Form</a><br />

var globalIDValue = $feature.GLOBALID
var relGlobalIDValue = FeatureSetByName($map,"Inspection Form",['REL_GLOBALID'], false)
var status = "NO INSPECTION"
for (var i in relGlobalIDValue) {
    var compareValue = Text(i.REL_GLOBALID)
    var currentValue = globalIDValue
    if (currentValue == compareValue){  
        status = "YES"
     }
}
return status

kapalczynski_0-1682964293763.png

 

 

0 Kudos
kapalczynski
Occasional Contributor III

I was able to hide one or the other with this example...

https://community.esri.com/t5/arcgis-online-questions/using-arcade-or-html-to-hide-display-hyperlink...

Scroll down to comment by by JohannesLindner 

 

'My code that worked for me is below

Based on == or != in an IF I created to expressions... 

Then the DIV and html in the popup showed me either one or the other.

 

POPUP:
<tr style="background-color: rgb(255, 255, 255);" valign="top">
<td style="padding: 2px;padding-bottom: 5px;border: 1px solid rgb(203, 203, 203);padding-right: 5px;color:rgb(74, 74, 74);">Inspection Form
</td>
<td>
          <div style="display:{expression/expr1};">
<a href="arcgis-survey123://?itemID= cb33fcxxxxxxx50722440146&amp;portalUrl=https://url.gov/portal&amp;action=edit&amp;folder=inbox&amp;update=true&amp;filter=REL_GLOBALID:{GLOBALID}&amp;callback=arcgis-fieldmaps://?itemID=1cf5c7a0xxxxxxxx2c308a2" rel="nofollow ugc" target="_blank">Inspection Form 1</a>
            </div>
            <div style="display:{expression/expr2};">
<a href="arcgis-survey123://?itemID= cb33fc9a378xxxxxxxxxxxx0722440146&amp;field:REL_GLOBALID={GLOBALID}&amp;field:GEOGRAPHICAL_LOCATION={LATITUDE},{LONGITUDE}" rel="nofollow ugc" target="_blank">Inspection Form 2<br /></a>
              </div>
  </td>
  </tr>

 

 

EXPRESSION 1

 

var globalIDValue = $feature.GLOBALID
var relGlobalIDValue = FeatureSetByName($map,"Inspection Form",['REL_GLOBALID'], false)
var status = "none"
for (var i in relGlobalIDValue) {
    var compareValue = Text(i.REL_GLOBALID)
    var currentValue = globalIDValue
    if (currentValue != compareValue){  
        status = "inline"
      }
}
return status

 

 

EXPRESSION 2

 

var globalIDValue = $feature.GLOBALID
var relGlobalIDValue = FeatureSetByName($map,"Inspection Form",['REL_GLOBALID'], false)
var status = "none"
for (var i in relGlobalIDValue) {
    var compareValue = Text(i.REL_GLOBALID)
    var currentValue = globalIDValue
    if (currentValue == compareValue){  
        status = "inline"
     }
}
return status

 

 

 

 

 

 

0 Kudos