- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2016 09:34 PM
Hi Guys,
I have a requirement as below,
i have a field called 'invoice_no' in a form.
when we open a record which is already created and when we click the button submit it has to give an error 'Duplicate Entry' if the field value(invoice_no) for the record is alreadty there in the another record.
for example:
if in one record the value for invoice_no is : JM1234
and in second record the value for invoice_no is : JM1234 same
then when we click the button(inside any of the record) it has to say that already one record exist for this field invoice_no;
Can someone help me on this scenario?
Thanks in advance
Malaisamy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2016 10:50 PM
Use this code in your ui action:
var t=current.getValue('field_name');
var gr=new GlideRecord('table_name');
gr.addQuery('field_name!=""');
gr.query();
while(gr.next())
{
if(gr.field_name==t)
{
gs.addInfoMessage('There is a record with same invoice number');
//current.setAbortAction(true); //use this if you don't want to update the record or use current.update()
break;
}
else
current.update();
}
let me know if this helps.
Thanks
Priyanka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2016 11:47 PM
Hi Priyanka,
It works perfectly... Thanks for the support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2016 11:49 PM
Can you please mark the answer correct and close this thread so that others find it useful.
Thanks
Priyanka.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2016 12:51 AM
Hi Priyanka,
I am not getting the 'correct answer button'. SO that i have marked this as useful.
Let me know if you want me to do anything
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2016 01:11 AM
Need Script for throwing an error for duplicate entry open link and mark the correct answer.
Thanks,
Priyanka