function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
charchit nirayanwalcharchit nirayanwal 

How to make validation use a coupon single time by individual customer

For this we need to use trigger :

  trigger checkalready on "order object" (before insert) {
    order object a=trigger.new[0];
    integer d=[select count() from "order object" where "Customer field"  = :a."customer field" and "coupon field"=:a."coupon field"];
    if(d>0){
         a.addError('Coupons already used');
    }   
}

If anyone have any other answer without using trigger then must post
mukesh guptamukesh gupta
Hi Charcit,

Not possible wihout trigger.

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
charchit nirayanwalcharchit nirayanwal
Finally I found the answer!!
We can give prime number to every coupon and when user use that coupon update the inner field of customer multiply by that prime number.
When customer use coupon next time then we check it by finding  remainder and if it show remainder 0 that means he already used it.
we show validation error.