You need to sign in to do that
Don't have an account?
Rakesh Samal
Error when inserting a record
I have two custom object.
One is student_Master__c. Field is: Name,Pancard Number,Phone, Background Check Status.
and another is Black_Listed_candidate__c. Field is: Name, PAN, phone.
Condition: Whenever we are inserting record in student_Master__c it has to check "pancard number" in above database. If the "PAN number" is found in "Black_Listed_candidate__c" object, then show message in "Background Check Status" field that "candidate is blacklisted. we cannot hire!."
And also as well as update "Phone" field in "Black_Listed_candidate__c" object record with new phone present in "student_Master__c" object record.
Please help me with this. I am trying but give error.
This is my code below:
Apex Class:
public class PancardCheckClass {
@future
public static void updateBlackListPhone(Map<Id,string> idAndPhoneMap)
{
list<Black_Listed_Candidate__c> blackListedPans = [SELECT Name,PAN__c,Phone__c FROM Black_Listed_Candidate__c WHERE Id IN:idAndPhoneMap.KeySet()];
for(Black_Listed_Candidate__c black :blackListedPans)
{
black.Phone__c = idAndPhoneMap.get(black.Id);
}
Update blackListedPans;
}
}
Trigger:
trigger PancardCheckClassTrigger on Student_Master__c (before insert) {
list<Black_Listed_Candidate__c> blackList =[SELECT Name,PAN__c,Phone__c FROM Black_Listed_Candidate__c];
system.debug('kdng' + blackList);
list<Student_Master__c> newRecord = new list<Student_Master__c>();
Map<Id,string> IdAndBlackListPhoneMap = New Map<Id,string>();
for(Student_Master__c varStudent: trigger.new)
{
for(Black_Listed_Candidate__c varBlacklist:blackList)
{
if(varBlacklist.PAN__c==varStudent.Pan_Card_Number__c)
{
varBlacklist.Phone__c=varStudent.Phone__c;
IdAndBlackListPhoneMap.put(varBlacklist.Id, varBlacklist.Phone__c);
newRecord.add(varStudent);
}
}
if(newRecord.size() > 0)
{
PancardCheckClass.updateBlackListPhone(IdAndBlackListPhoneMap);
for(Student_Master__c newAppRecord : newRecord)
{
newAppRecord.Background_Check_Status__c='Candidate is Blacklisted! We cannot hire!';
}
}
}
}
One is student_Master__c. Field is: Name,Pancard Number,Phone, Background Check Status.
and another is Black_Listed_candidate__c. Field is: Name, PAN, phone.
Condition: Whenever we are inserting record in student_Master__c it has to check "pancard number" in above database. If the "PAN number" is found in "Black_Listed_candidate__c" object, then show message in "Background Check Status" field that "candidate is blacklisted. we cannot hire!."
And also as well as update "Phone" field in "Black_Listed_candidate__c" object record with new phone present in "student_Master__c" object record.
Please help me with this. I am trying but give error.
This is my code below:
Apex Class:
public class PancardCheckClass {
@future
public static void updateBlackListPhone(Map<Id,string> idAndPhoneMap)
{
list<Black_Listed_Candidate__c> blackListedPans = [SELECT Name,PAN__c,Phone__c FROM Black_Listed_Candidate__c WHERE Id IN:idAndPhoneMap.KeySet()];
for(Black_Listed_Candidate__c black :blackListedPans)
{
black.Phone__c = idAndPhoneMap.get(black.Id);
}
Update blackListedPans;
}
}
Trigger:
trigger PancardCheckClassTrigger on Student_Master__c (before insert) {
list<Black_Listed_Candidate__c> blackList =[SELECT Name,PAN__c,Phone__c FROM Black_Listed_Candidate__c];
system.debug('kdng' + blackList);
list<Student_Master__c> newRecord = new list<Student_Master__c>();
Map<Id,string> IdAndBlackListPhoneMap = New Map<Id,string>();
for(Student_Master__c varStudent: trigger.new)
{
for(Black_Listed_Candidate__c varBlacklist:blackList)
{
if(varBlacklist.PAN__c==varStudent.Pan_Card_Number__c)
{
varBlacklist.Phone__c=varStudent.Phone__c;
IdAndBlackListPhoneMap.put(varBlacklist.Id, varBlacklist.Phone__c);
newRecord.add(varStudent);
}
}
if(newRecord.size() > 0)
{
PancardCheckClass.updateBlackListPhone(IdAndBlackListPhoneMap);
for(Student_Master__c newAppRecord : newRecord)
{
newAppRecord.Background_Check_Status__c='Candidate is Blacklisted! We cannot hire!';
}
}
}
}
This error means that the value submitted to Salesforce exceeds the maximum character length set for the Salesforce field.
Resolution :-
Apply character limit to the text field that is throwing the error. To add a character limit, select the field and click Options > Validation Rules and enter a number in the "Limit length of answer" box.
Reference :- https://help.formassembly.com/help/salesforce-error-data-value-too-large
Kindly mark it as the best answer if it works for you.
Thanks & Regards,
Priya Ranjan