Cannot set value moralis object

my moralis object has the following methods

  setStatus: function(newStatus) {
    console.log("status run");
    this.set("status", newStatus);
    this.save().then(
      (obj) => {
        // Execute any logic that should take place after the object is saved.
        alert("New object created with objectid: " + obj.id);
      },
      (error) => {
        // Execute any logic that should take place if the save fails.
        // error is a Moralis.Error with an error code and message.
        alert("Failed to create new object, with error code: " + error.message);
      }
    );
  },

  removeBuyerId: function() {
    this.set("buyerId", "nil");
    this.save();
  },

it works here

  const order = () => {
    buyerOrder()
      .then((reply) => {
        console.log(reply.getHash().hash);
        obj.setStatus("In Order");
        obj.setBuyerId(user.id);
      })
      .catch((err) => {
        console.log(err);
      });
  };

but not here even though it seemingly the same code

  const claim = () => {
    sellerClaim()
      .then((reply) => {
        console.log(reply.getHash().hash);
        obj.setStatus("Open");
        obj.removeBuyerId();
      })
      .catch((err) => {
        console.log(err);
      });
  };

in the first case ‘order’, i can change the status from open to in order but in the second case ‘claim’ i cannot change the status from in order to open nor change the buyerid field.

in fact for ‘claim’ i don’t even get the log message “status run”. so it seeems the method isnt even called.

any idea? thank you

Hi there, thanks for the post.
You have some of your own functions here like sellerClaim and buyerOrder.
It’s impossible to help without debugging them.

I would recommend removing all of own code and just use the basic .set, .save functions that Moralis offers and rebuild from there and you will find the error.

Hi. Thank you for the reply. I didn’t include sellerClaim and buyerOrder becuase they were smart contract that didn’t touch moralis. And then the console log message did get printed in the then blocks so it means they were successful. But thanks anyway for the debugging. I’ll try that out and update here if I find the error. :grinning: