emanriq
Visitor.
675 views

User field required based on status of other field

Jump to solution

Hi Colleagues,

I think it is better to do it through a different thread in order to solve it. I am pretty sure the question is easy

I am trying to do it working on Test Lab but I do not get it. I am trying that when an user changes the status of a test case to 'Blocked', it was mandatory to fill in another field (TC_USER_01)

However I do not get that appear the field 'TC_USER_01) after changing the status to Blocked

Can anyone help me to see what's wrong? I tried the below code in 'Test Lab module'

Sub TestSet_FieldChange(FieldName)
On Error Resume Next
If FieldName= "TC_STATUS" then
If TestSet_Fields("TC_STATUS").value="Blocked" then
TestSet_Fields("TS_USER_01").IsRequired=True
Else
TestSet_Fields("TS_USER_01").IsRequired=False

End If
Else
' Enter your code here.
End If
PrintError "TestSet_FieldChange"
On Error GoTo 0
End Sub

Can anyone tell me what is wrong in the above code?

 

Thanks in advance/Emilio

0 Likes
1 Solution

Accepted Solutions
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: User field required based on status of other field

Jump to solution

Always when debugging a script, make sure you comment the On Error Resume Next lines.

If you do that you will get an error that points to a typo you have in your code - "TestSetTests_Fields" should be "TestSetTest_Fields".

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
7 Replies
Highlighted
Absent Member.. Trudy Claspill Absent Member..
Absent Member..

Re: User field required based on status of other field

Jump to solution

I have two suggestions to help you self-solve this.

1. Comment out the "On Error" commands so that if there are any errors being raised they will be displayed to you.

2. Use the Msgbox command to pop up dialogs at various points in the code to ensure that the code is actually being executed.

[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]

(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)
0 Likes
emanriq
Visitor.

Re: User field required based on status of other field

Jump to solution

Hi Trudy, thanks for your answer

I am trying to find out how to work with 'on error' commands and 'Msgbox' because I just tunned the code from another thread based on that I am not a programer

Working on it I have one question. I am not sure either if the code has an error or just the code does not work as I expect. For the second scenario, will I be able to find out the error by 'on error' commands?

Thanks

 

0 Likes
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: User field required based on status of other field

Jump to solution

"TC_USER_01" is a field that belongs to the Test Instances (Test Set Tests) in Test Lab. So far so good. Note however that there is a typo in the code where it is referred to twice as "TS_USER_01", which is a field that belongs to a Test Plan Test.

The main problem is that you are trying to execute your code from TestSet_FieldChange, which is only relevant to fields on the Test Set level. So you need to move your code to TestSetTests_FieldChange. And the object references to "TestSet_Fields" need to be replaced with "TestSetTest_Fields".

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
0 Likes
emanriq
Visitor.

Re: User field required based on status of other field

Jump to solution

Thanks Jan.  I do understand your feedback but I do not get it works . Below the code I am working with:

 

Sub TestSetTests_FieldChange(FieldName)
On Error Resume Next
If FieldName="TC_STATUS" then
If TestSetTests_Fields("TC_STATUS").value="Blocked" then
TestSetTests_Fields("TC_USER_01").IsRequired=True
Else
TestSetTests_Fields("TC_USER_01").IsRequired=False

End If
Else
' Enter your code here.
End If
PrintError "TestSetTests_FieldChange"
On Error GoTo 0
End Sub

0 Likes
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: User field required based on status of other field

Jump to solution

Always when debugging a script, make sure you comment the On Error Resume Next lines.

If you do that you will get an error that points to a typo you have in your code - "TestSetTests_Fields" should be "TestSetTest_Fields".

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
emanriq
Visitor.

Re: User field required based on status of other field

Jump to solution

Hi again, moreover if I add 'MsgBox' as you can see below, I see the message 'Hola' when I change the status of any instance to any value... not only to Blocked...

 

Sub TestSetTests_FieldChange(FieldName)
On Error Resume Next
If FieldName="TC_STATUS" then
If TestSetTests_Fields("TC_STATUS").value="Blocked" then
MsgBox("Hola")
TestSetTests_Fields("TC_USER_01").IsRequired=True
Else
TestSetTests_Fields("TC_USER_01").IsRequired=False

End If
Else
' Enter your code here.
End If
PrintError "TestSetTests_FieldChange"
On Error GoTo 0
End Sub

0 Likes
emanriq
Visitor.

Re: User field required based on status of other field

Jump to solution

Thank You!

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.