Great Plains Dexterity Dynamics eEnterprise Microsoft CRM Microsoft RMS Crystal Reports SQL International
Alba Spectrum Technologies
Phones
Toll Free: 1-866-528-0577
Office: 1-630-961-5918
Cell (consultant-on-duty): 1-630-854-0597
Email: welcome@albaspectrum.com.
Alba Spectrum Technologies
Sample Dexterity Code
This is Dexterity sample code. It is table update trigger, which update SOP Invoice lines 'Requested Ship Date' field to make it the same as 'Requested Ship Date' of SOP Invoice'. Prior to this it checks if 'Requested Ship Date' of Invoice header is not updated - it makes it equal the 'Invoice Date'
Name of the procedure: AS_SOP_HDR_WORK_Req_Ship_Date
Parameter:
inout table SOP_HDR_WORK.
{Updates 'Requested Ship Date' of Table SOP_HDR_WORK to 'Invoice Date' of the
same table, when 'Requested Ship Date' = 'Order Date' - it means it is not
changed by Order Enter} person}
if 'SOP Type' of table SOP_HDR_WORK = 3 and
'Requested Ship Date' of table SOP_HDR_WORK = 'Order Date'
of table SOP_HDR_WORK then
set 'Requested Ship Date' of table SOP_HDR_WORK to
'Invoice Date' of table SOP_HDR_WORK.
release table SOP_LINE_WORK.
range clear table SOP_LINE_WORK.
set 'SOP Type' of table SOP_LINE_WORK to
'SOP Type' of table SOP_HDR_WORK.
set 'SOP Number' of table SOP_LINE_WORK to
'SOP Number' of table SOP_HDR_WORK.
{Updates 'Requested Ship Date' of Table SOP_LINE_WORK to 'Requested Ship Date' of Table SOP_HDR_WORK}
clear 'Line Item Sequence' of table SOP_LINE_WORK.
clear 'Component Sequence' of table SOP_LINE_WORK.
range start table SOP_LINE_WORK.
fill 'Line Item Sequence' of table SOP_LINE_WORK.
fill 'Component Sequence' of table SOP_LINE_WORK.
range end table SOP_LINE_WORK.
get first table SOP_LINE_WORK.
while err()<>EOF do
change table SOP_LINE_WORK.
set 'Requested Ship Date'of table SOP_LINE_WORK to
'Requested Ship Date' of table SOP_HDR_WORK.
save table SOP_LINE_WORK.
get next table SOP_LINE_WORK.
end while.
end if.
and below is trigger registration in Startup procedure:
{We want Requested Ship Date for the doc and each line be the same as Invoice
Date}
set l_result to Trigger_RegisterDatabase(reference(table SOP_HDR_WORK),0,
TRIGGER_ON_DB_UPDATE, script AS_SOP_HDR_WORK_Req_Ship_Date).
if l_result <> SY_NOERR then
warning "Database trigger registration failed.".
end if.