Skip to main content

Help with scripting to show subtype descriptions instead of code in report.

Comments

12 comments

  • Jason Hannigan

    Figured it out with help:

     

     var code = label1.Text;

       

      var newText = "";

      switch (code){

        case "1":

          newText = "Desc1";

          break;

        case "2":

          newText = "Desc2";

          break;

        case "3":

          newText = "Desc3";

          break;

        case "4":

          newText = "Desc4";

          break;

        case "5":

          newText = "Desc5";

          break;

        }

       

      label1.Text = newText;

    0
  • Ryan Cooney

    You can do this without scripting. See https://docs.geocortex.com/reporting/latest/help/Default.htm#rpt5/help/coded-value-domains.htm for details.

     

    --Ryan

    0
  • Jason Hannigan

    Thanks Ryan,

    I have used that for domains, but according to the documentation subtypes are not supported yet. Am I missing something?

    0
  • Ryan Cooney

    Hi Jason,

     

    Support for subtypes was added in version 5.2.

     

    --Ryan

    0
  • Permanently deleted user

    I am trying to use subtype description in my report, and cannot get it to work either. I looked at this documentation, and set my expression accordingly, but it still not working? https://docs.geocortex.com/reporting/latest/help/Default.htm#rpt5/help/coded-value-domains.htm

    0
  • Permanently deleted user

    @Jason Hannigan? I have tried to implement the script you shared above, to display the subtype description, but cannot get it to work. Would you mind sharing more information about how you configured it: which element did you associated it with (specific label, or a detail section?), and which event? Are there any other configurations that need to happen for this to work? Thank you.

    0
  • Ryan Cooney

    @Nataliya Lys? if the data is public... are you able to provide a link to the ArcGIS service and point out the layer and field you are trying to use?

    0
  • Permanently deleted user

    @Ryan Cooney? I just sent you a message.

    0
  • Jason Hannigan

    In my case I was just trying to clean up the municipal labels. I have added the following code that references the label text box (label48). I just opened the scripts area from the top toolbar and added the following code:

     

    private void label48_BeforePrint(object sender, system.Drawing.Printing.PrintEventArgs e) {

     

     var code = label48.Text;

     var newText = "";

     switch (code){

      case "1":

       newText = "Brooke-Alvinston";

       break;

      case "2":

       newText = "Dawn-Euphemia";

       break;

      case "3":

       newText = "Enniskillen";

       break;

      case "4":

       newText = "Lambton Shores";

       break;

      case "5":

       newText = "Plympton-Wyoming";

       break;

      case "6":

       newText = "Sarnia";

       break;

      case "7":

       newText = "St. Clair";

       break;

      case "8":

       newText = "Warwick";

       break;

      }

     label48.Text = newText;

    }

     

    The case is the subtype code and I just replace the printing of that number code with the text. This is ok if you have just a few codes you can manually type in, probably not the best if you have lots of subtypes.

     

    0
  • Ryan Cooney

    You can also use the built-in expressions to do this sort of logic.

    Iif( [SWR_TYPE] = 4, 'Storm Combined', [SWR_TYPE] = 3, 'Sanitary Combined', [SWR_TYPE] = 2, 'Combined', [SWR_TYPE] = 1, 'Storm', 'Sanitary' )

     

    0
  • Permanently deleted user

    @Jason Hannigan? and @Ryan Cooney? thank you both for your help.

     

    I got it to work for the built-in expression that Ryan provided. I cannot believe how easy this workaround is. I was way overthinking it. 😏

    0
  • Ryan Cooney

    It turns out that the GetDomainDescription function does not handle the case where the subtype itself not a domain and the subtype field is the very field that you want to display. In version 5.11 there will be a new GetSubtypeName function to easily handle this case.

     

    --Ryan

    0

Please sign in to leave a comment.