Gareth,

I'm still using VB6 here, so I'm not sure if this will be much help, but
here is a module (.bas) I use. It has sections for creating records,
updating records, running queries, importing records, retrieving
attachments, and running process commands (specifically, I use this for
the Application-Generate-GUID process, but it should work for others as
well). This was written using build 7.0.2523.16350 of the .NET wrapper.



HTH

Mark 


//SIGNED//
MARK A. WORLEY, Contractor, 2 SOS/SYOS
Remedy ARS Support, SAIC
Commercial: (402) 294-8226
DSN:  271-8226
mailto:[EMAIL PROTECTED]

-----Original Message-----
From: Action Request System discussion list(ARSList)
[mailto:[EMAIL PROTECTED] On Behalf Of Gareth Oliver
Sent: Tuesday, April 10, 2007 22:57
To: [email protected]
Subject: Re: .net Utilities on ARSWiki.org

Very useful - two apps one for Delete existing entry, one for Modifying
existing entry.
 
Question - does anyone have a sample application that does a Query for a
record based on a qualification, then a modification of that record.
 
Thanks

________________________________

From: Action Request System discussion list(ARSList) on behalf of Axton
Sent: Thu 05/04/07 09:30
To: ARSList
Subject: .net Utilities on ARSWiki.org



I wanted to announce a set of .net utilities hosted on ARSWiki.  Many
thanks to Stephen Heider for releasing these under an open source
license and adding these to the ARSWiki site.

http://arswiki.org/projects/dotnetutil

If you want to learn .net, contribute to these .net utilities, or add
additional .net utilities to the site, reference the link above for
information.

Axton Grams

________________________________________________________________________
_______
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org ARSlist:"Where
the Answers Are"

________________________________________________________________________
_______
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org ARSlist:"Where
the Answers Are"

_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org ARSlist:"Where the 
Answers Are"
Attribute VB_Name = "Multi_ARS"
'******************************************************************************
'Module Name:           Multi_ARS
'Module Version:        1.0.0
'Purpose:               reusable code to enter data into remedy via the API
'Description:           uses the unsupport Remedy .net wrapper
'Procedures:            OpenARS; CreateRecord; UpdateRecord; CloseARS
'Functions:
'Additional Modules:
'Included Forms:
'Remedy/SQL Tables:
'Other Dependencies:    Wrapper assembly for interacting with Remedy AR System
'Modifications:
' 2005/06/10  1.0.0 Mark A Worley (SAIC)
'   Initial Release
' 2006/04/10  1.0.1 Mark A Worley (SAIC)
'   Added Run_Process procedure
' 2006/12/08  1.0.2 Mark A Worley (SAIC)
'   Added Run_Query and Return_Record functions
' 2006/12/15  2.0.0 Mark A Worley (SAIC)
'   Updated module using version 7.0.2523.16350 of the arsystem api wrapper
'******************************************************************************

Option Explicit

Private ARS_Connection() As Object  ' array of server objects
'******************************************************************************
' The OpenARS procedure is used to do the initial login to an ARS server, the
'   expected parameters are the name of the server (ARS_Server), the user to
'   log in as (ARS_User), the user's password (ARS_Password), an integer to
'   keep track of the connection number (ConnectionNumber). The variable used
'   for the ConnectionNumber will be altered in the calling procedure after
'   this procedure finishes.
'------------------------------------------------------------------------------
Public Sub OpenARS(ByVal ARS_Server As String, _
  ByVal ARS_User As String, _
  ByVal ARS_Password As String, _
  ByRef ConnectionNumber As Integer)
  Static nextConn As Integer    ' static variable for next connection
  
  If nextConn = 0 Then nextConn = 1
  
  ReDim Preserve ARS_Connection(1 To nextConn)
  
  ConnectionNumber = nextConn
  
' *** Login to the Remedy server as specified by procedure parameters
  Set ARS_Connection(nextConn) = CreateObject("BMC.ARSystem.Server")
  ARS_Connection(nextConn).Login ARS_Server, ARS_User, ARS_Password
  ARS_Connection(nextConn).UseDefaultPort
  
  nextConn = nextConn + 1
  
End Sub
'------------------------------------------------------------------------------

'******************************************************************************
' The UpdateRecord procedure is used to update an existing record. The
'   expected parameters are the name of the Remedy schema (Schema), the full
'   request id value (field 1) of the record to update (Request_ID), an array
'   that maps the field ids to update to an updated value (FieldMapping), and
'   the ConnectionNumber that was "returned" from a prior call to the OpenARS
'   procedure.
'
'   CallMapping input: two dimensional array (x, 1), variable number of rows,
'     only two columns, first column s/b the field id to update, second column
'     is the value to place in the field
'------------------------------------------------------------------------------
Public Sub UpdateRecord(ByVal Schema As String, _
  ByVal Request_ID As String, _
  ByVal FieldMapping As Variant, _
  ByVal ConnectionNumber As Integer)
  Dim fieldValues As Object     ' API field value object
  Dim loopy As Integer          ' variable for looping through the array
  
' *** loop through the input array and assign vales to the appropriate ids
  Set fieldValues = CreateObject("BMC.ARSystem.FieldValueList")
  Do While loopy <= UBound(FieldMapping, 1)
    If FieldMapping(loopy, 0) <> "" Then
      If FieldMapping(loopy, 0) <> "1" Then _
        fieldValues.Item(FieldMapping(loopy, 0)) = FieldMapping(loopy, 1)
    End If
    loopy = loopy + 1
  Loop
  
' *** apply the update using the api
  ARS_Connection(ConnectionNumber).SetEntry Schema, Request_ID, fieldValues

End Sub
'------------------------------------------------------------------------------

'******************************************************************************
' The CreateRecord procedure is used to create a new record. The expected
'   parameters are the name of the Remedy schema (Schema), an array that maps
'   the field ids to input values (FieldMapping), and the ConnectionNumber
'   that was "returned" from a prior call to the OpenARS procedure.
'
'   CallMapping input: two dimensional array (x, 1), variable number of rows,
'     only two columns, first column s/b the field id to update, second column
'     is the value to place in the field
'------------------------------------------------------------------------------
Public Sub CreateRecord(ByVal Schema As String, _
  ByVal FieldMapping As Variant, _
  ByVal ConnectionNumber As Integer)
  Dim fieldValues As Object ' API field value object
  Dim loopy As Integer      ' variable for looping through the array
  
' *** loop through the input array and assign values to the appropriate fields
  Set fieldValues = CreateObject("BMC.ARSystem.FieldValueList")
  Do While loopy <= UBound(FieldMapping, 1)
    If FieldMapping(loopy, 0) <> "" Then
      If FieldMapping(loopy, 0) <> "1" Then _
        fieldValues.Item(FieldMapping(loopy, 0)) = FieldMapping(loopy, 1)
    End If
    loopy = loopy + 1
  Loop
  
' *** create the record using the api
  ARS_Connection(ConnectionNumber).CreateEntry Schema, _
    fieldValues
  
End Sub
'------------------------------------------------------------------------------

'******************************************************************************
' The CloseARS procedure is used to close an existing ARS Connection. The
'   expected parameter is the ConnectionNumber that was "returned" from a prior
'   call to the OpenARS procedure.
'------------------------------------------------------------------------------
Public Sub CloseARS(ByVal ConnectionNumber As Integer)

' *** release the connection object
  ARS_Connection(ConnectionNumber).Logout
  Set ARS_Connection(ConnectionNumber) = Nothing
  
End Sub
'------------------------------------------------------------------------------

'******************************************************************************
' The Run_Query function is used to return a entryIDList of records matching
'   the provided query. The expected parameters are the ConnectionNumber that
'   was "returned" from a prior call to the OpenARS procedure, a SchemaName for
'   which table to query, and a QueryToRun.
'------------------------------------------------------------------------------
Public Function Run_Query(ByVal ConnectionNumber As Integer, _
  ByVal SchemaName As String, _
  ByVal QueryToRun As String) As Object
  Dim returnList As Object
  
' *** run the query on the remedy connection
  Set returnList = ARS_Connection(ConnectionNumber).GetListEntry _
    (SchemaName, QueryToRun)
  
' *** return the results of the query
  Set Run_Query = returnList
  
End Function
'------------------------------------------------------------------------------

'******************************************************************************
' The Return_Record function is used to return data for a specific record. The
'   expected parameters are the ConnectionNumber that was "returned" from a
'   prior call to the OpenARS procedure, a SchemaName for which table to query,
'   and an appropriately fomatted RecordID for the row to be returned.
'------------------------------------------------------------------------------
Public Function Return_Record(ByVal ConnectionNumber As Integer, _
  ByVal SchemaName As String, _
  ByVal RecordID As String) As Object
  Dim recordOut As Variant      ' Field data returned from Remedy.
  
' *** Query the remedy connection for the record on the table
  Set recordOut = ARS_Connection(ConnectionNumber).GetEntry _
    (SchemaName, RecordID)
  
' *** Return the data from the query
  Set Return_Record = recordOut
  
End Function
'------------------------------------------------------------------------------

'******************************************************************************
' The CloseARS procedure is used to close an existing ARS Connection. The
'   expected parameter is the ConnectionNumber that was "returned" from a prior
'   call to the OpenARS procedure.
'------------------------------------------------------------------------------
Public Sub Run_Process(ByVal ProcessCall As String, _
  ByVal ConnectionNumber As Integer, _
  Optional ByRef ProcessReturn As String)
  Dim procResult As Variant
  
  Set procResult = ARS_Connection(ConnectionNumber).ExecuteProcess(ProcessCall)
  ProcessReturn = procResult.ReturnString
  
End Sub
'------------------------------------------------------------------------------

'******************************************************************************
' The MergeRecord procedure is used to import a record into the database. The
'   expected parameters are the name of the Remedy schema (Schema), an integer
'   determining what to do with duplicate records, a boolean to indicate that
'   filters should/should not be ran, an array that maps the field ids to
'   update to an updated value (FieldMapping), and the ConnectionNumber that
'   was "returned" from a prior call to the OpenARS procedure.
'
'   CallMapping input: two dimensional array (x, 1), variable number of rows,
'     only two columns, first column s/b the field id to update, second column
'     is the value to place in the field
'------------------------------------------------------------------------------
Public Sub MergeRecord(ByVal Schema As String, _
  ByVal MergeDuplicateOption As Integer, _
  ByVal SuppressFilters As Boolean, _
  ByVal FieldMapping As Variant, _
  ByVal ConnectionNumber As Integer)
  Dim fieldValues As Object     ' API field value object
  Dim requestObj As Object      ' API request (record) object
  Dim loopy As Integer          ' variable for looping through the array
  
' *** loop through the input array and assign vales to the appropriate ids
  Set fieldValues = CreateObject("BMC.ARSystem.FieldValueList")
  Do While loopy <= UBound(FieldMapping, 1)
    If FieldMapping(loopy, 0) <> "" Then
      fieldValues.Item(FieldMapping(loopy, 0)) = FieldMapping(loopy, 1)
    End If
    loopy = loopy + 1
  Loop
  
' *** merge the record using the api
  ARS_Connection(ConnectionNumber).MergeEntry Schema, fieldValues, _
    MergeDuplicateOption, True, True, SuppressFilters

End Sub
'------------------------------------------------------------------------------

'******************************************************************************
'------------------------------------------------------------------------------
Public Sub RetieveAttachment(ByVal Schema As String, _
  ByVal RequestID As String, _
  ByVal AttachFieldID As Long, _
  ByVal OutputFileName As String, _
  ByVal ConnectionNumber As Integer)
  
  ARS_Connection(ConnectionNumber).GetEntryBLOB Schema, RequestID, _
    AttachFieldID, OutputFileName
  
End Sub
'------------------------------------------------------------------------------

Reply via email to