PricingBlog

Input field bound to individual path within a data object overwrites entire object

  • mdxwired-1274207457970884772

    mdxwired

    1 year ago

    I have a form input field bound to a path within a variable which has been formatted as a data object (eg. profile_data.fname). The incoming binding works fine. But the default event created when I bound the object just overwrites the entire object (profile_data="Bob"), rather than the indivdual path/element of the object (profile_data.fname="Bob"). There does not seem to be a way to force it to only update the relevant object as this level of granularity cannot be set in the action. Do I need to use a temp variable and create a multi-step update process for each event? That seems 'heavy' to me.
  • lucasg-1274209178734297178

    Lucas G

    1 year ago

    You should be able to use the Set node with the input event
  • 1274209307050643547-image.png
  • mdxwired-1274210417194831873

    mdxwired

    1 year ago

    Yes, but the 'Then' portion only offers the "Set: profile_data" option so, in the end, it still pushes the data to the entire object, overwriting it. 😦 I've been at this for hours trying different combinations... no joy.
    1274210416658219110-image.png
    1274210416968466473-image.png
  • ...or it performs the function correctly, but then sets the whole object to Null.
  • mdxwired-1274211427216789574

    mdxwired

    1 year ago

    As always... I assume that the fault lies with me, not with the environement. 🙂
  • mdxwired-1274211948472569928

    mdxwired

    1 year ago

    Ahhh... hold please.
  • max.kayr-1274212150738423852

    Max

    1 year ago

    Did you figure it out or do you need a screenshot? 🙂
  • mdxwired-1274212331898929256

    mdxwired

    1 year ago

    Working on it... BRB
  • mdxwired-1274214794177544273

    mdxwired

    1 year ago

    So, with this method, it seems to just overwrite the entire original structure with the new single key/value pair. Is there any way to have it just update the one path/element without having to define the entire data structure and push all paths/elements every time?
  • mdxwired-1274215193190334485

    mdxwired

    1 year ago

    before...
    1274215193252986910-image.png
  • max.kayr-1274215290841993228

    Max

    1 year ago

    Yes. Just a sec
  • mdxwired-1274215468978409515

    mdxwired

    1 year ago

    After...
    1274215468886130789-image.png
  • K
  • max.kayr-1274216406094844025

    Max

    1 year ago

    This is how you can do it. In the "set: variable" node, you need to adjust the formula (1). Have a Set node (2) and your variable as an input (3). That way, you can change one path of that object
    1274216405864026164-image.png
  • mdxwired-1274216532779601942

    mdxwired

    1 year ago

    Thank you. Reviewing...
  • Tod-1274216534364913736

    Tod

    1 year ago

    Great energy @mdxwired! Your continuous contribution to the toddle Community just made you advance to Community Level 4!
  • mdxwired-1274220428545622067

    mdxwired

    1 year ago

    Works. Follow-up toddle.dev best practices question: Do I create 12 of these workflows (one for each field on the page) or is there a way to make the path being updated dynamic as well, such that I only need call a single workflow?
  • ...or just update all paths with each keypress?
  • max.kayr-1274220695416471645

    Max

    1 year ago

    Don't create 12 Workflows 😬
  • mdxwired-1274220896445272106

    mdxwired

    1 year ago

    I assumed that was not the correct path... 😕
  • max.kayr-1274220990120853586

    Max

    1 year ago

    The path is flexible. You can have a second input in your workflow like "path" and bind it to the path in the set node (click the +)
  • mdxwired-1274228914465669266

    mdxwired

    1 year ago

    Got it. THANKS!! As I said... not the platform's fault.
    1274228914650222654-image.png
    💪1
  • andreasmoller-1274285555714097244

    Andreas Møller

    1 year ago

    If you are setting 1-2 properties then you can chain set commands.

    If you want to update multiple keys at the same time you can use Concatenate to merge objects
    1274285555257049181-CleanShot_2024-08-17_at_10.35.432x.png
  • Concatenate is a "shallow" merge, so if you need to update deep properties you have to use Set.