Highlighted
Super Contributor.
Super Contributor.
187 views

ALM query not running from Workflow

Hello All,

I am trying to create a workflow which will determine if a Defect is linked with another defect and in case the defect is closed, it will notify owner of the linked defect that the original defect has been closed.

First step towards this is to identify if a Defect is linked with another defect.

In but_afterpost module, I am trying to run the below query.

'====================================

Dim com, rec, td, bugNo, Query, cnt
Set td = TDConnection
Set com = td.Command
bugNo = Bug_Fields("BG_BUG_ID").value
Query = "SELECT LN_LINK_ID FROM LINK WHERE LN_ENTITY_ID = '" & bugNo & "' and LN_ENTITY_TYPE = 'BUG'"
com.CommandText = Query
Set rec = com.Execute
cnt = rec.RecordCount
msgbox cnt
rec.First
for i=1 to cnt
msgbox i & ": " & rec.FieldValue(0)
rec.Next
next

'====================================

the Query output I tried to run as separate query in Analysis module and is producing proper result.

But from within the workflow, it seems it is not executing as it is not producing any count for recordset (cnt) as well as not providing any message for field values for rec.

I am not being able to identify what went wrong.

Can you kindly help.

0 Likes
8 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

If I understand correctly, you would like to get linked defects for a given defect.
If it is true, I think you wrote a wrong query. Try below one please.
Query = "SELECT LN_ENTITY_ID FROM LINK WHERE LN_BUG_ID = '" & bugNo & "' and LN_ENTITY_TYPE = 'BUG'"
0 Likes
Highlighted
Knowledge Partner Knowledge Partner
Knowledge Partner

In addition to above suggestion also try giving cint(bugno) or clng(bugno) and see if it is making the difference.
0 Likes
Highlighted
Super Contributor.
Super Contributor.

Thanks Roddy and Srihari for your suggestion.

I have made the changes according to both of you and my query looks like below:

'======-'
Dim com, rec, td, bugNo, Query, cnt
Set td = TDConnection
Set com = td.Command
bugNo = Bug_Fields("BG_BUG_ID").value
Query = "SELECT LN_ENTITY_ID FROM LINK WHERE LN_ENTITY_ID = '" & cint(bugNo) & "' and LN_ENTITY_TYPE = 'BUG'"
com.CommandText = Query
Set rec = com.Execute
cnt = rec.RecordCount
msgbox cnt
rec.First
for i=1 to cnt
msgbox i & ": " & rec.FieldValue(0)
rec.Next
next
'======-'

But still same issue. No output. Not sure what is wrong with this. It is suppose to be a straigt forward one. 😞

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Please note you set the wrong where clause.

Query = "SELECT LN_ENTITY_ID FROM LINK WHERE LN_BUG_ID = '" & bugNo & "' and LN_ENTITY_TYPE = 'BUG'"

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Even If I change the query and use one which produces a result set, it is not showing any output when I am trying to fetch the recordset using rec.

It seems the issues lies there. But not sure what it is.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

I used excatly the same code you provided and just changed the query as I described previously in workflow.

It pops up correct linked defect id as expected. Please check again, it is supposed to be working here.

0 Likes
Highlighted
Knowledge Partner Knowledge Partner
Knowledge Partner

Verify value of DISABLE_COMMAND_INTERFACE value in site admin parameters, if it is Y, change it to N and then try to perform same activity and see if it is resolving this issue.
0 Likes
Highlighted
Super Contributor.
Super Contributor.

Thanks Srihari for your suggestion. As I am using SaaS version, created a ticket with MF to check that.
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.