function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pintoo rajputpintoo rajput 

Need to insert records using dataloader..

I need to upload 100 contacts using dataloader, we have some validation rule on contact object, now my requirement is the validation rule should impose for 1 to 50 records and should not impose for 51 to 100 records, how to achieve this?  

Thanks in Advance
Best Answer chosen by pintoo rajput
Leandro Valdes VieraLeandro Valdes Viera
I don't know if there is a simpler way to do this, but you can accomplish it by creating a new Custom Field (Boolean) on Contacts called "Override_Validation_Rules__c" and add to your Validation Rule:

Override_Validation_Rules__c = FALSE

Then add a column to your CSV file for this field and mark TRUE for the 50 records that you don't want to apply the Validation rule to, and FALSE for the other 50 records.

All Answers

Rakesh51Rakesh51
1. Create two excel sheets with 50-50 records in each
2. Process first excel sheet using the Data Loader
3. Before processing second excel sheet make sure to Deactivate the Validation rule. 
4.Once process done, activate the Data Loader 

 
Leandro Valdes VieraLeandro Valdes Viera
I don't know if there is a simpler way to do this, but you can accomplish it by creating a new Custom Field (Boolean) on Contacts called "Override_Validation_Rules__c" and add to your Validation Rule:

Override_Validation_Rules__c = FALSE

Then add a column to your CSV file for this field and mark TRUE for the 50 records that you don't want to apply the Validation rule to, and FALSE for the other 50 records.
This was selected as the best answer
Rakesh51Rakesh51
But for creating a custom field to process 50 records is not a good solution 
Leandro Valdes VieraLeandro Valdes Viera

True that you shouldn't create a new field to process just 50 records.

The good part is that you can reuse this going forward. And if you add it to all -or most- Validations you create, next time you need to override a couple of rules you don't need to go around deactivating and activating a bunch of them.

pintoo rajputpintoo rajput
Thanks Rakesh, but i think deactivation the validation rule is not good idea,beacuse meawhile other user can create wrong data,because in production same time other users can create contacts.thanks for your suggestion.