发新话题
打印

[TechNote] Is it possible to copy values from one field into another field?( 此文章被查看:1771次,被回复:2篇!! )

Is it possible to copy values from one field into another field?

Problem
Is it possible to copy values from one field into another field?
Solution
QUESTION: Is it possible to copy values from one field into another field?

ANSWER:
Yes. This example shows how to copy values of a multiline_string field (Field A) into a short_string field (Field B) so that it can be displayed in a query.

The following steps outline the procedure in detail:

- Make backups of all databases, including the master schema repository (so they are all in synch with each other).

- Make a new field, field B (or any name of your choice), of type short_string with 254 characters. You can make the field of any length. In this example, I am making it 254 so that I have a large enough field to bring over values from a multiline_sting field.
** Make sure that the length of your field is large enough to accommodate the values being brought over. If you have a multiline_string field with a large amount of data, all of the data will not be able to be brought over. You will get an error message saying that field B has invalid values because the limit is 254 characters.

- Put this new field, field B, on the form.

- Add this script in the Initialization column of the Modify action (in defect record type)....

Dim newbie
newbie = GetFieldValue("A").GetValue
SetFieldValue "B", newbie

** This will create a temp variable called newbie. It will get the value of the original field, A, and put it in the new field, B.

- Test this in a test database before doing it in the production database!

- Run a query to grab all of the defects.

- Up in the query result set, hold down the control button and select all defects. Now they all show up highlighted in black.

- Do a mass modify. With all records selected, go to the first record and do Actions > Modify.

- A dialog box titled "Multiple Record Update" will pop up. The first question asks if the changes made to the first record are to be applied to all. Say yes. If you do not want this change to affect all of the defects, you should create a query of only the desired records. The second question asks if you want to see each record before committing the changes. Answer this accordingly and then hit OK.

- Now you will see the records being changed. There isn't a need to change anything else in the records. Only do Actions > Modify (because the hook to change it is on the initialization of the modify action).

- Once it goes through ALL of the records, hit apply.

- View each record and to see that the values in field A are now brought over to the new field, field B.

- Now, do the above to the production database.
** It is good to run through it once first in the test database to be familiar with the procedure and see how it works.

- After making the changes to the production database, you can now delete the original field, field A, off the form. Now, none of the users will see the old field. It can remain in the fields grid of Designer if you want.

- After making all of these changes, you can remove the hook because records submitted from now on will not have the original field on the form for users to put data into. They will now use the new field.



© 本文为 懂你SCMLife 共同所有,未经同意,请勿转载 ©如该文侵犯了您的版权,请联系管理员
优惠购买Rational,Telelogic,Hansky产品,企业VIP服务、实施
VIP服务电话:13581809377

TOP

这是我翻译的 有异议尽管提,然后我来改
"忠于原文 适当发挥"

问题

可能向一个field里复制另一个filed的值吗?

解决

提问:可能向一个field里复制另一个filed的值吗?

回答:可以的。下面的例子说明了怎样复制值为multiline_string类型的字段A的值到值类型为short_string 的字段B中去,而后在查询中显示出来。

下面步骤详细说明了过程:

-备份所有数据库,包括master schema

-创建一个新字段,字段B,类型为short_string with 254 characters。可以赋予字段任何长度。在这个例子中,我给它赋254的长度,从而有足够的长度容纳从multiline_sting来的值。
**
确保有足够的长度来容纳过来的值。如果你有个非常大的数据的multiline_string的字段,那么所有的数据将不能被完全brought over。你将会看到一个错误信息说明字段B有个非法的值因为长度限制在254个字符。

-将新字段B放置到表单上。

-向初始化列中添加下段代码来修改行为

Dim newbie
newbie = GetFieldValue("A").GetValue
SetFieldValue "B", newbie

**这便会创建一个叫newbie的临时变量。它会将原始字段A的值赋予到字段B中。
-在操作production库前请在test库中做下测试!
-运行查询所有缺陷的查询
-在结果集的最上端,点住control button来全选缺陷,可以看到全部突出显示为
黑色。
-简单修改。在全部缺陷中,找到第一条记录,然后点击Actions > Modify
-会弹出一个标题为“Multiple Record Update”的对话框。第一个问题是问:是否要对所有的记录做像第一个似的改动?是的。如果你不想向所有的记录做改动的话,你需要新建一个你所期望的查询。第二个问题是问:是否想在提交变更前察看每个记录?回答这个问题然后点击OK。
-那么现在你就可以看到改变后的记录了。没有必要再修改记录中的其他地方了。只要做Actions > Modify(因为hook可以改变修改行为的初始值)
-一旦需要应用到所有记录中去,点击applay。
-查看每条记录,字段A的值现在被brought over到新字段B中了。
-现在,在production做上门的操作。
**最好是在test库中运行下,一边熟悉整个过程并且了解它是怎样工作的。
-在对production库做了改动之后,你便可以从表单中将原始的字段A删除掉了。现在,没有任何一个用户可以看到旧的字段了。如果你想得话,它可以在Designer的fields grid保留着。
-在做完所有操作后,你便可以移除hook了,因为从现在开始所有用户在表单上提交的数据不会使用到原始的字段了。他们将会用到新的字段。


本帖最近评分记录
  • 懂你 金钱 +20 工作到家,向你学习! 2006-10-18 11:50



© 本文为 刘刘SCMLife 共同所有,未经同意,请勿转载 ©如该文侵犯了您的版权,请联系管理员
i am on my way ....

TOP

刘刘 工作做的很到家,俺刚贴上来一篇文章就给翻译了,加20分予以鼓励!

鼓励大家都能将那些英文文章翻译过来!



© 本文为 懂你SCMLife 共同所有,未经同意,请勿转载 ©如该文侵犯了您的版权,请联系管理员
优惠购买Rational,Telelogic,Hansky产品,企业VIP服务、实施
VIP服务电话:13581809377

TOP

发新话题