52
Views
11
Comments
Solved
Checkbox - Can't find "content" to use in update function.

Hello all, I am trying to update an entity's attribute (a Boolean) to be true or false depending on a checkbox. Pretty simple. The twist is that it is inside a table records and I can't seem to reference the "content" of the checkbox. Here is what it looks like: 


I figured I couldn't just use a variable since it depended on which "row" was being clicked.

How can I do that?

2019-06-15 21-39-22
Afonso Carvalho
 
MVP
Solution

Add a Query refresh alongside your AJAX refresh. The changes you do in the table are lost when you AJAX refresh, and just updating the database does not make it so new results are fetched:

2023-07-03 14-28-45
Vinicius Seixas

Afonso Carvalho wrote:

Add a Query refresh alongside your AJAX refresh. The changes you do in the table are lost when you AJAX refresh, and just updating the database does not make it so new results are fetched:


Perfect! Thank you kind sir!

2019-06-15 21-39-22
Afonso Carvalho
 
MVP

Hi Vinicius,

Give your Table a name and then you can use TableName.List.Current.YourRecord.YourFlag to get the specific value.

2021-01-12 09-17-15
35e7a81a-9d12-4e49-a81f-8c1f290be6f4

You don't need a local variable as an intermediary.

If a column with the 'is verified' boolean already exists in your database table or List, you can bind your checkbox directly to that value:

YourTableName.List.Current.RecordName.IsVerified
2023-07-03 14-28-45
Vinicius Seixas

You see guys, that's what I thought too initially, but if I do that like you guys suggested this is what happens:

I have an "on change" function set to the checkbox. Once it changes, it updates the entity using the update function. I have linked it like you suggested, using the table name and the existing one. 

However, once I flip these: 


and I refresh the page, they do not get updated. When I debugged it, it didnt' even update in the database, so I don't think it's working.

2021-01-12 09-17-15
35e7a81a-9d12-4e49-a81f-8c1f290be6f4

Just checking a few things:

- When you debugged using the debugger, did you check the state of the record in the OnChange Action before the database update, and was the boolean flipped correctly in that stage? 

- Did you refresh the whole page (like you would with F5) or did you use Ajax refresh?

2023-07-03 14-28-45
Vinicius Seixas

Monique de Vos wrote:

Just checking a few things:

- When you debugged using the debugger, did you check the state of the record in the OnChange Action before the database update, and was the boolean flipped correctly in that stage? 

- Did you refresh the whole page (like you would with F5) or did you use Ajax refresh?

Hi, I posted the OML file here, and I used an Ajax refresh on the table widget, where the checkbox is.


2019-06-15 21-39-22
Afonso Carvalho
 
MVP

When you say they didn't update in the database, are you saving them yourself? What do you see when you're debugging - are the correct values being read but not being written to the database?

Could you share your espace file?

2023-07-03 14-28-45
Vinicius Seixas

I am using the update function to change the value of IsValid in the entity to the value stored in the Table1. 

Here is the espace. 

2019-06-15 21-39-22
Afonso Carvalho
 
MVP
Solution

Add a Query refresh alongside your AJAX refresh. The changes you do in the table are lost when you AJAX refresh, and just updating the database does not make it so new results are fetched:

2023-07-03 14-28-45
Vinicius Seixas

Afonso Carvalho wrote:

Add a Query refresh alongside your AJAX refresh. The changes you do in the table are lost when you AJAX refresh, and just updating the database does not make it so new results are fetched:


Perfect! Thank you kind sir!

2019-06-15 21-39-22
Afonso Carvalho
 
MVP

No problem. Another remark: unless you're doing very specific things with your data, you don't usually need to use a GetForUpdate - you shouldn't be having concurrency problems in a Form.

2023-07-03 14-28-45
Vinicius Seixas

Yeah I was not using it initially, but someone suggested that I did, maybe they meant in another usage. Thank you for the suggestion!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.