Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Visual Basic Sample Code to Access & Change a UDA List Attribute (Multiple Select List)

Visual Basic Sample Code to Access & Change a UDA List Attribute (Multiple Select List)

Problem:

Visual Basic Sample Code to Access & Change a UDA List Attribute (Multiple Select List)

Resolution:


  • Product Name: CaliberRM
  • Product Version: CaliberRM 2005 R2 SP1
  • Product Component: SDK
  • Platform/OS Version: Microsoft Platforms including XP / Windows 2000 / Windows Server 2003 / Windows Server 2005

Pre Requites

  1. CaliberRM SDK installed
  2. Microsoft Word / Office installed
  3. Basic understanding of Object Orientated Programming and Visual Basic for Applications (VBA)
  4. KB Article 5624: CaliberRM: Visual Basic for Applications (VBA) , setting up a Microsoft Word VBA application. http://support.borland.com/entry.jspa?categoryID=435&externalID=5623

Sample Code to Access and Set a UDA List Value

Note: TheMultiple Selection Listis the same as alist box

This code sample uses 2 procedure to set a multiple select list. A multiple select list is a collection of CaliberRM Objects.

Dim my_collection As CaliberRM.Collection

A collection contains the information about the list i.e. if selected or not

To make changes to the collection we have to:

1. Create the collection

2. Copy original collection making require changes into the new collection.

3. Update UDA List

The Set_msl procedure parses the selection list (items to be selected) i.e. "1,2,5" or "item1,item2,item5", it then call the Set_msl_item which creates a new collection with the changes to the updated item.

Sub Set_msl(my_req As Requirement, Selection_List as String, no_of_attributes As Integer, my_collection As CaliberRM.Collection)

"Parse a MSL stringcall procedure to select items

Dim the_string As String

Dim temp_string As String

"title of column is UDA name

.uda_name = ActiveSheet.Cells(1, column)

"parse list using a comma as a delimiter

chk_data = Selection_List

string_length = Len(chk_data)

temp_string = ""

the_string = ""

the_chr = ""

strt = 1

Offset = 0

For i = 1 To string_length

the_chr = Mid(chk_data, i, 1)

Debug.Print the_chr

If the_chr <> "," Then temp_string = Mid(chk_data, strt, i - Offset)

Debug.Print temp_string

If the_chr = "," Then

the_string = temp_string

temp_string = ""

Offset = i

Debug.Print the_string

"select parsed item

Set_msl_item my_req, UDA_name, no_of_attributes, the_string, my_collection

strt = i + 1

End If

Next

Debug.Print temp_string

select last item

Set_msl_item my_req, UDA_name, no_of_attributes, temp_string, my_collection

End Sub

Sub Set_msl_item(my_req As Requirement,uda_name As String, no_of_attributes As Integer, uda_value As String, my_collection As CaliberRM.Collection)"Select an item in a Multiple Select list

Dim my_attribute As AttributeValue

Dim found_it, found_item As Boolean

Dim att_count, att_item As Integer

Dim my_uda_list As UDAListValue

found_it = False

found_item = False

att_count = 0

att_item = 0

Loop through attributes to find the Ref ID

Do While found_it = False "And att_count

Set my_attribute = my_req.AttributeValues.Item(att_count)

If my_attribute.Attribute.Name = uda_name Then

Ref to Ref ID in Excel Spread Sheet

chk_data = uda_value

found_it = True

Multiple and single Lists

Set my_uda_list = my_attribute

no_in_list = my_uda_list.ListEntries.Count

Do While found_item = False And att_item <>

Set mylistselect = my_uda_list.ListEntries.Item(att_item)

the_result = my_uda_list.ListEntries.Item(att_item).toString

myans = InStr(the_result, chk_data)

If myans > 0 Then

found_item = True

my_req.lock

"add selected item to collection

my_collection.Add (att_item)

my_uda_list.SelectedIndices = my_collection

my_req.Save "Data Changed"

my_req.unlock

End If

att_item = att_item + 1

Loop

End If

att_count = att_count + 1

Loop

End Sub


Old KB# 15856

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 18:26
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.