Skip to main content

Allow an Administrator to Create Custom Persistent Fields in an XPO-Based Application

  • 4 minutes to read

You can allow an application administrator to create custom persistent fields and display the added fields’ data in the UI without recompiling the application. In this example, the SkypeID field will be added to the Contact business object in the MainDemo application.

CustomPersistentFields_Result

Prerequisites

Ensure that your application does not contradict the following conditions. Otherwise, creating new persistent fields is impossible at runtime.

Setup the Application

Apply the following changes in the application code to allow application administrators to create and display custom persistent field data in the UI.

Implement the Persistent Field and Display It

Follow the steps below to add a custom persistent field at an end-user workstation.

  1. Invoke the built-in Model Editor using the Tools | Edit Model command at runtime or close the application and start the standalone Model Editor by running the DevExpress.ExpressApp.ModelEditor.v25.2.exe executable file.

    If you use the standalone Model Editor, specify the path to the application configuration file (MainDemo.Win.exe.config for Windows or MySolution.Blazor.Server.dll for Blazor) and click Open in the Open Model dialog.

    CustomPersistentFields_RunME

  2. Navigate to the BO_Model | Contact node in the tree on the left. Right-click the OwnMembers child node and choose Add… | Member.

    CustomPersistentFields_AddMember

  3. Set the Name property of the newly added node to “SkypeID”. Then, set the IsCalculated property to “False”, Type to “System.String”, Size to “32”, and Caption to “Skype ID”.

    CustomPersistentFields_MemberProperties

  4. Copy the differences that you have introduced in the administrator’s layer using the Merge Differences command.

    CustomPersistentFields_Merge

  5. Save changes using the Save button or the CTRL+S shortcut and restart the Model Editor.
  6. Navigate to the Views | Contact_DetailView node in the tree on the left. Right-click the Items child node and choose Add… | PropertyEditor.

    CustomPersistentFields_AddEditor1

  7. Set PropertyName and Id to “SkypeID”.

    CustomPersistentFields_AddEditor2

  8. Focus the Layout node. Right-click the empty space within the form preview displayed on the right and select Customize Layout.

    CustomPersistentFields_AddEditor3

  9. Drag the Skype ID item from the invoked Customization window to an appropriate position within the form.

    CustomPersistentFields_AddEditor4

    You can also add the Skype ID column to the Contact List View using a similar approach (see List View Columns Customization).

  10. Merge the differences as described at the forth step.
  11. Save the changes and close the Model Editor.
  12. Update your database schema as described in the Apply Changes to the Database section.
  13. Restart the application and open the Contact Detail View to see the result demonstrated in the introduction of this topic.

Important

If the application is installed on multiple PCs and the Administrator’s Model Differences are stored in the Model.xafml file, copy it from the application’s working folder to each PC. Otherwise, the created field is available only on the workstation where you added it.

Access a Custom Persistent Field in Code

To access custom persistent fields in code, use the solution from the following topic: Access a Custom Field in Code

Apply Changes to the Database

Launch a command line interpreter, for instance, Command Prompt, and run your application with the -updateDatabase command.

C:\Users\Public\MyApplication\MySolution.Blazor.Server.exe -updateDatabase -silent -forceUpdate

For additional information, refer to the following topic: Production Database and Application Updates