New Ranks & Badges For The Community!
Notice something different? The ranks and associated badges have gone "Star Fleet". See what they all mean HERE
Highlighted
Lieutenant Lieutenant
Lieutenant
610 views

ALM12 Workflow - Count attachments of a new requirement

Hi,

 

I am attempting to write workflow code to require a user to attach at least one file to a new requirement.  Unfortunately, it appears that the attachment/s are not saved until after the Req_AfterPost sub has finished.

 

The following sub returns the correct number for existing Requirements, but returns 0 for new ones with attachments. The same code cannot be used in Req_CanPost for new requrements, as at that stage, the requirement does not have any id.

 

Sub Template_Req_AfterPost

  Dim ReqID, Requirement, AttList
  ReqID= Req_Fields("RQ_REQ_ID").value
  Set Requirement = TDConnection.ReqFactory.Item(ReqID)
  Set AttList = Requirement.Attachments.NewList("")

  Msgbox AttList.Count,,"Attachment Count"

End Sub

 

Is there any way to check whether there are any attachments before the requirement record is saved?

 

We are using ALM 12.01

0 Likes
2 Replies
Highlighted
Fleet Admiral
Fleet Admiral

Unfortunately, the attachment reference for new items is not added to the database until after the AfterPost event occurs. It is the same in the other modules, unless it  has changed recently.

 

You can't even rely on the Attachment_New event, since it is not triggered for new requirements, only for existing ones. I would call that a bug.

Jan Czajkowski

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

The closest I have been able to get to solving this is to track whether the user has pressed the attach button.

 

Function Template_ActionCanExecute(ActionName)is called when the file is attached to a new requirement, with the value "NewReqAttachment.AttachFile". I have not been able to find a way for the code to determine whether the user attached a file (as opposed to pressing the cancel button in the attach dialog).

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.