Referencing parent field on document creation

2019-07-29 00:16发布

I have a form called ProductFamily. It has a field called ProductFamilyMBValues which is a list of strings.

I've got a response document using a form called Item, which is always a response of a document using the above form.

The Item form has a dialoglist field ItemMakeBuy that has the validation formula @If(@Length(ItemMakeBuy) = 0;@Failure("You must choose a Make or Buy value");@Success)

The choices for that field is a formula: @IfError(@GetDocField($ref;"ProductFamilyMBValues");"?").

My problem is that when i create a new Item document the choices for the ItemMakeBuy field aren't populated, seemingly because until the document is saved the $ref field isn't populated. However, i can't save it because of my validation formula, requiring a value to be entered.

How can i get around this issue? Ideally i want to keep the validation formula for the field.

3条回答
Ridiculous、
2楼-- · 2019-07-29 00:37

When creating the response, do you copy any other fields from the parent? If you copy the UniversalID to the response you can use that until the document is saved. If combined with a @IsNewDoc in the formula, the moment the document is saved it can point to the $REF.

Or something like this: @IfError(@GetDocField($ref;"ProductFamilyMBValues");@GetDocField(ParentUNIDField;"ProductFamilyMBValues"))

查看更多
劫难
3楼-- · 2019-07-29 00:37

That is a logical way to reference the parent document, but Notes has an alternate way to get at parent field information. In your Item form, go to the form properties and select the option "on create: formulas inherit values from selected document". Then you can create any number of fields in the Item form and use a computed field formula referencing the field name from the ProductFamily form, and those values will get passed in. In your case, you could just pass the ProductFamilyMBValues field to the response doc.

Here is more information on that subject from the docs.

查看更多
女痞
4楼-- · 2019-07-29 00:44

You can use the function @InheritedDocumentUniqueID to get the parent doc id when creating a new doc.

In your case the formula for the choices would be : @IfError(@GetDocField(@InheritedDocumentUniqueID;"ProductFamilyMBValues");"?")

查看更多
登录 后发表回答