metropoj
2nd May 2018, 21:45
I am looking for some approaches to capture a specific field value BEFORE I actually change it.

Example: an Item Description.

I want to capture the current unmodified value and then also write the changed value.

I currently write my changed values via dal.set.field() without issue in the appropriate places within ueDLL's and DAL scripting.

Just wondering best way to grab the 'previous' value before i made a change.

Thanks !

vahdani
3rd May 2018, 12:00
Hi,

the standard function with.old.object.values.do() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_db_operations_with_old_object_values_do) is the one which I would use in UeDLL or DAL.

You could do something like the following:


table ttcibd001 |Item Base data

domian tcdsca old.dsca


function extern long ue.before.before.save.object(long mode)
{
on case mode
case DAL_NEW:
break
case DAL_UPDATE:
with.old.object.values.do(get.old.values)
break
endcase
return(0)
}

function extern long ue.after.after.save.object(long mode)
{
on case mode
case DAL_NEW:
break
case DAL_UPDATE:
if tcibd001.dsca <> old.dsca then
|Description is just being changed!!
do.something.with( tcibd001.dsca,
old.dsca)
end
break
endcase
return(0)
}

function get.old.values()
{
old.dsca = tcibd001.dsca
}

function do.something.with(...)
{
...
}



Greetings from Cologne to Canada!

metropoj
3rd May 2018, 14:38
Ahhh, thanks for that functionality to look at.
That looks great.
This morning I thought about using a select statement in before.program: to grab my current unedited values and then when a change actually happens, write my record of current select first, then proceed to re-select the new values from the table before writing them as well.

Cheers.

vahdani
3rd May 2018, 15:10
Hi again!

I forgot::rolleyes: If you don't want to use DAL or UE you can use the function on.old.occ() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_form_and_form_field_operations_on_old_occ) in your session script which basically does the same thing. Something like:

declaration:
domain old.dsca

main.table.io:
before.rewrite:
on.old.occ(get.old.values)
if tcibd001.dsca <> old.dsca then
...
endif

functions:
function get.old.values()
{
old.dsca = tcibd001.dsca
}