tmannais
21st January 2019, 10:20
First things first,
I have looked into this thread
http://www.baanboard.com/baanboard/showthread.php?t=71316
but it is about the updating process while my case is about on creating a new record.

It is about Call session (tsclm1100m000).
I want it to set a default value to a field, let's say tsclm100.emno, in the session when the user clicks New.

I tried using both Before Command and After Command hooks in Extension type Session to set the field to the desired default text and then display.all().
That is what I followed from the link above.
I implemented those hooks inside New (add.set) of Standard Command.
It does not work. Nothing gets defaulted in the field. It is still empty.

It is now like this.

tcmcs100.emno = "test"
display.all()

Any suggestions?

JaapJD
21st January 2019, 11:35
Did you try already the Set Object Defaults hook in the table extension?

tmannais
21st January 2019, 11:55
Thank you, JaapJD!
It works like a charm.
It doesn't even need to have the display.all() part.

OmeLuuk
4th November 2021, 12:14
Did you try already the Set Object Defaults hook in the table extension?
Is there a functional difference between setting it in the function extern void tdisa010.bind.update(long mode)
{
|* Use this hook to update the value before it is really validated.
|* This hook is called after the standard update() hook,
|* but the value you assign will be validated by
|* the standard is.valid() hook.
tdisa010.bind = tcyesno.no | opposed to RDD default Yes, we never use it...
}

Or would this hook used in this way also (intentionally) set to Yes records back to No where your option only is used when a new record is initiated?

And could this also be done by entering No in the green field?

JaapJD
4th November 2021, 12:57
Programmer's manual says about update hook: This hook is called in case a field on which this field depends (by means of a HOOK_UPDATE or HOOK_IS_APPLICABLE dependency) has changed.
So, it will not be triggered to set the default.
If you always want to have this field set to 'no' regardless of what the standard code does, do it in before save hook.

JaapJD
4th November 2021, 13:00
And could this also be done by entering No in the green field?

You cannot enter that field, it is information only.

OmeLuuk
4th November 2021, 13:15
You cannot enter that field, it is information only.
But it is not showing the default set in the table definition?