+ Start a Discussion
nani@rnani@r 

field dependencie

In the data model when i insert name in name field  i should have to enter only characters i want to do no ride to enter numbers in the name field how to do that.

Best Answer chosen by Admin (Salesforce Developers) 
PrasadVRPrasadVR

Hai.....

  

  u can control ur field name by using validation rule see below

    

   isnumber(name__c)    suppose if enter numeric num in ur name field, now its true it displays error msg &it alows char    only

All Answers

Jia HuJia Hu

user Validation Rule on the Name field,

 

such as,

 

If( OR( CONTAINS(Name, '0' ), CONTAINS(Name, '1' ), CONTAINS(Name, '2' ) ) , TRUE, FALSE)

 

Name is the API name of your field

 

you can not input 0, 1, 2 in the Name field now,  you can add the support for 3 to 9 as the same

 

nani@rnani@r

Hiii thanx for ur information

 

At the same way can i restrict to another field like 'subject,fees,time,duration',

pls help me 

Jia HuJia Hu
Yeah, it is same. Change the filed name to whatever you want to set the Validation Rule.
nani@rnani@r

hiiiiiiiiiii 

     one more doubt sir  i want only restrict numbers .i want insert like RAJESH123 ,RAJESH32.when i insert only numbers in that time only i want to restrict sir .

hhyyddhhyydd

if  you want to restrict numbers in the field

 

create one validation rule

suppose if your field name is customer name then give the validation rule as

isnumber(customer_name__c)

 

this validation rule becomes true when u entered field data only numbers

if it is true it throws error message

 

isnumber( ) is a inbuilt function available in salesforce

 

the aim of this function is to check the field data whether it is number data or text data

PrasadVRPrasadVR

Hai.....

  

  u can control ur field name by using validation rule see below

    

   isnumber(name__c)    suppose if enter numeric num in ur name field, now its true it displays error msg &it alows char    only

This was selected as the best answer
nani@rnani@r

IAM TRYING TO DO LIKE THIS BUT THAT DOES'T WORK IN DEVELOPER CONSOLE WHY SO.IT SHOWS ERROR(INSERT FAILED)

 

 

@istest
public class rajinsert{

static testmethod void raj(){

rajesh__c a = new rajesh__c();

a.name = 'Mumbai';
a.price__c=9000;
a.subject__c='sfdc';

rajesh__c b=new rajesh__c();
b.name = 'raj';
b.price__c=4000;
b.subject__c='c';

rajesh__c c=new rajesh__c();

c.name = 'raj';
c.price__c=4400;
c.subject__c=C++';

list<rajesh__c> ab=new list<rajesh__C>();
ab=[select name,price__C,subject__c from rajesh__C ];
ab.add(a);
ab.add(b);
ab.add(c);
insert ab;

}

}