• ANAMIKA MONDAL 8
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 9
    Replies
Hi, I am sending survey invitations manually through email on a survey. When checking the related list for 'Survey Invitation' on the surevy, the inviatation names shows as in format of '2021-02-02 20:56:56'.
But that is being difficult for me to track, as it can be multiple people can send invitation at that time.
Can we make this names auto incremental or any format that we want?
Hi Experts,

I have below question with me, can you please help me understand the right answer?
 
  1. Universal containers sales team would like to track product shipments for each of its customers. The shipment tracking information is currently available in a back end system, which the company plans to integrate with Salesforce. Which objects are relevant for this integration?
 
a.          Opportunity, Opportunity product, Contract, Custom object Shipment Status.
b.           Lead, Account, Opportunity Product, Custom object –Shipment Status.
c.           Opportunity, Opportunity product, Custom object –Shipment Status.
d.           Lead, Opportunity, Product, Custom object –Shipment Status.

I think C is the right answer, butat someplaces the option A is marked as correct. DO we need Contract?
I've written below snippet..  but getting error as 'Method does not exist or incorrect signature: void get(Id) from the type List<Line_Item__c>'


List<Line_Item__c>  liness = [Select Id,Order_c,status__c from Line_Item__c where Order_c in :orderss];
Map<ID, List<Line_Item__c>> connection = new Map<ID, List<Line_Item__c>>();
 for (Line_Item__c lii : liness)
    {
     connection.put(lii.Order_c, liness.get(lii.id)); 
    }


Need to get a list<Line_Item__c> from liness while putting the value into map.
Hi All,

I am having a parent objcet Tree and its child object is Fruit. I need to update the Tree's status to Grown when all the fruits' status of the Tree is changed to Eatable.

Please help me with the trigger logic, or any releted example would help.
Can someone please explain me what is generic object? and why we use it?
Suppose we have two users A and B, A is above B's role hierarchyB is having access to Object C, but A doesn't.
B has created many records of Object C.
Will A be able to see those records of B?
Except @isTest annotation, what all are the annotations that are used in a Test class?
Dear All,

Can someone please explain if outbound messages do a synchonous or asynchonous call? 
Also can please help me understand the diffence of synchonous or asynchonous call with example?
Dear All,

I was trying to write test class for my trigger, but it it giving me error like below
'FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, restrictCase: execution of BeforeInsert' , 'FATAL_ERROR caused by: System.NullPointerException: Attempt to de-reference a null object'

heres my trigger
trigger restrictCase on Case(before insert)
{
MaxCase__c mxx = MaxCase__c.getInstance('MaxValue');    
Integer mvv = Integer.valueOf(mxx.Max__c);
    system.debug('int value' + mvv);

Set<Id> userIds = new Set<Id>();

    
for (case cc : Trigger.new)  
{
userIds.add(cc.ownerId);
} 
 
List<User> userss = [Select Id, Name from User where Id in :userIds];  
Map<Id, Integer> userCases = new Map<Id,Integer>(); 
    
for (user u : userss)
{
 integer countCase = [Select count() from Case where ownerId=:u.Id AND createdDate = This_Month];
 userCases.put(u.id, countCase); 
 system.Debug('user and case' + u.Name + ' . ' + countcase);
}
  
for (case c : trigger.new)    
{

Integer countc = userCases.get(c.OwnerId);    
system.debug('current user case count' + countc);    
    if (countc > mvv)
    {
        c.addError('Too many cases created this month for user' + c.owner.Name + '(' + c.OwnerId + ')' + ':' + mvv);
    }
    
}   
    
    
    
}

and heres the test class I've written
 
@isTest

public class testRestrictCase {

 static testMethod void caseCreation1 ()
 {
          MaxCase__c maxi = new MaxCase__c();
     maxi.Name = 'newMax';
     maxi.Max__c = 80;
     insert maxi;
     
     system.debug('maxi custom setting' + maxi.Name);
     Integer maxiInt = Integer.valueOf(maxi.Max__c);
      system.debug('max value' + maxiInt);
     
     
  Account acct = new Account(Name='anamika');   
  insert acct;
     system.debug('account inserted' + acct.name);
 Contact con = new Contact(FirstName='aa', LastName='bb', AccountId=acct.Id, email='abc@g.com');
  insert con;
     system.debug('contact inserted' + con.name);

 List<Case> casess = new List<Case>();
     for(integer i = 0; i<maxiInt ; i++)
     {
    Case TestC = new Case(Subject='Test Controller Acct Case'+ i, accountId=acct.id, status='New', origin ='Email', contactId=con.id, priority='Medium', type='Mechanical', reason='Installation');
     casess.add(Testc); 
system.debug('testC .i.' + TestC.Subject);
 }
   insert casess;
     system.debug('cases size' + casess.size());
     
     Case TestC1 = new Case(Subject='Test Controller Acct Case new', accountId=acct.id, status='New', origin ='Email', contactId=con.id, priority='Medium', type='Mechanical', reason='Installation');

     try{
         insert TestC1;
     }
 catch(DMLException ex)
 {
   system.debug('max cases inserted');  
 }
 
 }
}

​Please help me finding the issue.

Thanks a lot in advance.
Dear all,

I've wrote a trigger which populates Opportunity owner's manager on opportunity. But when saving any opty it is giving me error like 'Apex trigger PopulateOwnerManager caused an unexpected exception, contact your administrator: PopulateOwnerManager: execution of BeforeInsert caused by: System.ListException: List index out of bounds: 0: Trigger.PopulateOwnerManager: line 7, column 1'

PFB code:
 
trigger PopulateOwnerManager on Opportunity (before insert) {
    
  for(Opportunity op : Trigger.new)  
  {
  
  List<Opportunity>  ownr = [Select OwnerId from Opportunity where id = :op.id]; 
      System.debug('oppty ownerId :' + ownr[0].OwnerId);
  List<User> mngr = [Select ManagerId from User where id= :ownr[0].OwnerId];
      System.debug('oppty owner managerID :' + mngr[0].ManagerId);
  op.Owner_s_Manager__c = mngr[0].ManagerId;    
      
      
  }  
    
}

Please help me sorting this out. Thanks in advance.
Dear All,

I've written a test class for my trigger but its not covering one line that is ''   ls.addError  ('duplicate email');    " 
and only 85% ic covered.
PFB the trigger :
 
trigger DeDups on Lead (before insert, before update) {

  for  (Lead ls : Trigger.New)
  { 
   if (ls.Email != Null) 
   {
       
       List<Contact> dups = [SELECT Id from Contact where Email =:ls.Email ];  
       
       if (dups.size() > 0)
       {
           
       ls.addError  ('duplicate email');    
       }       
       
     else  
         
         insert ls;
       
   }

}
}

Here's the test class I've written :
 
@isTest
public class TestDeDups 
{

  static testMethod void  testDeDupsMethod ()
      
  {
      
  List<Contact> conList= New List<Contact>();
     
  Contact c1 = New Contact(FirstName='test', LastName='test', email ='test@xyz.com');   
  Contact c2 = New Contact(FirstName='test2', LastName='test2',  email ='test2@xyz.com'); 
  Contact c3 = New Contact(FirstName='test3', LastName='test3',  email ='test3@xyz.com');  
  conList.add(c1);
  conList.add(c2);
  conList.add(c3);
  

    Lead l1 = New Lead(FirstName='test22', LastName='test4', company='testbhc45b', email ='test@xyz.com');  
  
      try{ Insert l1 ;}
      catch (Exception e)
      {system.debug ('duplicate found');
      }
      
   List<Lead> ld = [SELECT ID from Lead where Email = 'test@xyz.com'];   
 system.assertEquals(0, ld.size());
      
  }
   
}

Please help with 100% code coverage. Thanks in advance :)​
Hii,

I'm trying to answera question on Trailhead, but it keeps giving me an error.

Question is like the below: 

Create a validation rule to check that a contact is in the zip code of its account.
To complete this challenge, add a validation rule which will block the insertion of a contact if the contact is related to an account and has a mailing postal code (which has the API Name MailingPostalCode) different from the account's shipping postal code (which has the API Name ShippingPostalCode).
Name the validation rule 'Contact must be in Account ZIP Code'.
A contact with a MailingPostalCode that has an account and does not match the associated Account ShippingPostalCode should return with a validation error and not be inserted.
The validation rule should ONLY apply to contact records with an associated account. Contact records with no associated parent account can be added with any MailingPostalCode value. (Hint: you can use the ISBLANK function for this check)

The Error I'm getting :

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [MailingPostalCode__c]: [MailingPostalCode__c]


I've written the below V rule:

AND 

NOT(ISBLANK( AccountId )), 
MailingPostalCode__c != Account.ShippingPostalCode__c 
)

If the MailingPostalCode__c wasn't created, It won't allow me to create the V rule on contact with the field MailingPostalCode__c. And also how can the API name be only MailingPostalCode, its always gets concate with __c.
Please help me out.
Thank in advance.


 
I've written below snippet..  but getting error as 'Method does not exist or incorrect signature: void get(Id) from the type List<Line_Item__c>'


List<Line_Item__c>  liness = [Select Id,Order_c,status__c from Line_Item__c where Order_c in :orderss];
Map<ID, List<Line_Item__c>> connection = new Map<ID, List<Line_Item__c>>();
 for (Line_Item__c lii : liness)
    {
     connection.put(lii.Order_c, liness.get(lii.id)); 
    }


Need to get a list<Line_Item__c> from liness while putting the value into map.
Hi All,

I am having a parent objcet Tree and its child object is Fruit. I need to update the Tree's status to Grown when all the fruits' status of the Tree is changed to Eatable.

Please help me with the trigger logic, or any releted example would help.
Dear All,

I was trying to write test class for my trigger, but it it giving me error like below
'FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, restrictCase: execution of BeforeInsert' , 'FATAL_ERROR caused by: System.NullPointerException: Attempt to de-reference a null object'

heres my trigger
trigger restrictCase on Case(before insert)
{
MaxCase__c mxx = MaxCase__c.getInstance('MaxValue');    
Integer mvv = Integer.valueOf(mxx.Max__c);
    system.debug('int value' + mvv);

Set<Id> userIds = new Set<Id>();

    
for (case cc : Trigger.new)  
{
userIds.add(cc.ownerId);
} 
 
List<User> userss = [Select Id, Name from User where Id in :userIds];  
Map<Id, Integer> userCases = new Map<Id,Integer>(); 
    
for (user u : userss)
{
 integer countCase = [Select count() from Case where ownerId=:u.Id AND createdDate = This_Month];
 userCases.put(u.id, countCase); 
 system.Debug('user and case' + u.Name + ' . ' + countcase);
}
  
for (case c : trigger.new)    
{

Integer countc = userCases.get(c.OwnerId);    
system.debug('current user case count' + countc);    
    if (countc > mvv)
    {
        c.addError('Too many cases created this month for user' + c.owner.Name + '(' + c.OwnerId + ')' + ':' + mvv);
    }
    
}   
    
    
    
}

and heres the test class I've written
 
@isTest

public class testRestrictCase {

 static testMethod void caseCreation1 ()
 {
          MaxCase__c maxi = new MaxCase__c();
     maxi.Name = 'newMax';
     maxi.Max__c = 80;
     insert maxi;
     
     system.debug('maxi custom setting' + maxi.Name);
     Integer maxiInt = Integer.valueOf(maxi.Max__c);
      system.debug('max value' + maxiInt);
     
     
  Account acct = new Account(Name='anamika');   
  insert acct;
     system.debug('account inserted' + acct.name);
 Contact con = new Contact(FirstName='aa', LastName='bb', AccountId=acct.Id, email='abc@g.com');
  insert con;
     system.debug('contact inserted' + con.name);

 List<Case> casess = new List<Case>();
     for(integer i = 0; i<maxiInt ; i++)
     {
    Case TestC = new Case(Subject='Test Controller Acct Case'+ i, accountId=acct.id, status='New', origin ='Email', contactId=con.id, priority='Medium', type='Mechanical', reason='Installation');
     casess.add(Testc); 
system.debug('testC .i.' + TestC.Subject);
 }
   insert casess;
     system.debug('cases size' + casess.size());
     
     Case TestC1 = new Case(Subject='Test Controller Acct Case new', accountId=acct.id, status='New', origin ='Email', contactId=con.id, priority='Medium', type='Mechanical', reason='Installation');

     try{
         insert TestC1;
     }
 catch(DMLException ex)
 {
   system.debug('max cases inserted');  
 }
 
 }
}

​Please help me finding the issue.

Thanks a lot in advance.
Dear all,

I've wrote a trigger which populates Opportunity owner's manager on opportunity. But when saving any opty it is giving me error like 'Apex trigger PopulateOwnerManager caused an unexpected exception, contact your administrator: PopulateOwnerManager: execution of BeforeInsert caused by: System.ListException: List index out of bounds: 0: Trigger.PopulateOwnerManager: line 7, column 1'

PFB code:
 
trigger PopulateOwnerManager on Opportunity (before insert) {
    
  for(Opportunity op : Trigger.new)  
  {
  
  List<Opportunity>  ownr = [Select OwnerId from Opportunity where id = :op.id]; 
      System.debug('oppty ownerId :' + ownr[0].OwnerId);
  List<User> mngr = [Select ManagerId from User where id= :ownr[0].OwnerId];
      System.debug('oppty owner managerID :' + mngr[0].ManagerId);
  op.Owner_s_Manager__c = mngr[0].ManagerId;    
      
      
  }  
    
}

Please help me sorting this out. Thanks in advance.
Dear All,

I've written a test class for my trigger but its not covering one line that is ''   ls.addError  ('duplicate email');    " 
and only 85% ic covered.
PFB the trigger :
 
trigger DeDups on Lead (before insert, before update) {

  for  (Lead ls : Trigger.New)
  { 
   if (ls.Email != Null) 
   {
       
       List<Contact> dups = [SELECT Id from Contact where Email =:ls.Email ];  
       
       if (dups.size() > 0)
       {
           
       ls.addError  ('duplicate email');    
       }       
       
     else  
         
         insert ls;
       
   }

}
}

Here's the test class I've written :
 
@isTest
public class TestDeDups 
{

  static testMethod void  testDeDupsMethod ()
      
  {
      
  List<Contact> conList= New List<Contact>();
     
  Contact c1 = New Contact(FirstName='test', LastName='test', email ='test@xyz.com');   
  Contact c2 = New Contact(FirstName='test2', LastName='test2',  email ='test2@xyz.com'); 
  Contact c3 = New Contact(FirstName='test3', LastName='test3',  email ='test3@xyz.com');  
  conList.add(c1);
  conList.add(c2);
  conList.add(c3);
  

    Lead l1 = New Lead(FirstName='test22', LastName='test4', company='testbhc45b', email ='test@xyz.com');  
  
      try{ Insert l1 ;}
      catch (Exception e)
      {system.debug ('duplicate found');
      }
      
   List<Lead> ld = [SELECT ID from Lead where Email = 'test@xyz.com'];   
 system.assertEquals(0, ld.size());
      
  }
   
}

Please help with 100% code coverage. Thanks in advance :)​
Hii,

I'm trying to answera question on Trailhead, but it keeps giving me an error.

Question is like the below: 

Create a validation rule to check that a contact is in the zip code of its account.
To complete this challenge, add a validation rule which will block the insertion of a contact if the contact is related to an account and has a mailing postal code (which has the API Name MailingPostalCode) different from the account's shipping postal code (which has the API Name ShippingPostalCode).
Name the validation rule 'Contact must be in Account ZIP Code'.
A contact with a MailingPostalCode that has an account and does not match the associated Account ShippingPostalCode should return with a validation error and not be inserted.
The validation rule should ONLY apply to contact records with an associated account. Contact records with no associated parent account can be added with any MailingPostalCode value. (Hint: you can use the ISBLANK function for this check)

The Error I'm getting :

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [MailingPostalCode__c]: [MailingPostalCode__c]


I've written the below V rule:

AND 

NOT(ISBLANK( AccountId )), 
MailingPostalCode__c != Account.ShippingPostalCode__c 
)

If the MailingPostalCode__c wasn't created, It won't allow me to create the V rule on contact with the field MailingPostalCode__c. And also how can the API name be only MailingPostalCode, its always gets concate with __c.
Please help me out.
Thank in advance.


 
Hi Experts,
What is the difference between Clone () and DeepClone() in Apex? When should we use what? Can someone explain with an example?

Thanks!