Validate input field value

saurabhsharma
Giga Contributor

Hi 

I have created a custom table name as badge. I have two field name as Badge type and Bagde number. Badge type is of drop down has value C1 and C2 and Badge number is of text field. When user select type as C1 then user needs to enter value in number field. Suppose user enter A6857. Now when another user select C1 and enter same value that is A6857 then it should throw an error.

How can I validate this ? Kindly help me in this.

Thanks,

Saurabh

7 REPLIES 7

Santosh_Ksagar
Mega Sage
Mega Sage

Hi Saurabh,

Write a before insert business rule---> add condition as number is same as number--> In action check abort action -->add message as Please enter diffrent number.

Regards

Santosh K

_Gaurav
Kilo Sage

Hi Saurabh,

As per your requirement, If one user selects C1 and enter A6857 in number field then you want to restrict other user to create same record ?

 

If yes then you can write "before" business rule for this, that checks both the values on the batch table.
if it find the values in table record then you can set abort action(true) else allow the user to create record.

 

Thanks

Hi Gaurav,

Please give me that code to compare current entry with enteritis in table.

Thanks,

Saurabh

BR:-

When to run - Before Insert

 

var value1 = current.getValue("Field1");

var value2 = current.getValue("Field2");

 

var glide = new GlideRecord("table name");

glide.addQuery('column_lable1' , value1).addCondition('column_lable2' , value2);

glide.query();

if(glide.next())

{

     current.setAbortAction(true);

}

 

Please let me know the response.