是否可以在 FileMaker 中将字段(而不是其内容)存储为变量?

Is it possible to store a field (not its contents) as a variable in FileMaker?

提问人:NewBoard 提问时间:10/24/2023 最后编辑:NewBoard 更新时间:10/24/2023 访问量:37

问:

我开始清理FileMaker数据库中的一些旧代码。有人有以下脚本,允许用户将文件上传到容器字段。该脚本根据脚本参数确定要在哪个字段中存储文件。

Set Error Capture [On]
Allow User Abort [Off]

Set Variable [$ScriptParameter; Value: Get (ScriptParameter)]

If [$ScriptParameter = "Clean"]
    Insert File [Insert; Display content; Never compress; Target:Inspections::cert_Clean]
Else If [$ScriptParameter = "C of C"]
    Insert File [Insert; Display content; Never compress; Target:Inspections::cert_C of C]
Else If [$ScriptParameter = "Hardness"]
    Insert File [Insert; Display content; Never compress; Target:Inspections::cert_Hardness]
...
.
.
End If

它或多或少是一个查找表。我想从查找表中提取实际函数,然后只使用存储目标字段的变量。然后让 get its Target from the variable.是否可以使用 ?Insert FileInsert FileSet Variable

变量赋值 FileMaker 查找表

评论


答:

2赞 michael.hor257k 10/24/2023 #1

脚本参数始终是一个,而不是字段引用

另一件事是脚本步骤允许您动态指定目标字段;您必须将目标字段“烘焙”到步骤中。Insert File

但是,您可以做的是先将文件插入到变量中,然后使用脚本步骤将插入的文件放置在由脚本参数确定的目标字段中。但是,您需要将目标字段的名称(作为文本)作为脚本参数传递 - 例如,使参数:Set Field By Name

GetFieldName ( Target:Inspections::cert_Clean )

对于第一个字段,依此类推。然后,您的脚本可以简单地执行以下操作:

Insert File [ $insertedFile ]
Set Field By Name [ Get ( ScriptParameter ); $insertedFile ]

P.S. 这一步:

Set Variable [$ScriptParameter; Value: Get (ScriptParameter)]

除了浪费 CPU 周期和内存外,不会完成任何事情。脚本参数本身已经是一个变量;您可以直接参考它。

评论

0赞 NewBoard 10/24/2023
好的,谢谢,我很感激你的帮助。谢谢你的提示!Set Variable