Updating another table field after doing an insert?

Options

I have a table of scripts, that has a filed called questions (object).

This questions field stores a ref to the questionID, from my questions table.

when I create a new question on my front end, I want to update the related script by adding the questionID to that object field in scripts.

I cant do it as I do not know the id of the question at the time I create it?

Is there a way in Xano to update that column ?

I can can create new questions, and I do have a ref to the script in the questions DB:

But right now, in my scripts DB, I am manually entering the script_questions object field for the record with the questionIDs

Tagged:

Answers

  • Pawel Magdanski
    Pawel Magdanski Member ✭✭✭
    Options

    Hi,

    So after you create the record you can get the id of it right away in the next step, just make sure that the id is available in the output generated by add record function. So you can take it and update your script record in the next step

  • twinstick
    twinstick Member
    Options

    @Pawel Magdanski am I right in thinking that I add another function to the function stack in the create questions API?

    And in that new function I use the output you have shown to update the record in the scripts table?

    Essentially handling everything in Xano, and not my frontend (Weweb).

    Thanks for your reply

  • Pawel Magdanski
    Pawel Magdanski Member ✭✭✭
    Options

    If you want this script table to be always automatically updated after you add question then yes, I think you should do all that in a single function stack, no need to involve front-end here, unless there are some factors I'm not aware of.

  • twinstick
    twinstick Member
    Options

    @Pawel Magdanski thanks, I will have to go away and spend some time understanding the function stack and how to access the previous output field, use it to identify the right script and then update the field in the object.

  • Pawel Magdanski
    Pawel Magdanski Member ✭✭✭
    Options

    @twinstick Ok, take you time. If you want I'm offering a consultations when we can speed up the whole process for you. You can drop me an email if you are interested pmagdanski@gmail.com