views:

224

answers:

2

Is there a way to use form fields that does not correspond to database field for temporary processings?

I.e. I want to add:

  • temp fields item1, item2
  • database field sum
  • button with record hook that sets sum = item1 + item2
+2  A: 

As far as I know it's simply not possible with ClearQuest. I've tried to do something similar and was told by our IBM consultant that the only way is to create a DB field for all variables.

Kristof Provost
+2  A: 

You can't attach data to form fields really - those are representations of the underlying data, not something scripts interact with directly.

Adding temporary data to the underlying record (entity) itself sounds unlikely as well. Perhaps it's possible to abuse the perl API and dynamically attach data to entity objects but I personally wouldn't try it, you're liable to lose your data at the whim of CQ then ;-)

That does not however mean it's impossible to have temporary data. The best way seems to me to be using the session object, which is explicitly intended for that purpose.

From the helpfile:

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.

There's some helpful documentation on this subject in file:///C:/Program%20Files/Rational/ClearQuest/doc/help/cq_api/c_session_vars.htm (Presuming a default installation on a windows machine, of course.)

Translating the code example in there into what you seem to be wanting, first you store the data you have calculated inside the session object:

$session->SetNameValue("item1", $value1);
$session->SetNameValue("item2", $value2);

Then in your calculation hook you retrieve the stored values and set the value of that totals field like this:

my $item1 = GetNameValue("item1");
my $item2 = GetNameValue("item2");
my $sum = $item1 + $item2;

$entity->SetFieldValue("some_totals_record", $sum);

Adjust to taste of course ;-)

Randakar