Hi all,
I have defined a table Customer which contains 2 fields Custid (PK) and custname in sql server2014. I want to validate records with unique custname in my rollbase app through trigger type Validate Record Data 'before create' a new record. When I create a new customer record then it should validate the records with custname whether a new custname does not match with existing customer name.If new Customer Name matches with existing one then an alert should appear 'Customer name ... already exists'.
So how to loop through all records that satisfy a condintion in rollbase?
You can achieve the same without using triggers, by enabling this property "Do not allow duplicate values in this field." at in field definition.
Customer Object Definition -> Click on Edit link of the field custname -> Check the property "Do not allow duplicate values in this field" and save. Now try to create a new record. It will validate all existing customer names
Thanks
Srinivas
Hi,
This works fine. But I want to use it with server side scripting in formula header of trigger. So how to loop records that satisfy the given condition?
One more thing : we know sql triggers(which are defined in sql server) does not work in rollbase, as "System Errror appears".
so my question is "Is there any way to run sql triggers in my rollbase application? What should be the minimal changes in rollbase to work with sql triggers? Because triggers are 50 or 100 lines of code so do we need to recreate a same trigger in rollbase?
Please suggest.
You can use rbv_api.selectQuery("SELECT ... FROM ..", maxRows, arg1, arg2...) Server API to get the records. Execute rbv_api.selectQuery("SELECT count(*) FROM Customer", 1) to get Count of records. Then execute the select query to get all the records.It returns a double dimensional array. Now you can iterate through this array and implement the logic to perform the validation.
Example:
var count=rbv_api.selectQuery("SELECT count(*) FROM customer", 1);
rbv_api.println(count[0][0]);
var names=rbv_api.selectQuery("SELECT customername FROM customer", count[0][0]);
rbv_api.println(names[0][0]);
Thanks
Srinivas
Hi all,
we know sql triggers(which are defined in sql server) does not work in rollbase, as "System Errror appears".
so my question is "Is there any way to run sql triggers in my rollbase application? What should be the minimal changes in rollbase to work with sql triggers? Because triggers are 50 or 100 lines of code so do we need to recreate a same trigger in rollbase?
- See more at: community.progress.com/.../77529
You can use custom triggers. I am not sure this works for you. In customer trigger, you have to write java code to invoke DB trigger. This custom trigger can be invoked on 'before create' of a new record.
Custom trigger documentation is available @ www.rollbase.com/.../customt.zip
Thanks
Srinivas
Hi Shilpi,
I was wrong. we cannot invoke database triggers from Rollbase. Database triggers are only executed before/after rows are inserted/updated/deleted in the database.
Thanks
Srinivas