Causes of errors in generated models

Although a model can be generated successfully for a DataWindow, the model may not work correctly in the following cases:

  • If a DataWindow has used expression in its computed field, the GetItem function of the model generated from the DataWindow sometimes may not work well.

  • If the SELECT statement in the DataWindow SQL refers to a computed column with an empty string and no alias, the parser will use a default name for the column. The generated model may fail to work because the column in the model cannot be mapped back to the DataWindow column by name.

  • If the columns returned by the DataWindow SQL are more than the columns defined in the DataWindow painter, the generated model may fail to work because the column in the model cannot be mapped back to the DataWindow column by name.

  • If a DataWindow column has default value that contains double quotes, you must add escape character (\) in the double quotes in the generated model, to make sure the default value can be interpreted correctly at runtime.

  • If the DataWindow SRD contains some parameters in the UI or Group By section, the model generated from the DataWindow may fail to create the datastore.

  • Contains some parameters that will display in the UI

  • If a DataWindow contains expression which calls a global function, the global function won’t work well in the generated model.

    This issue can be resolved by the following workaround steps:

    1. Create a static function in the class file that provides the same functionality as the global function;

      For example, using the following script to create the static function:

      public class MyGlobalFunc 
          { 
            public static Int32 gf_getid2(Int32 id) 
              { 
                return id;
               } 
          }
      
    2. Register the function by calling PbExpressionFactory.Current.AddGlobalFunc<MyGlobalfunc>(), where MyGlobalfunc is the class that the newly created static function belongs to and it should not be a static class.

      For example, registering the function in Startup.cs:

      public void ConfigureServices(IServiceCollection services) 
          { 
      
            //Register the function for use by the DataWindow expression
            PbExpressionFactory.Current.AddGlobalFunc<MyGlobalFunc>();
      
            ...
           }