Change default value for field

I want to create an action button that takes a value from a selected document; open a new form of another view; then set one of the fields to the selected field’s value. Below are the codes I’ve tried.

@Command([Compose];“Create Product Relationship”);

FIELD pr_fromproduct := pr_fromproduct;

@Set(pr_fromproduct; prodname);

@Command([Compose];“Create Product Relationship”);

FIELD pr_fromproduct := prodname;

@Command([Compose];“Create Product Relationship”);

FIELD pr_fromproduct := pr_fromproduct;

@SetField(pr_fromproduct; prodname);

The first two give no responce. The last one gives an error that states: “Field name requires a value”. Does anyone know a solution to this?

*FYI

pr_fromproduct = field from created form

prodname = selected document field

Subject: Change default value for field

You can only set fields on a new document to the value of a field on the existing document this way if the form has the property “Formulas inherit values from selected document” checked (in the form properties box, Defaults tab.)

If you don’t want to use that property, you could have the button first set an environment variable with the value to be used, then compose the new form. The default value formula of the field on the new document would be set to grab the environment var.

So, something like this:

@SetEnvironment(“prodName”; fieldNameThatContainsTheValue);

@Command([Compose]; “Create Product Relationship”);

Then the formula for the field on your newly-composed document would be:

@Environment(“prodName”)

You’d then want to make sure you cleared out the value of the prodName variable when the new document is closed so that it doesn’t affect subsequent documents.

Subject: Change default value for field

Well, the really easy and logical way to do it is with inheritance, as Esther mentioned: You’d set the “target” form’s “on create: fields inherit values from selected document” property, and then simply use

prodname

as the formula in pr_fromproduct.


If you really wanted to do it in formula language from the “source” form, however, you could use

@Command([Compose];“Create Product Relationship”);

prod := prodname;

@updateformulacontext;

field pr_fromproduct := prod;

“”

Subject: RE: Change default value for field

Ooh, that’s one of the new 6.x formlae I haven’t had a chance to try yet! That could be a big help in a lot of places…thanks for mentioning it.