Skip to main content
Question

Can we use 'CrudOperation' variable with 'before command'

  • April 16, 2026
  • 5 replies
  • 22 views

Forum|alt.badge.img+6

In the Technical Documentation for before and after commands, it says that 

  • The CrudOperation variable can be used to get the operation (createupdate or delete).

 Can we use the CrudOperation and only have something execute upon ‘update’?

For example:

 

@Override
list ItemsList for ContractItem {

   crudactions {
      before command CContractItemValidation;
   }

}

 

and then

 

command CContractItemValidation for ContractItem {
   mode = SelectedRecords;
   variable CContractItemString Text;
   variable CValidation Boolean;

   bulkexecute {
      if [CrudOperation = "update"] {

         stringify(records, "DATA", JSON) into CContractItemString;
         call CValidateContractItems(CContractItemString) into CValidation;
      }
   }
}

 

Anybody came across this kind of scenario?

Where you have to validate the updates done to multiple records before being saved.

5 replies

Forum|alt.badge.img+12
  • Hero (Customer)
  • April 16, 2026

If it’s purely validation driven, any particular reason you want to do it at CRUD action level rather than just override Check_Upate___ for ContractItem ?


Forum|alt.badge.img+6

Hi ​@SimonTestard 

The requirement is to check multiple records together before saving, for example the sum of a specific attribute of all the records should be 0.

Check_Upate___ executes separately for each record that was modified if I understand.


Forum|alt.badge.img+12
  • Hero (Customer)
  • April 17, 2026

Ok that makes sense.

 

If your code note working ? It should be, it follows the right syntax

 

 

 

Although I’m not used to Stringify so I can’t tell you much about that use, if you trace/log/error output the  CContractItemString within the action, do you have the data you need for your validation?


Forum|alt.badge.img+6

I get the values of the attributes of the records that I pass to CContractItemString.

 

But the CrudOperation value is null inside the bulkexecute’s conditional statement.


And considering its a bulk execute (some records might be create and some might be update), I tried passing the CrudOperation value into CContractItemString as well hoping it would pass the type of action for each record, but on the plsvc side I still have it as null.


Forum|alt.badge.img+12
  • Hero (Customer)
  • April 19, 2026

so what you’re saying is that if instead of calling the PLSVC action, just as a test, if your command calls, let’s say, info("${CrudOperation}"), the resulting toast has no value ?

If that is the case, have you tried with a regular execute rather than bulkexecute ? If CrudOperation has a value with execute but not bulkexecute, it might simply not be compatible with bulkexecute ?