Brick River | Update to default values

Update to default values

12/10/2019

Default values can now be provided from the currently logged in User's record.

Example 1, using the current user's email address as a default value.

The DefaultFrom attribute can provide a default value from the current User. Here we're using the User's email as the default for a news article's contact email.
<View Id="News" TableId="Content">
  <Fields>
    <FieldSet Id="ContactFields">
      <Column Id="Email" DefaultFrom="User.Email"/>
    </FieldSet>
  </Fields>
</View>

Example 2, setting the author of an article based on the current user.

You can add custom fields, including relationships, to the Users table. So we first create a Relationship between Users and Authors
 
<View Id="All" TableId="Users">
  <Fields>
    <Relationship Id="DefaultAuthor" Name="Default Author" TableId="Contacts" ViewId="Authors" Multiple="false" Cmd="After:MemberOf" />
  </Fields>
</View>

Then on News we can set the Author based on the current user. Be sure to make the field Invisible, and also allow update by setting ReadOnlyOnAdd to false.
<View Id="News" TableId="Content">
  <Fields>
    <FieldSet Id="ArticleFields">
      <Relationship Id="Authors" DefaultFrom="User.DefaultAuthor" Invisible="true" ReadOnlyOnAdd="false" />
    </FieldSet>
  </Fields>
</View>