Priyotosh_ganguly Valued Contributor.
Valued Contributor.
197 views

UPDATE Requirement Type using Command

I am trying to implement a Workflow change, where after Requirement gets dragged into a particular folder (TrashCan), Requirement type needs to be set to 'Undefined'

I am trying to run update Query from Req_AfterPost

Sub Req_AfterPost

if Req_Fields.Field("RQ_FATHER_ID").Value= 58 then   'TrashCan folder value

change_req_type_to_undefined()

End Sub

 

Sub change_req_type_to_undefined

On Error Resume Next

dim query
dim com
dim updateReq
ReqId = Req_Fields.Field("RQ_REQ_ID").Value
set com = TDConnection.Command

Query = "UPDATE REQ Set RQ_REQ_TYPE = '0' WHERE (RQ_REQ_ID = '"& ReqID & "')"

com.CommandText = Query
Set updateReq = com.Execute

On Error GoTo 0
End Sub

But nothing is geting changed. Even I tried to update Requirement Name but it is not effecting the Requirement.

Can you please help.

 

0 Likes
8 Replies
Chris_Grz Outstanding Contributor.
Outstanding Contributor.

Re: UPDATE Requirement Type using Command

It seems that there are two errors in your UPDATE statement:

1) Do not set RQ_REQ_TYPE which is obsolete but set RQ_TYPE_ID to 0 (zero, without any quote: this is an integer)

2) RQ_REQ_ID also is an integer so its value should not be enclosed in quotes.

"UPDATE REQ SET RQ_TYPE_ID = 0 WHERE RQ_REQ_ID = " & CStr (ReqId)

To insure the integrity of the database, you should make sure that the fields of a requirement of type Undefined are compatible with the fields of the initial requirement type.

0 Likes
Priyotosh_ganguly Valued Contributor.
Valued Contributor.

Re: UPDATE Requirement Type using Command

@Chris_Grz

Really appreciate your input to solve the issue.

I tried to execute the Query that you recommended.

But still there is no change in attribute of the Dragged Requirement. 

0 Likes
Priyotosh_ganguly Valued Contributor.
Valued Contributor.

Re: UPDATE Requirement Type using Command

Is there any possibility that the Query is not being executed at all.

User ID is having TDAdmin access, hence should not be a access privilege issue.

 

0 Likes
Chris_Grz Outstanding Contributor.
Outstanding Contributor.

Re: UPDATE Requirement Type using Command

We need to know what error is raised. To that end, please insert the following statements in the change_req_type_to_undefined sub, just before the On Error GoTo 0 statement:

If Err.Number <> 0 Then
    MsgBox Err.Description
Else
   MsgBox "No error in change_req_type_to_undefined"
End If

0 Likes
Knowledge Partner
Knowledge Partner

Re: UPDATE Requirement Type using Command

Hi Priyotosh_Ganguly,

Tried without using command object, please validate and check if it is helpful in your case.

Is there any specific reason on why you are choosing to perform this requirement using SQL query via command object? In general posts(updates) via OTA API is preferred over database updates in most of the cases because it will take care of the linkages between various connected tables .

Sub Req_FieldChange(FieldName)
 ' On Error Resume Next
  If FieldName = "RQ_FATHER_ID" Then
      Set Parent_Req= TDConnection.ReqFactory.Item(Req_Fields.Field("RQ_FATHER_ID").Value)
      Set Moved_Req= TDConnection.ReqFactory.Item(Req_Fields.Field("RQ_REQ_ID").Value)
      If Parent_Req.Name = "TrashCan" and Parent_Req.TypeID="Folder" Then
         If Req_Fields.Field("RQ_TYPE_ID").Value <> "Undefined" Then
            Moved_Req.TypeID =  "Undefined"
            Moved_Req.Post
            Actions.Action("actFilterRefresh").Execute
         End IF
      End IF
  End IF
 ' On Error GoTo 0
End Sub

 

Regards,Srihari

0 Likes
Priyotosh_ganguly Valued Contributor.
Valued Contributor.

Re: UPDATE Requirement Type using Command

Hi Chris,
Thanks for your reply. It shows error message 'Object Required'
0 Likes
Priyotosh_ganguly Valued Contributor.
Valued Contributor.

Re: UPDATE Requirement Type using Command

Hi Srihari,
Thanks a lot for your reply. I tried this piece of code but it actually did not change the Requirement type after dragging into TrashCan. I checked for any error message, but not throwing any error message either.
0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

Re: UPDATE Requirement Type using Command

Hi ,
What is the exact name of your thrash can folder present in ALM?
We need to tweak provided code as per exact name ex: "TrashCan" or "trashcan" or "Trashcan", also is your trashcan requirement is of type Folder?
Please put message boxes in the provided code and check where it is deviating.
Regards,
Srihari
0 Likes
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.