"ReferenceError: Error #1056: Cannot create property ___class on ..." when running IDataStore.first

Hi,
I trying to get going with backendless and the Flex API.
I’m getting this Error:
ReferenceError: Error #1056: Cannot create property ___class on valueObjects.Contact
when running IDataStore.first method.

I have to entities related to each other: Phonebook and Contact.
When running the save_ButtonClickHandler I’m getting the above mentioned error.


 protected var phonBook:Phonebook;
        
        private function button1_clickHandler(event:MouseEvent):void {
            phonBook = createPhonebook();
            clientDataGrid.dataProvider = new ArrayCollection(phonBook.contacts);
        }
        protected function createPhonebook():Phonebook {
            var phBook:Phonebook = new Phonebook();
            phBook.owner = new Contact();
            phBook.owner.firstname = "Arne";
            phBook.owner.lastname = "Brödel";
            phBook.owner.birthdate = new Date(1985, 6, 23);
            phBook.contacts = [phBook.owner];
            return phBook;
        }

        

        private function saveButton_clickHandler(event:MouseEvent):void {

            var phBookDataStore:IDataStore = Backendless.PersistenceService.of(Phonebook);
            phBookDataStore.save(phonBook, new mx.rpc.Responder(phoneBookSaveResultHandler, phoneBookSaveFaultHandler));
            phBookDataStore.first(new mx.rpc.Responder(phoneBookFirstResult, phoneBookFirstFault));

        }

Phonebook

package valueObjects {
[Bindable]
[RemoteClass(alias="valueObjects.Phonebook")]
public class Phonebook extends Persistable{
    public var owner:Contact;
    [ArrayElementType("valueObjects.Contact")]
    public var contacts:Array;
    public function Phonebook() {
    }
}
}

Contact

package valueObjects {

[Bindable]
[RemoteClass(alias="valueObjects.Contact")]
public class Contact extends Persistable{
    public var firstname:String;
    public var lastname:String;
    public var birthdate:Date;

    public function Contact() 
    {
    }

Persistable

package valueObjects {
import com.backendless.data.IBackendlessEntity;

public class Persistable implements IBackendlessEntity{
    public function get objectId():String {
        return _objectId;
    }

    public function set objectId(value:String):void {
        _objectId = value;
    }

    public function get created():Date {
        return _created;
    }

    public function set created(value:Date):void {
        _created = value;
    }

    public function get updated():Date {
        return _updated;
    }

    public function set updated(value:Date):void {
        _updated = value;
    }

    protected var _objectId:String;
    protected var _created:Date;
    protected var _updated:Date;
    public function Persistable() {
    }

Do those questions have a max length? Or is there an extend button somewhere? I am not able to see the whole text that I posted. When I click on edit I can see the whole text in the editor

Phonebook

package valueObjects {
[Bindable]
(RemoteClass(alias="valueObjects.Phonebook"))
public class Phonebook extends Persistable{
public var owner:Contact;
[ArrayElementType("valueObjects.Contact")]
public var contacts:Array;
public function Phonebook() {
}
}
}

Contact

package valueObjects {

[Bindable]
(RemoteClass(alias="valueObjects.Contact"))
public class Contact extends Persistable{
public var firstname:String;
public var lastname:String;
public var birthdate:Date;

public function Contact()
{
}

Persistable

package valueObjects {
import com.backendless.data.IBackendlessEntity;

public class Persistable implements IBackendlessEntity{
public function get objectId():String {
return _objectId;
}

public function set objectId(value:String):void {
_objectId = value;
}

public function get created():Date {
return _created;
}

public function set created(value:Date):void {
_created = value;
}

public function get updated():Date {
return _updated;
}

public function set updated(value:Date):void {
_updated = value;
}

protected var _objectId:String;
protected var _created:Date;
protected var _updated:Date;
public function Persistable() {
}

Hi Arne,

All related classes must declare the “___class” field which should contain the name of the table/class. In your case, you can declare the following field in the Contact class:

public var ___class:String = "Contact";

We just made a change in the SDK to add that field dynamically (if the class is declared as ‘dynamic’). We will upload the SDK to the site shortly, but meanwhile simply declare the field and it should work.

Regards,
Mark