Add to existing value without getting a record?

Options
Hey! Was wondering if I can use "Edit record" function to do some maths on an existing value, without pulling out a record prior to this.

E.g. there is a record with a value that counts a number of sent emails. Every time I send another email, I want to increment that value. Doable with just "Edit" or I have to pull the data first?

I know it sounds weird, but I am just learning.

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Hey  - if you want to add to something that already exists then yes you will have to first get the data and update it.

    So in your case if you are doing math on an existing value, then you will always want to first get the existing value and apply your math to it then update the value in the database. 
  • Inshal Haq-4369016
    Options
    Hello, I am having a similar issue here. 

    I am attempting to increment an existing variable; however, when using Get Record and then incrementing the value using Edit Record, I receive an error message stating "Unable to locate var: photo_activity.total_likes". Any assistance would be appreciated!
    [increment likes issue in Xano - error msg.PNG][increment likes issue in Xano.PNG]
     
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     - unable to locate var means that your variable at that path does not exist. This could be because there is a typo or you don't have a value at that path...

    If it is the latter then you want to use the GET filter in lieu of dot notation so you can define a default value (perhaps 0 if you are doing math) - https://docs.xano.com/working-with-data/dot-notation#get-filter
  • Inshal Haq-4369016
    Options
    Thank you for your quick response! Got it working with the GET filter![increment likes in Xano - Working!.PNG]