Hi,
Need help on how to prefix value into the field before data entry.
field = leave_number
need fill with prefix before data entry for example below:-
leave number: ABC00000001
tried using tablename-tv.js hook but fail to do so.
thanks in advance.
Prefix Value Into Field
Re: Prefix Value Into Field
Hi,
can you please explain what you try to acheive? Thhe tablenamne-tv.js will apply changes to the tableview. So you only want to see a prefix in the table view where as the real data has no prefix?
can you please explain what you try to acheive? Thhe tablenamne-tv.js will apply changes to the tableview. So you only want to see a prefix in the table view where as the real data has no prefix?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Prefix Value Into Field
Hi,
trying to achieve pre-fill field with prefix + auto increment number
(field) = leave_number
When user click insert new, need to populate leave_number with prefix + auto increment number
As example = ABC000001
try achieve sql query success but manage to do it with number increment only.
not sure how to prefix ABC in front of it.
Thanks.
trying to achieve pre-fill field with prefix + auto increment number
(field) = leave_number
When user click insert new, need to populate leave_number with prefix + auto increment number
As example = ABC000001
try achieve sql query success but manage to do it with number increment only.
not sure how to prefix ABC in front of it.
Thanks.
Re: Prefix Value Into Field
Hi,
not sure if this is what you are looking for, but you could use either the primary key (if you have one that is autoincremented) and use the after_insert, after_update (if needed) hook functions to apply your prefix
or you can add an additional field that will hold your unique number (as you described above and you use the after_insert, after_update (if needed) hook functions to apply your prefix to the autoincremented number.
something like
sqlvalue("UPDATE ##tablename## set leave_number=concat("ABC",lpad(ID, 6, 0) where id =".$data['selectedID']);
or
sqlvalue("UPDATE ##tablename## set leave_number=concat("ABC",lpad(leave_number_autoinc, 6, 0) where id =".$data['selectedID']);
not sure if this is what you are looking for, but you could use either the primary key (if you have one that is autoincremented) and use the after_insert, after_update (if needed) hook functions to apply your prefix
or you can add an additional field that will hold your unique number (as you described above and you use the after_insert, after_update (if needed) hook functions to apply your prefix to the autoincremented number.
something like
sqlvalue("UPDATE ##tablename## set leave_number=concat("ABC",lpad(ID, 6, 0) where id =".$data['selectedID']);
or
sqlvalue("UPDATE ##tablename## set leave_number=concat("ABC",lpad(leave_number_autoinc, 6, 0) where id =".$data['selectedID']);
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Prefix Value Into Field
Hi,
This also can. But have not tried out yet.
Will keep posted.
Regards,
This also can. But have not tried out yet.
Will keep posted.
Regards,