1 2 Previous Next 20 Replies Latest reply on Apr 29, 2014 5:27 PM by Carl Wilson Branched from an earlier discussion.

    Java API - Form Queries and Error Messages

      Share This:

      Hi Matheo, I got connection now. Thanks for your help I've tried to use the client, but instead to use the server name, I've connected the IP with the Port, so I did the same in Java, use the IP with Port.

       

      Now I have more 2 questions, should I create another discussion?

       

      - User connected from another machine. ERROR(9093) User is currently connected from another machine, but this user is connected only in my machine. Why I received that?

       

      private static void showARSystemDetails() {
             System.out.println("AR Server version: " + ctx.getServerVersion() + "\n");
             System.out.println("List all connected users and last accessed time");
        try {
             for (UserInfo user : ctx.getListUser(Constants.AR_USER_LIST_CURRENT)) {
                  System.out.println("   " + user.getUserName() + " - " + user.getLastAccessTime().toDate());
             }
        } catch (ARException e) {
             System.out.println(e.getMessage());
        }
      }
      
      

       

      AR Server version: 7.1.00 Patch 011 RTLW_01/02/2014_SW00379074

       

       

      List all connected users and last accessed time

      ERROR (9093): User is currently connected from another machine;

       

      - Is there a data model documentation? I need to know how to query incidents.

       

      For example, when I open a request I see this link . How can I found the schema/table?

      http://ip/arsys/forms/remedytdata/HPD%3AHelp+Desk/OPT+Brasil+View/?cacheid=b8cb7455

       

      private static void getAPITutorialSampleEntry() {
        String schemaName = "CTM:AuditLogSystem";
        String entryID = "1";
      
        try {
        Entry record = ctx.getEntry(schemaName, entryID, null);
             for (Integer i : record.keySet()) {
                  System.out.println(record.get(i));
             }
        } catch (ARException e) {
             System.out.println(e.getMessage());
        }
      
      }
      
      

       

      Thanks

        • 1. Re: Java API - Form Queries and Error Messages

          I'm trying to execute a query given in the tutorial example. Should be return empty in case there aren't values with This is, right?

           

          private static void getAPITutorialSampleEntry() {
            String schemaName = "CTM:AuditLogSystem";
            String queryString = "'Character Field' LIKE \"This is a%\"";
          
            try {
                 QualifierInfo qual = ctx.parseQualification(schemaName, queryString);
                 List<EntryListInfo> eListInfos = ctx.getListEntry(schemaName, qual, 0, 0, null, null, false, null);
          
                 for (EntryListInfo eListInfo : eListInfos) {
                      Entry record = ctx.getEntry(schemaName, eListInfo.getEntryID(),null);
                 
                      for (Integer i : record.keySet()) {
                           System.out.println(record.get(i));
                      }
                 }
            } catch (ARException e) {
                 System.out.println(e.getMessage());
            }
          }
          

           

          ERROR (4558): Qualification line error;

          ERROR (2297): Unknown field reference;  position 17   (...haracter Field'^ LIKE "a a%")

          • 2. Re: Java API - Form Queries and Error Messages
            Carl Wilson

            Hi,

            I have branched this to another topic as the original was answered.

            To answer your 2 questions:

             

            1.  Dependent on the permissions for the user, and if you exited correctly (logged out) you will see this message if the user deemed to be connected i.e. the system has registered that username as being logged in.

            2.  The error from the query is pointing out that it is incorrectly formatted and it cannot find a field named 'Character Field'.  You need to replace 'Character Field' with either a valid field name or field id from the form you are querying.

             

            As Laurent mentions in the other discussion, there are a large number of topic on the Java API that you can reference with example code.

             

            Cheers

            Carl

             

            http://www.missingpiecessoftware.com/

            • 3. Re: Java API - Form Queries and Error Messages
              Laurent Matheo

              Gg for the connection

               

              For the rest, Carl Wilson answered

              Since you don't post your code completly (login / logout) we have no way to know what you're doing ok or not.

              In C it would be ARTermination:

              https://docs.bmc.com/docs/display/public/ars81/ARTermination

               

              In Java it should be server.logout (well, from the server object), you have a full example here in the doc wiki:

              https://docs.bmc.com/docs/display/public/ars81/Java+API+sample+code+for+managing+BMC+Remedy+AR+System+records

              • 4. Re: Java API - Form Queries and Error Messages

                Thanks Carl Wilson to create another topic.

                 

                1. I'm using another user. It's working.

                2. I'm searching about Data Model, I need to do some queries to get incidents. I found this schema/table in an example CTM:AuditLogSystem. I'd like to do something like that. SELECT * FROM CTM:AuditLogSystem.

                 

                Just for tests, can you tell me a table to do select? SELECT * FROM CTM:AuditLogSystem

                 

                private static void getAPITutorialSampleEntry() {
                     String schemaName = "CTM:AuditLogSystem";
                     String queryString = "SELECT * FROM CTM:AuditLogSystem";
                
                     try {
                            QualifierInfo qual = ctx.parseQualification(schemaName, queryString);
                            List<EntryListInfo> eListInfos = ctx.getListEntry(schemaName, qual, 0, 0, null, null, false, null);
                
                            for (EntryListInfo eListInfo : eListInfos) {
                                      Entry record = ctx.getEntry(schemaName, eListInfo.getEntryID(), null);
                
                                 for (Integer i : record.keySet()) {
                                      System.out.println(record.get(i));
                                 }
                            }
                     } catch (ARException e) {
                            System.out.println(e.getMessage());
                     }
                }
                
                

                 

                JDBC: https://developer.bmc.com/legal/arjdbc10/JDBC_database_access.pdf

                Do you know if there is a model data for Remedy, if the tables for incidents are default, where I can found tables with incidents? I don't know if another team has created the tables. Do you know any default table?

                 

                I'm also developing using JDBC, but doesn't exist AuditLogSystem.

                 

                ResultSet rs = st.executeQuery("select * from CTM:AuditLogSystem")
                

                 

                ERROR (303): Form does not exist on server CTM

                • 5. Re: Java API - Form Queries and Error Messages

                  Hi guys, Thanks for your help.

                   

                  I've completed here.

                   

                  private static void getAPITutorialSampleEntry() {
                    String schemaName = "HPD:Help Desk";
                    String queryString = "'Status' = \"Assigned\"";
                  
                    try {
                         QualifierInfo qual = ctx.parseQualification(schemaName, queryString);
                         List<EntryListInfo> eListInfos = ctx.getListEntry(schemaName, qual, 0, 0, null, null, false, null);
                  
                         for (EntryListInfo eListInfo : eListInfos) {
                              Entry record = ctx.getEntry(schemaName, eListInfo.getEntryID(), null);
                  
                              for (Integer i : record.keySet()) {
                                   System.out.println(record.get(i));
                               }
                         }
                    } catch (ARException e) {
                         System.out.println(e.getMessage());
                    }
                  }
                  

                   

                  I'll finish my script with connection and queries, If I could share with the community the solution, let me know how to do that.

                   

                  Thanks a lot.

                  • 6. Re: Re: Java API - Form Queries and Error Messages
                    Laurent Matheo

                    Select * is SQL query, it will only work for JDBC / ODBC.

                    As for JDBC, if you don't use "mode=new", it's CTM_AuditLogSystem, see the Curtis Gallant post here:

                    BMC Remedy AR System JDBC Driver 1.0.2

                     

                     

                    As for qualification and fields to get, you have a full example here:

                    AR System APIs Quick Start Java

                     

                    This is the form the qualification is done on: "API:TUTORIAL"

                    The qualification (that can be used by ARS, in Advanced search for example) is: 'Character Field' LIKE "This is a%"

                     

                    • You "parse" the qualification using "parseQualification",
                    • You get a list of entries that match the qualification using "getListEntry"
                    • You actually get the entries using getEntry,
                    • You traverse the list of fields fetched using the "for" loop,

                     

                    private static void getAPITutorialEntries() {
                        String schemaName = "API:TUTORIAL";
                        String queryString = "'Character Field' LIKE \"This is a%\"";
                        try {
                            QualifierInfo qual = ctx.parseQualification(schemaName, queryString);
                            List<EntryListInfo> eListInfos = ctx.getListEntry(schemaName, qual, 0, 0, null, null, false, null);
                            for (EntryListInfo eListInfo : eListInfos) {
                                Entry record = ctx.getEntry(schemaName,eListInfo.getEntryID(), null);
                                for (Integer i : record.keySet()) {
                                    System.out.println(record.get(i));
                                }
                            }
                        } catch (ARException e) {
                            System.out.println(e.getMessage());
                        }
                    }
                    

                     

                    Here you don't specify a field list you want to fetch, so you'll get all fields.

                    Like said in the document, the list of fields you'd like to get can be defined in the third parameter of GetEntry:

                    • String schemaName
                    • String requestID
                    • int[] fieldList

                     

                    Here I just fetch three fields (not a full code here...), I'm not using the same APIs but the idea is the same.

                    23-04-2014 20-14-32.png

                     

                     

                    As for the data model, there is none (or old docs, sometimes...), logs, Developer Studio and BMC Community will mostly be your best friends.

                     

                     

                    Btw, you have the details of the APIs in a "ardocXX_buildXXX.jar" jar file (explained here AR System APIs Quick Start Java - Dev Environment Setup).

                    • 7. Re: Re: Java API - Form Queries and Error Messages
                      Laurent Matheo

                      You can create a blog entry or a document if you want to share something

                      • 8. Re: Java API - Form Queries and Error Messages

                        Last question

                         

                        getAPITutorialEntries

                        The output will return only the values, how we can show the title/field name?

                        • 9. Re: Java API - Form Queries and Error Messages
                          Laurent Matheo

                          Well, since KeySet is a Hash Map, the field id is simply... i.

                          • 10. Re: Java API - Form Queries and Error Messages

                            Right, but it's the ID, how to get the label?

                             

                            Easy way to extract field Name and Field Label for all forms

                            Is possible to extract the field name, but is hard to do the mapping for all fields, is possible to get just the label?

                            • 11. Re: Re: Java API - Form Queries and Error Messages
                              Laurent Matheo

                              If you want the field name, once again it's in the demo code from Misi (AR System APIs Quick Start Java)...

                              Field field = ctx.getField(schemaName, fieldID)
                              field.getName()
                              

                               

                              So in your example:

                              for (Integer i : record.keySet())
                              {
                                Field field = ctx.getField(schemaName, i)
                                System.out.println("Field ID = " + i + ", FieldName= " + field.getName() + ", Value= " + record.get(i));
                              }
                              
                              • 12. Re: Re: Re: Java API - Form Queries and Error Messages
                                Laurent Matheo

                                If you want to get the Field Label (the REAL label, not the field name), it's more tricky...

                                 

                                You have to get the "Field" object, the get the "getDisplayInstance" that will return all display properties of the field, per view.

                                Then, for a view, do a keySet to get all properties, something like this:

                                 

                                for (Integer i : record.keySet())  
                                {  
                                  Field field = ctx.getField(schemaName, i)  
                                  System.out.println("Field ID = " + i + ", FieldName= " + field.getName() + ", Value= " + record.get(i));  
                                
                                
                                  DisplayInstanceMap MyInstMap=null;
                                  MyInstMap=field.getDisplayInstance();
                                
                                
                                  //Per view
                                  for (Integer j : MyInstMap.keySet())
                                  {
                                  System.out.println("View ID: " + j);
                                
                                
                                  //Properties per view
                                  DisplayPropertyMap MyPropertyMap=null;
                                  MyPropertyMap=MyInstMap.get(j);
                                
                                  for (Integer m : MyPropertyMap.keySet())
                                  {
                                  System.out.println("-> Property: " + m + "=" + MyPropertyMap.get(m));
                                  }
                                
                                  }
                                
                                
                                }  
                                

                                 

                                 

                                Then you ID the "m" where the label is (20), in my example (on a code I have) it gives something like:

                                Field in database is "Company" and its label in view 399990088 is "Company+".

                                23-04-2014 22-35-41.png

                                1 of 1 people found this helpful
                                • 13. Re: Re: Re: Re: Java API - Form Queries and Error Messages

                                  Hi Matheo,

                                   

                                  The Field name is perfect for me. Sorry,  I saw it on documentation but didn't know what it was.

                                   

                                  Field field = ctx.getField(schemaName, i);
                                  

                                   

                                  Thank you.

                                  1 2 Previous Next