Drag and drop between subjects example

  • 18 February 2021
  • 0 replies

Userlevel 6
Badge +18


Creating a drag and drop task for the first time can be challenging. This example will tell how to create a simple drag-drop task that will enable you to drag products into a shopping cart.


There are three components, namely the Source tab, the Target tab and of course the Drag-drop task. Assuming the tabs are already present, we will focus on making the task and setting it correctly.

Create a task that has the Primary Key of the source tab and the target tab. Connect it to the Target tab on the Primary key columns. In Subjects, navigate to the Source tab and create an entry in Links → Drag-drop. Enter for the Drag-drop parameters (at least) the Primary key columns of the Source tab. These are the parameters that get filled with values from the SOurce tab. Set up the drag-drop interaction and you are good to go. Enable def. drag-drop enabled if needed at the Settings tab in Subjects.

Result looks like this:


Code used for this example:

--Product not in shopping cart yet
if not exists (select 1
from shop_order_line sol
where sol.shop_order_id = @shop_order_id
and sol.product_id = @product_id)
--and at least a quantity of 1
and @quantity_of_pick > 0
--add to cart
insert shop_order_line (shop_order_id
select @shop_order_id
, @product_id
, @quantity_of_pick
--Product already in shopping cart
--Update the quantity by adding the picked amount
update sol
set sol.quantity_in_basket = sol.quantity_in_basket + @quantity_of_pick
from shop_order_line sol
where sol.shop_order_id = @shop_order_id
and sol.product_id = @product_id

--Update the stock
update p
set p.quantity_in_stock = p.quantity_in_stock - @quantity_of_pick
from product p
where p.product_id = @product_id


0 replies

Be the first to reply!