Notifications
Clear all

Cách kiểm tra tính hợp lệ của dữ liệu trước khi thực hiện câu query Approval

1 Posts
1 Users
0 Likes
308 Views
admin
Posts: 334
Admin
Topic starter
(@admin)
Prominent Member
Joined: 2 years ago

Tình huống

Chứng từ Sales Order cần qua cơ chế phê duyệt (Approval Process) trước khi được phép trở thành chứng từ chính thức. Tuy nhiên để đảm bảo dữ liệu đầy đủ, Sales Order phải được khai báo thông tin nhân viên kinh doanh (sales employee) trước khi gửi đi phê duyệt.

 

Giải pháp

Sử dụng Transaction Notification để chặn nếu người dùng (user) nhập thiếu thông tin sales employee 

Khi được gửi đi phê duyệt, chứng từ sẽ được lưu ở dạng nháp trong các bảng ODRF, DRF1. Do vậy cần sử dụng object type là 112

Đây là dạng mẫu minh họa

if @object_type = '112' and @transaction_type in ('A', 'U')
begin
	IF exists (select T0.DocEntry from ODRF T0 inner join DRF1 T1 on T0.DocEntry=T1.DocEntry 
where T0.DocEntry = @list_of_cols_val_tab_del 
		and T0.objtype=17 --Sales Order
		and (isnull(T1.SlpCode,0)=0 or T1.SlpCode=-1) )
		begin
			set @error = 1701
			set @error_message = N'Assign Sales Employee, please.'
		end
end
Reply
Share:
x  Powerful Protection for WordPress, from Shield Security
This Site Is Protected By
Shield Security