
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 04:05 AM
I have a requirement where i do not want to get a record inserted into a table if it is allready present.
I have a form as follows:
For each project code i will have to enter 12 month's amount, meaning For '123' project code i need to enter amount for 123-january upto 123-december.
But i dont want to enter 2 entries for 123-january or any month.
I wrote a business rule for this but it doesn't seem to wotk:
BR:
(function executeRule(current, previous /*null when async*/) {
var amt = current.amount;
gs.info(amt);
var month = current.month;
// Add your code here
var gr = new GlideRecord("x_71260_pmo_develo_billing_details");
//gr.addQuery("project_code", current.project_code);
//gr.addQuery("project_status", current.project_status);
//gr.addQuery("year", current.year);
gr.query();
if(gr.addQuery("month","==", month))
{
gs.info("inside IF");
gs.info("You have allready entered PO amount for this month for this project.");
gs.addErrorMessage("You have allready entered PO amount for this month for this project.");
current.setAbortAction(true);
}
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 04:46 AM
Hi Vineetha,
It's easy to do by code( Business Rule).
var gr = new Gliderecord('your table name');
gr.addQuery('ProjectCode',current.projectcode);
gr.addQuery('ProjectName',current.projectname);
gr.addQuery('Projectstatus',current.projectstatus);
.........................................................................
...............// you can add what ever fields u have unique in field
gr.query();
if(gr.getRowCount() > 0)
{
current.setAbortAction(true);
}
This is generic script ,, modify as u want.
if it is correct answer for you , please mark this answer as CORRECT .
regards,
VIPIN MATHEW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 04:47 AM
ok then you can simply add one more query. if count more than 1 then abort action.
gr.addQuery("month", current.month);
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 04:46 AM
Hi Vineetha,
It's easy to do by code( Business Rule).
var gr = new Gliderecord('your table name');
gr.addQuery('ProjectCode',current.projectcode);
gr.addQuery('ProjectName',current.projectname);
gr.addQuery('Projectstatus',current.projectstatus);
.........................................................................
...............// you can add what ever fields u have unique in field
gr.query();
if(gr.getRowCount() > 0)
{
current.setAbortAction(true);
}
This is generic script ,, modify as u want.
if it is correct answer for you , please mark this answer as CORRECT .
regards,
VIPIN MATHEW

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 05:03 AM
This worked, thanks for the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 07:05 AM
You are welcome