Rollbase API Returns a Relationship ID even if the Related O

Posted by Rollbase User on 21-Oct-2011 04:52

I don't know if this is a bug, but the Rollbase API returns a Relationship ID for a related record even if the related record has been deleted. To replicate this issue: Object A has a related Object B with many to one relationship, on the field 'Relate' 1. Create 2 or more records in object A 2. Create a record in Object B 3. Attach records in A to B 4. Delete the record in B At this point, the records in A will show a blank 'Relate' field However, querying the record through the Rollbase API will still show a record ID for the records in object A (shows the ID for B). This renders the Select Query for blank (unrelated) records useless. Is this a bug, or a design feature? I need to select the records (through API) with no relationships, even if it was deleted. Thanks

All Replies

Posted by Admin on 23-Oct-2011 20:52

anyone?

Posted by Admin on 26-Oct-2011 12:46

What query strings have you used?



You can try these if you like:



var test = rbv_api.selectQuery("SELECT id,(integ_code for rel) FROM Object_A",1000);



you can then filter using javascript,



if (test[counter][1] == '' || String(test[counter][1]).length == 0 || test[counter][1] == '-1' || test[counter][1] == '0')

//where counter is the counter for your return array



or whichever handlers you'd like.



OR (alternative)



var test = rbv_api.selectQuery("SELECT id FROM Object_A WHERE (integ_code for rel) <> '' OR (integ_code for rel) <> '0' OR (integ_code for rel) <> '-1' ",1000);



In the case that it still returns a value, try searching the ID that you've received in Object B's filtered list, the record might still be there and not actually deleted.



If it's non-existent, then we should wait for Pavel's answer regarding this.



Thank you very much and hope this helps,

Piscoso Martin

Posted by Admin on 27-Oct-2011 02:29

Hi Martin,



Based on several tests we performed, the API returns the ID of the record it was previously linked to (which is now deleted). This is probably by design to accommodate the re-linking of the records in case the record in Object B gets restored.



However, the problem still persists; the API returns an ID for the deleted object, and it will not be viable to first Select the ID if it exists or not. Is there any other way to see if the relationship is indeed 'empty'?



Thanks for the reply, by the way.

Posted by Admin on 27-Oct-2011 02:32

This might be the cause of another bug we found with Rollbase:



http://gsfn.us/t/2gc9g

Posted by Admin on 27-Oct-2011 12:17

Hi Ran,



I've tried the scenario mentioned on one of our zones and it properly returned to me the ID from Object_A (i used my members object) where records from Object_B was deleted (I used my transactions object), here is my script syntax.



var x = rbv_api.selectQuery("SELECT id FROM member_obj WHERE lastName = 'Piscoso' AND R56632119 IS NULL",1000);

rbv_api.printArr(x);

//where R56632119 is the transactions where I deleted 3 records before running the test script.



It properly returned to me the id field of my record even if I deleted my related transactions



Cardinality: 1 member : many transactions.



Hope this helps,

Piscoso Martin

Rollbase PH

Posted by Admin on 27-Oct-2011 12:19

Additionally without filtering here are my results using:



var x = rbv_api.selectQuery("SELECT id FROM member_obj WHERE R56632119 IS NULL",1000);

rbv_api.printArr(x); //where R56632119 is the members transactions



Results:

{ { 56631911, }, { 56631936, }, { 56631968, }, { 56631970, }, { 56633634, }, { 56633666, }, { 56633668, }, { 56633693, }, { 56633708, }, { 56668021, }, { 56690402, }, { 57015994, }, { 58328655, }, { 60104182, }, { 60104214, }, { 60104224, }, { 60104230, }, { 60104236, }, { 61314022, }, }



This includes the id of the member record 'Martin Piscoso' related to my previous post.



Martin Piscoso's id = 56631911 (first item in the array).



Thanks and hope this helps

Piscoso Martin

Posted by Admin on 01-Nov-2011 20:23

Hi Martin,



Have you tried deleting records from Object A and then quering the relationship from Object B to Object A?



Basically, you'll just perform what you did except on the other way around; delete records in A, then query records in B. Relationship is One A to Many B. (The result set should just be a single record ID)



Like, SELECT R56632119 FROM parentObj



If we are experiencing the same problems, Object B's relationship field will still contain IDs from the deleted record A.



Thanks!

Posted by Admin on 26-Nov-2011 07:08

Hi! Any updates?

Posted by Admin on 27-Nov-2011 05:35

I'm doing test scripts now, just confirming the scenario, after deleting items from Obj A, you'd want to select records from Obj A again? (SELECT R56632119 FROM parentObj ) could you kindly give me your whole SOQL statement including your WHERE clause if applicable.



Re: >> SELECT R56632119 FROM parentObj - If we are experiencing the same problems, Object B's relationship field will still contain IDs from the deleted record A.



I think you'd be better off selecting records from Obj B where your relationship IS NULL. could you post your script so I can give you alternatives to your code?



Posted by Admin on 27-Nov-2011 05:42

Another question re:

If we are experiencing the same problems, Object B's relationship field will still contain IDs from the deleted record A. - Will it not have the same effect if you query the records will NULL relationships in Object B instead??? Kindly post your query so I can better understand your situation.hehe



Piscoso Martin

Rollbase PH

Posted by Admin on 27-Nov-2011 08:11

Hi Martin!



let's have an example scenario.



I have two objects: Subject and Student.

The relationship between them is One Room to many Students



I have Student Ran and Martin with a related Subject Chemistry



Querying the related Subject for both students will yield the ID for Chemistry



However, the record Chemistry was deleted from Subject



Querying the related Subject for both students will still yield the ID for Chemistry, even though the Subject was deleted.



My question is, how can I select Students with No Subjects, IF the query API returns an ID for Chemistry for students related to it, even if the record was actually deleted?



My query was a simple SELECT id FROM Students WHERE R1019201 IS NULL



That query will return No Results if we have performed the steps above

Posted by Admin on 27-Nov-2011 09:14

Wait a min, i'll be posting my screens to show you what I understood re the situation. It's pretty straightforward. Just clearing out the confusion (on my side) ^_^

Posted by Admin on 27-Nov-2011 09:48

Hi Ran,

I tested using your scenario and here is what I came up with.



Obj A - Purchase Order

Obj B - Line Item



Screens explaining the code below:

1: Querying Line items without Purchase Orders.







2 and 3. Recreating the scenario.

Creating a Purchase Order with a line item and deleting the parent Purchase Order.











4. Trigger handler just to ensure the cleanliness of records (optional)

I just added this one just in-case you still run into

Posted by Admin on 27-Nov-2011 10:34

btw, #4 is coming from the Parent, Purchase Order and updates it's related Line Items after deletion.

Posted by Admin on 10-Jan-2012 20:12

Any updates on this issue?

Posted by Admin on 10-Jan-2012 22:48

Pavel is working on it - http://getsatisfaction.com/rollbase/topics/filtering_not_working_properly - related post

Posted by Admin on 10-Jan-2012 23:24

ok thanks :)

Posted by Admin on 11-Jan-2012 20:40

This will be finally resolved in the next release

Posted by Admin on 11-Jan-2012 21:24

Yes! ^_^ Thanks for the VERY Hard Work @Pavel!

Posted by Admin on 11-Jan-2012 22:02

This will be finally addressed in the next release.

This thread is closed