Skip to main content
Nintex Community Menu Bar
Question

javascript updateRow question

  • July 9, 2024
  • 4 replies
  • 14 views

Forum|alt.badge.img+18

Can I replace this

model.updateRow(row, {UpVotes: row.UpVotes + 1});


with this

row.UpVotes++


??

Does that accomplish the same thing?

This topic has been closed for replies.

4 replies

Forum|alt.badge.img+8

No, they do not do the same thing. Your first way is the correct way. The second way, row.UpVotes++ introduces a “side effect”. It is actually setting the property row.UpVotes as one greater than the current value of row.UpVotes. You don’t want to do this because this would mean you’re going around the Skuid API, and directly modifying a property on a model. Then, after that, you are using the Skuid API, which is kind of silly.


Forum|alt.badge.img+8

To be clear, my comment was contrasting these two options.

model.updateRow(row, {UpVotes: row.UpVotes + 1});


and

model.updateRow(row, {UpVotes: row.UpVotes++ });

Forum|alt.badge.img+8

If you’re contrasting

model.updateRow(row, {UpVotes: row.UpVotes + 1});


and

row.UpVotes++


Then the answer is the same, but for different reasons. The first way is correct, and the second way is wrong. Skuid’s implementation of updateRow is hundreds of lines of Javascript that take care of many, many things. Just directly modifying model properties will get you into trouble, fast. 🙂


Forum|alt.badge.img+18
  • Author
  • July 9, 2024

This was the version I intended to contrast. Thanks.