Interacting with Remedy AR System DiaryFields
By: Seth Hall
By: Seth Hall
For those who have followed the other tutorials with Remedy AR System you notice that I never messed with DiaryFields. I finally got some time in to play around with them and decided to share it with you. If you haven’t followed my other tutorials then you will need to go back to those to fully establish a solid Remedy connection to your application.
The first part of this tutorial is a Console Application which retrieves the number of Diary entries, last modified by, etc. The last part will show you how to actually add information to those DiaryFields.
Imports BMC
Module Test
Public Class GetDiary
' Server info
Shared servername As String = "REMOVED"
Shared username As String = "REMOVED"
Shared password As String = "REMOVED"
' This is the field ID that you want to get the information from
Shared EntryID As String = "000000058134285"
Shared DiaryFieldID As UInteger = 536870967
Shared Form As String = "ISD"
'
Shared Server As New ARSystem.Server
Shared Sub Main()
‘ Try logging in to the Remedy Server to pull the info. Remember your Field IDs and Form names will vary and ‘ you should contact your Remedy Admin for any questions regarding your environment.
Try
Login()
Dim IDS() As UInteger = {1, 5, DiaryFieldID}
Dim record As ARSystem.FieldValueList = Server.GetEntry(Form, EntryID, IDS)
If Not IsDBNull(record.Item(1)) Then
Console.WriteLine("Retrieved record no: " & CType(record.Item(1), String))
End If
If Not IsDBNull(record.Item(5)) Then
Console.WriteLine("Record was last modified by: " & CType(record.Item(5), String))
End If
‘ Get Diary Field
If Not IsDBNull(record.Item(DiaryFieldID)) Then
Dim Diary As ARSystem.DiaryList = CType(record.Item(DiaryFieldID), ARSystem.DiaryList)
Console.WriteLine(Diary.Count & " Diary entries found." & vbNewLine & vbNewLine)
For Each Entry As ARSystem.DiaryEntry In Diary
Console.Write(Entry.User & " - ")
Console.WriteLine(Entry.Time)
Console.WriteLine(Entry.Text)
Next
End If
Catch ex As System.Exception
Console.Write("ERROR: " & ex.Message)
Finally
Logout()
End Try
Console.ReadLine()
End Sub
Public Shared Sub Login()
Try
Server.Login(servername, username, password, "", 24341)
Dim UI() As ARSystem.UserInfo = Server.GetListUser(ARSystem.Server.UserListType.Myself, New Date(2000, 1, 1))
Catch ex As Exception
Throw New System.Exception(ex.Message, ex.InnerException)
Exit Sub
End Try
End Sub
Public Shared Sub Logout()
Server.Logout()
End Sub
End Class
End Module
For the second part we will actually connect and be able to update a DiaryField on a help ticket. For this since we don’t need to keep a constant connection to the Remedy Server, I have declared it to just Login once, post the information then it will logout.
Imports BMC
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
‘ Declare our variables for our environment
Dim username As String = "REMOVED"
Dim password As String = "REMOVED"
Dim Fields As New ARSystem.FieldValueList
Dim entryID As New ARSystem.EntryListFieldList
Dim form As String = "ISD"
Dim ARServer As New ARSystem.Server
‘ Login to Remedy Server
ARServer.Login("SERVERNAME", username, password, "", PORTNUMBER)
‘ Here we add the LOG field(10) which is a DiaryField and set what we want to write to it.
Fields.Add(10, "Dashboard Automation Test - " & Now())
Dim record As New ARSystem.FieldValueList
‘ Update Diary Field
ARServer.SetEntry("ISD", "TICKETNUMBER", Fields)
End Sub
End Class
That’s all. I’ve added link to the past two tutorials which will get you started connecting and creating tickets with the Remedy AR System. If you have any questions or would like to request a tutorial just leave a comment.
Connecting to Remedy AR System with .NET API
Creating Tickets with Remedy AR System





MultiQuote


|