Support Topics Documentation Slack YouTube Blog

Relations Master 4/5 "Retrieve related data with API

Mission: Relations Master 4/5
Task: “Retrieve related data with API”

In SWIFT, the program works and seems to do the job, but it does not pass the test. Where is the problem please ?

var myTable = “Person”

@IBAction func pushButtonFindItemInCity(_ sender: Any) {
    let dataStore = Backendless.shared.data.ofTable(myTable)

    let queryBuilder = DataQueryBuilder()
    queryBuilder.setRelated(related: ["cityOfResidence", "cityOfResidence.City"])

    dataStore.findById(objectId: self.myObject["objectId"] as! String, queryBuilder: queryBuilder, responseHandler: { foundObjects in

        print("Found \(foundObjects.count) objects: \(foundObjects)")
    }, errorHandler: { fault in
        print("Error: \(fault.message ?? "")")
    })
}

Hi Sylvain,

Welcome to the Backendless community.

To get the task recognized, I recommend modifying the code so it is as close as possible to the logic demonstrated in the task’s instructions. You will see that the example in the instructions uses a where clause to identify the parent object. Also, the relation is only cityOfResidence (while your code puts two relations in there).

Hope this helps.

Regards,
Mark

Hi @mark-piller I too completed this task using codeless and am getting the response as required. However, the task is not getting recognised.

Anything specific that I need to take care of?

Thanks,
Varun

Could you please show the logic for establishing a relationship? Post a screenshot please.

Sure. Please see below:

Looks good. Try reloading Backendless Console and see if the task is counted.

There is a little overkill with tracking accuracy from our side. Remove spaces in where clase - name=' (not name = '), this should do the trick

Reloaded the console as well as removed white spaces but still the same issue.

What name do you type in to retrieve data?

Can you please make this call once again? I want to catch in the logs whats happening

I just hit the call right now @ 7:32 pm IST.

@mark-piller I used the name ‘Dang’

Once again please?

Done once again @ 7:38 pm IST

Thank you! What if you change page size to different than 1? E.g. 2 or more (does not matter)

I don’t follow. What do you mean by increase page size?

This worked. Although I don’t understand why it would work.