Add or Edit not working with me

Options
when i get records from a table and it is not null the "Add or Edit record" works but when i get the record from the a table and it is empty it does not create the record !!!! i am not sure why

[a3.JPG]

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Change your response type to single in your query all records... and instead of dot notation on var: UserRankings use the GET Filter:

    var: UserRankings | GET | id |default: null


    Otherwise, you currently have it set up where if nothing is found in your query all records then you get an empty array and your path does not exist.
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    The Get Filter is super flexible as it allows you to define a default value in case the path does not exist so your function stack can continue to run
  • Mohammed tayyar
    Options
      Thank you so much for the prompt response I really appreciate it 
  • Mohammed tayyar
    Options
    i have tried it but it is still not working i am not sure what am i doing wrong 
    it works if the data is there but it does not if it is not there 
    [3333.JPG][3333-2.JPG][3333-3.JPG]
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    It looks like you are trying to reference the auth: ID within this path

    [CleanShot 2022-04-04 at 11.47.55.png]
    You are getting access denied because your endpoint does not require user authentication and you are referencing the auth: ID. 

    However, this is not the correct way to reference the auth: ID even with authentication turned on for this endpoint.

    I believe you just want the text string "id" and not auth: ID for that path.
  • Mohammed tayyar
    Options
    i am still getting an error

    i am just wondering why is it not working with me the logic should be simple

    i will get an id in userRanking1 and then check it if we have it!!!!


    [no.JPG]
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     are you trying to Add or Edit the record you are inputting (UserID) or the record you are getting from your Query All Records?

    To me it looks like you are looking up a record with Query All Records and wishing to Add or Edit the result.

    IF that case you want the path of var: UserRankings_1 to be id... not your input UserID.

    var: UserRankings_1 | GET | path: id

    IF you want to edit the record of the UserID you are inputting then you only need that input on the field_value line and no filter.

    Also, be mindful of using Query All Records. If you are returning a list, then you will need to loop through the list to apply any manipulation to it. If you are just retuning a single item then what you have is fine. You can double-check which you are returning by clicking on the function (Query All Records > Output > Return). 
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    We have office hours in two hours if you are still stuck: https://calendly.com/xano/officehours