Select to view content in your preferred language

Display Domain Name from related table data

804
2
Jump to solution
11-28-2022 08:48 AM
DanielleGerlach_HNTB
Emerging Contributor

The goal is to populate a popup in an online map that contains data from a related table. Each record will have two related records, one for each end of the feature. I have it so the data will populate, but now I need to make it so the Domain Description displays as opposed to the Domain Code. The code is as follows:

 

var features = FeatureSetById($datastore, "8", ['*'], false);
var fk = $feature.GlobalID;
var filterStatement = 'CulvertID = @fk';
var relatedData = Filter(features, filterStatement);

var popupString = ' '
for (var f in relatedData)
{
   
    popupString +=
       
              "Culvert ID: " + DefaultValue(f.CulvertID, 'no data') + TextFormatting.NewLine +
              "Bound: " + DefaultValue(f.Bound, 'no data') + TextFormatting.NewLine +
              "Condition Index: "+ DefaultValue(f.ConditionIndex, 'no data') + TextFormatting.NewLine +
              "Embankment Condition: " + DefaultValue(f.EmbankmentCondition, 'no data') + TextFormatting.NewLine +
              "End Extension: " + DefaultValue(f.EndExtension, 'no data') + TextFormatting.NewLine +
              "End Location: " + DefaultValue(DomainName(features, 'EndLocation'), 'no data') + TextFormatting.NewLine +
              "End Section: " + DefaultValue(f.EndSection, 'no data') + TextFormatting.NewLine +
              "End Section Detached: " + DefaultValue(f.EndSectionDetached, 'no data') + TextFormatting.NewLine +
              "End Section Material: " + DomainName(FeatureSetByRelationshipName($feature, "MDOT_SDE.MDOT_SDE_ADMIN.MdotCulvertEndInventory"), 'EndSectionMaterial') + TextFormatting.NewLine +
              "Extension Dime Same as Culvert: " + DefaultValue(f.ExtensionDimeSameAsCulvert, 'no data') + TextFormatting.NewLine +
              "Extension Material Same as Culvert: " + DefaultValue(f.ExtensionMaterialSameAsCulvert, 'no data') + TextFormatting.NewLine +
              "Footing Exposed: " + DefaultValue(f.FootingExposed, 'no data') + TextFormatting.NewLine +
              "Install Year: " + DefaultValue(f.Installyear, 'no data') + TextFormatting.NewLine +
              "Invert Above Channel Bottom: " + DefaultValue(f.InvertAboveChannelBottom, 'no data') + TextFormatting.NewLine +
              "Scour Protection Type: " + DefaultValue(f.scour_prot_type_cd, 'no data') + TextFormatting.NewLine +
              "Rip Rap: " + DefaultValue(f.Riprap, 'no data') + TextFormatting.NewLine +
              "Rip Rap Condition: " + DefaultValue(f.RiprapCondition, 'no data') + TextFormatting.NewLine +
              "Safety Grate: " + DefaultValue(f.SafetyGrate, 'no data') + TextFormatting.NewLine +
              "Scour: " + DefaultValue(f.ScourPresent, 'no data') + TextFormatting.NewLine +
              "Sediment Depth >20: " + DefaultValue(f.SedimentDepthGreater20, 'no data') + TextFormatting.NewLine +
              "End Section Extension Length (ft): " + DefaultValue(f.EndSectionExtLength_ft, 'no data') + TextFormatting.NewLine +
              "End Section Remarks: " + DefaultValue(f.EndSectionRemarks, 'no data') + TextFormatting.NewLine +
              "Field Vertification Date: " + DefaultValue(f.invt_field_vrfy_date, 'no data') + TextFormatting.NewLine +
              "Inventory Field Verification User: " + DefaultValue(f.invt_field_vrfy_user, 'no data') + TextFormatting.NewLine +
              "Field Verification Company: " + DefaultValue(f.invt_field_vrfy_cmpy_cd, 'no data') + TextFormatting.NewLine +
              "User Create: " + DefaultValue(f.UserCreate, 'no data') + TextFormatting.NewLine +
              "System Create Date: " + DefaultValue(f.SystemCreateDate, 'no data') + TextFormatting.NewLine +
              "User Modified: " + DefaultValue(f.UserModified, 'no data') + TextFormatting.NewLine +
              "System Modified Date: " + DefaultValue(f.SystemModifiedDate, 'no data') + TextFormatting.NewLine + TextFormatting.NewLine
                 
               
                 
}



DefaultValue(popupString, 'No attributes to show')


Which provides the following (red text = field with domains): 

Culvert ID: {0A5BF456-57EC-4655-BD62-B153208EB3C5}
Bound: no data
Condition Index: no data
Embankment Condition: no data
End Extension: 2
End Location: no data
End Section: 7
End Section Detached: 2
End Section Material:
Extension Dime Same as Culvert: no data
Extension Material Same as Culvert: no data
Footing Exposed: 2
Install Year: no data
Invert Above Channel Bottom: 2
Scour Protection Type: no data
Rip Rap: 2
Rip Rap Condition: no data
Safety Grate: 2
Scour: 2
Sediment Depth >20: 2
End Section Extension Length (ft): no data
End Section Remarks: no data
Field Vertification Date: 2022-02-23T13:41:54-05:00
Inventory Field Verification User: Kyle Staines
Field Verification Company: 2
User Create: no data
System Create Date: no data
User Modified: MdotPublisher
System Modified Date: 2022-02-23T13:42:04-05:00

Culvert ID: {0A5BF456-57EC-4655-BD62-B153208EB3C5}
Bound: no data
Condition Index: no data
Embankment Condition: no data
End Extension: 2
End Location: no data
End Section: 7
End Section Detached: 2
End Section Material:
Extension Dime Same as Culvert: no data
Extension Material Same as Culvert: no data
Footing Exposed: 2
Install Year: no data
Invert Above Channel Bottom: 2
Scour Protection Type: no data
Rip Rap: 2
Rip Rap Condition: no data
Safety Grate: 2
Scour: 2
Sediment Depth >20: 2
End Section Extension Length (ft): no data
End Section Remarks: End section showing rebar
Field Vertification Date: 2022-02-23T13:42:36-05:00
Inventory Field Verification User: Kyle Staines
Field Verification Company: 2
User Create: no data
System Create Date: no data
User Modified: MdotPublisher
System Modified Date: 2022-02-23T13:42:46-05:00

 

So, I need the fields in red above to populate the domain name rather than code. Any help is appreciated! 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

I think you just need to use the DomainName function in those places. On lines like

"Condition Index: "+ DefaultValue(f.ConditionIndex, 'no data')

Try using the function there, like so:

"Condition Index: "+ DefaultValue(DomainName(f, 'ConditionIndex'), 'no data')

 

I see a couple other places where you are using the function, but you're supplying a FeatureSet as the input. To get a particular value's name, you need to supply a single feature. So instead of this:

DefaultValue(DomainName(features, 'EndLocation')

Try this:

DefaultValue(DomainName(First(features), 'EndLocation')

 

Lastly, for putting together long strings with lots of attributes inserted, you might want to try using template literals. It avoids having to concatenate so many strings, and respects line breaks. It would look like this:

`Culvert ID: ${DefaultValue(f.CulvertID, 'no data')}
Bound: ${DefaultValue(f.Bound, 'no data')}
Condition Index: ${DefaultValue(f.ConditionIndex, 'no data')}
Embankment Condition: ${DefaultValue(f.EmbankmentCondition, 'no data')}
... and so on
`

 

- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

I think you just need to use the DomainName function in those places. On lines like

"Condition Index: "+ DefaultValue(f.ConditionIndex, 'no data')

Try using the function there, like so:

"Condition Index: "+ DefaultValue(DomainName(f, 'ConditionIndex'), 'no data')

 

I see a couple other places where you are using the function, but you're supplying a FeatureSet as the input. To get a particular value's name, you need to supply a single feature. So instead of this:

DefaultValue(DomainName(features, 'EndLocation')

Try this:

DefaultValue(DomainName(First(features), 'EndLocation')

 

Lastly, for putting together long strings with lots of attributes inserted, you might want to try using template literals. It avoids having to concatenate so many strings, and respects line breaks. It would look like this:

`Culvert ID: ${DefaultValue(f.CulvertID, 'no data')}
Bound: ${DefaultValue(f.Bound, 'no data')}
Condition Index: ${DefaultValue(f.ConditionIndex, 'no data')}
Embankment Condition: ${DefaultValue(f.EmbankmentCondition, 'no data')}
... and so on
`

 

- Josh Carlson
Kendall County GIS
0 Kudos
DanielleGerlach_HNTB
Emerging Contributor

Many thanks!