Error WebClientdataset

Hello

Please try this code:

unit Unit1;

interface

uses
System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, Data.DB, WEBLib.CDS;

type
TForm1 = class(TWebForm)
cd: TWebClientDataSet;
cdcad: TStringField;
procedure WebFormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WebFormCreate(Sender: TObject);
begin
cd.active:=true;
cd.Append;
cd.FieldByName('cad').AsString:='hola';
cd.Post;
end;

end.

object Form1: TForm1
Left = 0
Top = 0
Width = 640
Height = 480
Caption = 'we'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Arial'
Font.Style = []
TabOrder = 1
OnCreate = WebFormCreate
object cd: TWebClientDataSet
Params = <>
Left = 250
Top = 146
object cdcad: TStringField
FieldName = 'cad'
Size = 50
end
end
end

I'm using WebCore 1.4.2.0.

When I run the application I get this error message

ERROR
No fields found | fMessage::No fields found fHelpContext::0 FJSError::Error: No fields found
at http://localhost:8000/Project1/Project1.js [304:11]

I need help to resolve it.

Thanks

Hello

After working a good time, I think I found a solution that fixes the error.
I don't want to go back to the 1.3.8 version.

So, if I put next code in the oncreate event, the application run ok.

procedure TForm1.WebFormCreate(Sender: TObject);
var
  i:integer;
  Field:TField;
begin
   for I := 0 to Self.ComponentCount-1 do
      begin
        if Components[i] is TField then
            begin
                Field:=TField(Components[i]);
                {if Field.DataSet.FieldDefs.Find(Field.FieldName)=nil then} //// this row gives an error
                
				Field.DataSet.FieldDefs.Add(Field.FieldName,Field.DataType,Field.Size,Field.Required);

//                MessageDlg(Field.FieldName,mtInformation,[mbok]); //// this row gives an error
            end;
      end;
	  
	cd.active:=true;
	cd.Append;
	cd.FieldByName('cad').AsString:='hola';
	cd.Post;	  
	  
	  
end;

I'm sure you will find a better solution, but with that I can run the application and go on with anothers projects

I had the same problem. Your Solution worked. Thanks

Hello,

I've just installed the new 1.5 webcore version and unfortunately I have seen that this error still persists.

Please, take a look at the example and if I'm doing something wrong let me know.

Is very simple, I can't use persistent fields created at design time and sometimes if I use the routine (it's above) in the oncreate event, sometimes -not all the time- it works.

The code updated is:

for I := 0 to Self.ComponentCount-1 do
      begin
        if Components[i] is TField then
            begin
                Field:=TField(Components[i]);
//                Field.DataSet.FieldDefs.Add(Field.FieldName,Field.DataType,Field.Size,Field.Required);
                      try
                        Field.DataSet.FieldDefs.Add(Field.FieldName,Field.DataType,Field.Size,Field.Required);
                      except

                      end;
            end;
      end;

Now I use "Try-except" because, sometimes, in descendents forms, some fields are created and an error occurs.

A sample source project with which we can reproduce this would help.
It is unclear in what circumstances there is an issue.
When we add in our demo Demo\Basics\Dataset for example persistent fields at design-time, this works fine. What do you want to do different?

Hello, thanks Bruno for answering.

I sent a mail to info@tmssoftware.com with project file and a video where you'll see the error

Thanks for providing these extra details. This enabled us to trace & solve this issue.
The next update will address this.