ClearQuest表单上的非数据库字段
时间:2020-03-06 14:58:26 来源:igfitidea点击:
有没有一种方法可以使用与数据库字段不对应的表单字段进行临时处理?
IE。我要添加:
- 临时字段item1,item2
- 数据库字段总和
- 带有记录钩子的按钮,用于设置sum = item1 + item2
解决方案
据我所知,ClearQuest根本不可能。
我已经尝试做类似的事情,并且我们的IBM顾问告诉我,唯一的方法是为所有变量创建一个DB字段。
我们不能将数据添加到表单字段上,而实际上这些字段是基础数据的表示形式,而不是脚本直接与之交互的内容。
听起来不太可能将临时数据添加到基础记录(实体)本身。也许有可能滥用perl API并将数据动态添加到实体对象上,但是我个人不会尝试,我们可能会在CQ突发奇想之后丢失数据;-)
但是,这并不意味着不可能有临时数据。
在我看来,最好的方法是使用会话对象,该对象专门用于此目的。
从帮助文件中:
IBM Rational ClearQuest supports the use of sessionwide variables for storing information. After you create sessionwide variables, you can access them through the current Session object using functions or subroutines, including hooks, that have access to the Session object. When the current session ends, all of the variables associated with that Session object are deleted. The session ends when the user logs out or the final reference to the Session object ceases to exist.
在文件:/// C:/Program%20Files/Rational/ClearQuest/doc/help/cq_api/c_session_vars.htm中有一些有关此主题的有用文档(当然,假定在Windows计算机上是默认安装)。
将其中的代码示例转换为我们想要的代码,首先将计算出的数据存储在会话对象内部:
$session->SetNameValue("item1", $value1); $session->SetNameValue("item2", $value2);
然后在计算挂钩中,检索存储的值并按如下所示设置该合计字段的值:
my $item1 = GetNameValue("item1"); my $item2 = GetNameValue("item2"); my $sum = $item1 + $item2; $entity->SetFieldValue("some_totals_record", $sum);
当然要调整口味;-)