Backendless Support
 
Waiting for user's response

Recursive function call in codeless?

Hi all,

is it possible to call a function in codeless in itself? So call it recursive? I wand to process objects in objects in objects...

I tried to test this, but when I call my function inside the function, the execution breaks up, due to a longer processing time than 5s. Also when I do nothing and return immediately the second time when the function is called.

Best regards

Leave a Comment

Comments (6)

photo
1

Hi Jonas

Yes, it's possible

Could you provide your App ID, or provide screenshot of your logic, it help me to investigate why it does not work

Regards, Vlad

photo
1

Hi Vladimir,

the AppID is: 63087FF7-7E1D-973D-FF3B-D5F0740FA100. The function name is: FilterObjectProperties.

Thanks for having a look.

photo
1

I've looked at your logic and find nothing that should not works.

may be the problem is with input parameters.

could you provide the input parameters, it may be no real data but should have the same data model as a real data. for ex: [{a:'a', b:'b', c:{ d: 'd' } }] and props => ['a', 'b', { ... } ]

and also what you would like to have as result.

photo
1

My data/objects in the array (parameter "Object") looks like below. They come directly out of the Load table objects block.

After the FilterObjectProperties function I want some properties of the objects in the array and the subobjects (User) to be removed.

  1. [

    {

    "a":"sss",

    "b":"sss",

    "User":

    {

    "ID":"sss",

    "created":nnn,

    "name":"sss",

    "ownerId":"sss",

    "updated":nnn,

    "objectId":"sss",

    "email":"sss",

    },

    "c":nnn,

    "d":nnn,

    "e":nnn,

    "f":"sss",

    },

    {

    ....

    },

    ....

    ]

  1. Properties:
  2. [
  3. 'a',
  4. 'b',
  5. 'c',
  6. {
  7. "Name": "User",
  8. "Items": [
  9. 'ID',
  10. 'name'
  11. ]
  12. }
  13. ]

photo
1

currently your function "FilterObjectProperties" returns a list, is it ok?

because if you want just remove some fields the function should not transform Object to List, but it's not a problem

I've run the code locally and everything works

  1. const sourceList = [
  2. {
  3. "a" : "sss",
  4. "b" : "sss",
  5. "User": {
  6. "ID" : "sss",
  7. "created" : 11,
  8. "name" : "sss",
  9. "ownerId" : "sss",
  10. "updated" : 22,
  11. "objectId": "sss",
  12. "email" : "sss",
  13. },
  14. "c" : 11,
  15. "d" : 222,
  16. "e" : 333,
  17. "f" : "sss",
  18. },
  19. {
  20. "a" : "sss",
  21. "b" : "sss",
  22. "User": {
  23. "ID" : "sss",
  24. "created" : 11,
  25. "name" : "sss",
  26. "ownerId" : "sss",
  27. "updated" : 22,
  28. "objectId": "sss",
  29. "email" : "sss",
  30. },
  31. "c" : 11,
  32. "d" : 222,
  33. "e" : 333,
  34. "f" : "sss",
  35. }
  36. ]
  37. const props = ['a', 'b', 'c', { "Name": "User", "Items": ['ID', 'name'] }]
  38. console.log('FilterObjectProperties result', FilterObjectProperties(sourceList, props))

result:

  1. [
  2. {"a":"sss","b":"sss","c":11,"User":[ {"ID":"sss","name":"sss"} ]},
  3. {"a":"sss","b":"sss","c":11,"User":[ {"ID":"sss","name":"sss"} ]}
  4. ]

photo
1

could you create a test service/method and put here only one function "FilterObjectProperties"?

and call the service/method with parameters what you have, and we can see if the problem is with this function or with something else

photo