Announcement

Collapse
No announcement yet.

ChannelUtil question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ChannelUtil question

    Hello all,
    I read all the threads that have to do with ChannelUtil, but I am a little confused on where or how to implement that class.

    Does the ChannelUtil go in the Preprocessor or Transformer or a Code Template.

    What I am trying to do is get the Channel Name, Channel ID and the connectors into one readable file.

    Does any on have an example that they can share?

    Thank you,
    Rubi

  • #2
    Hi Rubi,

    I do not have an example but here is a link to ChannelUtil.

    http://javadocs.mirthcorp.com/connec...annelUtil.html

    This is for version 3.2.2 not sure what version you are on?

    I usually use it in a javascript transformer step. You could also do:
    Code:
     logger.info(ChannelUtil.getChannelNames());
    to see what results you are getting.

    Also don't forget about auto complete Mirth has added, you can type ChannelUtil. and a list will appear with uses.

    Can you clarify more the use you need? You want the channel name/channel id/ and connectors of each channel in connect?

    Hope this helps some!

    Comment


    • #3
      Hi jadams4,

      I am on version 3.2.0 and Yes I am looking to get the Channel Name/Channel ID/ Is the Channel Enabled or disabled/Connectors and if connectors are Enabled or disabled.

      Wouldn't the logger.info(ChannelUtil.getChannelNames()); just place the message in the Dash board? I am looking to write it to a file.

      Comment


      • #4
        Originally posted by Rubicon View Post
        Hi jadams4,

        I am on version 3.2.0 and Yes I am looking to get the Channel Name/Channel ID/ Is the Channel Enabled or disabled/Connectors and if connectors are Enabled or disabled.

        Wouldn't the logger.info(ChannelUtil.getChannelNames()); just place the message in the Dash board? I am looking to write it to a file.
        To write to file, you could code that within a transformer step.

        Comment


        • #5
          I'm not sure on how to do that. What would be the source? Where do I put the transformer? In source Tab or destination Tab?

          Comment


          • #6
            Yes, this would place it in the dashboard. I meant you could use this to see if the information you want is correct. Then once you have what you want, for example:

            logger.info("Is channel deployed: " +ChannelUtil.getChannelState());
            logger.info(whatever other info you want here);
            // keep logging until you have everything you want

            Once you verify everything you want is working how you intend in the dashboard, you could create a destination with these transformers that is a file write. Then save this info in the channelmap and use it in the template to write to a file.

            Comment


            • #7
              Destination Transformer:
              Code:
              var fileContents = 'ChannelId: '+channelId+'\n'+'Channel Name: '+ChannelUtil.getChannelName(channelId);
              channelMap.put('fileContents', fileContents);
              Destination File writer template:
              Code:
              ${fileContents}

              Comment


              • #8
                Thank you mcalKno,
                I am getting an error of:
                Java class "com.mirth.connect.server.userutil.ChannelUtil " has no public instance field or method named "getChannelName".

                Attached is my Channel
                Attached Files

                Comment


                • #9
                  Originally posted by Rubicon View Post
                  Thank you mcalKno,
                  I am getting an error of:
                  Java class "com.mirth.connect.server.userutil.ChannelUtil " has no public instance field or method named "getChannelName".

                  Attached is my Channel
                  This worked for me, so I'm thinking it is a version difference. I'm running the latest 3.3.

                  Comment


                  • #10
                    Can you post you channel?

                    Comment


                    • #11
                      Originally posted by Rubicon View Post
                      Can you post you channel?
                      i imported your channel that you attached and it worked without error.

                      Comment


                      • #12
                        Originally posted by mcalKno View Post
                        i imported your channel that you attached and it worked without error.
                        Hmmm...I'm using 3.2.0 and I thought that ChannelUtil was available for 3.2.0.

                        I can see the info from the Dashboard when I use logger.info(ChannelUtil.getChannelNames());

                        Comment


                        • #13
                          Originally posted by Rubicon View Post
                          Hmmm...I'm using 3.2.0 and I thought that ChannelUtil was available for 3.2.0.

                          I can see the info from the Dashboard when I use logger.info(ChannelUtil.getChannelNames());
                          i just added ChannelUtil.getChannelNames() to the transformer and it worked. Are you able to upgrade your mirth to the latest and try?

                          Comment


                          • #14
                            I can't upgrade at this time.

                            Comment


                            • #15
                              The method getChannelName(channelId) was added to ChannelUtil in 3.3: MIRTH-3677
                              Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

                              Nicholas Rupley
                              Work: 949-237-6069
                              Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


                              - How do I foo?
                              - You just bar.

                              Comment

                              Working...
                              X