Skip to main content

Populate attribute value with the value of other fields in same feature service

Comments

8 comments

  • Permanently deleted user
    Hi Lauren,

     

    If you want to concatenate a bunch of strings together, then you would have to split up your Value input to this:

     

    string.Format("{0}, {1}, {2}, {3}, {4}, {5}", query_result.Features(0).Attributes("PREADDRNUM"), query_result.Features(0).Attributes("ADDRNUM"), query_result.Features(0).Attributes("ADDRNUMSUF"), query_result.Features(0).Attributes("FULLNAME"), query_result.Features(0).Attributes("UNITTYPE"), query_result.Features(0).Attributes("UNITID"))

     

    The Attributes method does not take this many columns at once so it will error out.

     

    After you have generated the strFullAddr string, you can assign it to a feature by:

     

    1. Querying for the feature you want to add the full address to

     

    2. use an Assign activity to assign the new value to the feature like this: 

     

    To = featureSet.Features.First().Attributes("FULLADDR")

     

    Value = strFullAddr

     

    3. Then use the UpdateFeatures activity to commit the changes. 

     

    If you want more information, this code gallery sample demonstrates on how to update features:

     

    https://support.geocortex.com/essentialsGSCCodeGallery?sub-nav=codegall&main-nav=essentials&#!/feedtype=SINGLE_ARTICLE_DETAIL&criteria=BESTANSWERS&id=kA4600000004EWUCA2

     

    I hope this helps.

     

    Regards, 

     

    Carmen
    0
  • Permanently deleted user
    Thank you, this helps a lot.
    0
  • Permanently deleted user
    I got the concatenate to work and update the feature to commit the changes. Is there a way to account for fields that have a null value without adding a space in the concatenated string. For example, if the address does not have a suffix, I don't want a space to be added where that value would go. Any suggestions?
    0
  • Tom Neer
    IF(fs.Feature(i).Attributes("fieldname") is Nothing,"",fs.Feature(i).Attributes("fieldname").ToString())
    0
  • Permanently deleted user
    Hi Lauren, 

     

    I would do what Tom has suggested and include an IF activity per parameter to catch whether the value is NULL or empty. If you have 6 parameters, then you would have 6 IF activities. The condition would be something like this:

     

    query_result.Features(0).Attributes("PREADDRNUM").ToString.IsNullOrEmpty

     

    Then: leave this section empty and it would allow the workflow to just continue

     

    Else: Use an assign activity here where strFullAddr = strFullAddr + query_result.Features(0).Attributes("PREADDRNUM").ToString

     

    I hope this helps.

     

    Regards, 

     

    Carmen
    0
  • Permanently deleted user
    I set up each of the 6 if statements as follows...

     

    Condition: query_result.Features(0).Attributes("ADDRNUM").ToString.IsNullOrEmpty

     

    Then: empty

     

    Else: Assign activity

     

            To: strFullAddr

     

            Value: strFullAddr + query_result.Features(0).Attributes("PREADDRNUM").ToString

     

    I am getting an error from my If statement that the "Object Reference is not set to instance of an object". I am having some trouble figuring out how to fix this. My initial thought was that is has something to do with the Attributes("ADDRNUM") portion of the condition?

     

     
    0
  • Permanently deleted user
    Hi Lauren, 

     

    If that's the case then I would try replacing all your IF activities to using the TRY/CATCH activity. What that error means is we are trying to assign it a value that does not exist. So if the query_result.Features(0).Attributes("ADDRNUM") produces a NULL value, then we cannot convert it into a string to see if it is empty or not. That is what I think is causing the error. The try/catch activity would eliminate that issue. 

     

    Regards, 

     

    Carmen
    0
  • Permanently deleted user
    Perfect, that makes sense. Thanks again.
    0

Please sign in to leave a comment.