tmannais
14th August 2018, 13:50
Hi,
I am trying to save current record in a session using Extension.
I have tried
- execute(update.db)
- dal.save.object() with dal.change.object() and dal.set.field()
but no luck. The record is not saved.
What is the correct solution to do this?
Regards,
Thana
JaapJD
14th August 2018, 15:05
Can you elaborate a little bit more on your scenario? When do you want to save the current record? Which hook do you use in the extension?
tmannais
15th August 2018, 04:37
In Extension tisfc0101m100 type Session. Inside the Extension Modeler, I created a Custom Form Command which contains this snippet.
. . .
tisfc001.qrdr = tisfc001.qrdr + 500 |* Just update the quantity
display.all() |* This will not be needed if it can save and redisplay by itself
execute(update.db) |* Try to save but it doesn't work
. . .
I wrote this in the Command Execute hook so when the form command is activated, it will run this code, in which it runs without any errors but the save command just does not do its job.
tmannais
15th August 2018, 07:08
The problem is now solved using this solution.
select tisfc001.qrdr
from tisfc001 for update
where tisfc001.pdno = :tisfc001.pdno
selectdo
db.retry.point()
if dal.change.object("tisfc001") <> 0 then
dal.get.error.message(error.msg)
dal.set.message(MSG.ERROR, "@DAL Error: " & error.msg)
show.dal.messages()
endif
dal.set.field("tisfc001.qrdr", tisfc001.qrdr + 500)
if dal.save.object("tisfc001") <> 0 then
dal.get.error.message(error.msg)
dal.set.message(MSG.ERROR, "@DAL Error: " & error.msg)
show.dal.messages()
endif
commit.transaction()
endselect
prcm.notify("tisfc001")
The important thing that forces it to save is "commit.transaction()", and to make the value redisplay in the session, I use "prcm.notify()" with the table I just updated one of its value.
JaapJD
15th August 2018, 10:47
Two remarks: the db.retry.point() must be before the select. And instead of prcm.notify, I would use refresh.curr.occ().
tmannais
15th August 2018, 13:15
Thank you for your advice.
I will keep that in mind.