• bharathsdsd kumar
  • NEWBIE
  • 20 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
Hi,

I am new to salesforce lightening concept , i am trying to perform some DML operations(insert , update) using lightening in my developer org

I would like to have a sample code and its flow for reference

Kindly help me pls

Thanks in advance
Hi,

I have a following method where i am getting

System.null pointer exception : attempt to dereference a null object


Kindly help me how to fix it

This is my method where error occurs
METHOD :

public void CallPremisysQuote(Team_Form__c so)
			{ 
				
				list<Team_Form__c>lstTF = [select ID,Engagement_Script__r.GPS_VRD_Customer__c from Team_Form__c where Id = :so.Id];
				if(TFIdPSQuoteMap.get(so.Id)!= null && TFIdPSQuoteMap.get(so.Id).size()>0)
				{
					PremisysQuoteExist= True;      
				}
				
				if(so.Status__c=='Released to Sales')
				{
					
					if(!PremisysQuoteExist)
					{
						if(lstTF[0].Engagement_Script__r.GPS_VRD_Customer__c.touppercase() == 'NO'){
							
							if(so.PS_Engagement_Type__c=='New Order')
							{ 
								
								GPS_Premisys_CreateQuote.fnCreatePremisysQuote(so.Id);
							}
							
							else
							{
								if(so.GPS_Price_Impacting__c=='Yes')
								{
									
									GPS_Premisys_CreateQuote.fnCreatePremisysQuote(so.Id);                 
								}              
								
							}
						}
                /*else{
so.addError('PremiSys quote cannot be created for VRD customers. The sales team has chosen this option on the Engagement Script');        
}*/
            }      
        }

Kindly help me pls

Thanks in Advance
Hi,

I have the following class where i am trying to write test class for it which covers only 35% , i am wondering how to cover the following lines , Kindly help me pls

 
MY APEX CLASS :


public class IarCloneAttachment implements Queueable {
	public Id attachmentId;
	public Id newParentId;
	public Set<String> oldIdList;
	public Map<String,String> oldParentId_newParentId_Map;
	public IarCloneAttachment() {
		
	}

	public void execute(QueueableContext context) {
		cloneAttachments();
	}

	public void cloneAttachments() {
        SkipingHelper.skipTriggerIARAttachmentTrigger  = true;
        SkipingHelper.SkippAllTriggersFromAttachment();
        for(Attachment attch :[SELECT Id,ParentId,BodyLength  FROM Attachment WHERE ParentId in:oldIdList]) {
            System.debug('Attachment xxx Heap Size:'+Limits.getHeapSize() + ' Limit:'+Limits.getLimitHeapSize());
        	System.debug('Attachment xxx Id:' + attch.Id + ' size:' + attch.BodyLength);
        	//Note: The following SOQL is inside a for loop. This is by design. Retrieving all the attachments in one soql will throw the heap size limit error.
			List<Attachment> attachmentList = [SELECT Body,ParentId,CreatedDate,ContentType,OwnerId,CreatedById,LastModifiedDate,IsPrivate,Description,Name,LastModifiedById FROM Attachment WHERE Id=:attch.Id];
			if (attachmentList.size()>0) {
				Attachment sAttachment = attachmentList[0].clone(false);
				sAttachment.ParentId = oldParentId_newParentId_Map.get(attachmentList[0].ParentId);
				sAttachment.ownerId = attachmentList[0].OwnerId;
				insert sAttachment;
				sAttachment.Body = null;
            }
        }
	}
}
MY TEST CLASS :

@isTest
public class IarCloneAttachment_Test {  
    static testmethod void IarCloneAttachment_TestMethod()
    {
        User Uu3 = IARTestUtilities.createStandardUser('WrkTs');
        System.RunAs(Uu3) {
            IARTestUtilities.createCustomSettingsForPRMSFDCVDMSGSAM();            
            Account acc = IARTestUtilities.createTestAccount();  
            system.debug('acc:'+acc); 
            
            Opportunity op = IARTestUtilities.createTestOpportunity(acc.id);                     
            system.debug('op:'+op);
            
            Test.startTest();
            IAR_Main__c IAR = IARTestUtilities.createNewTestIARwithSHForms(acc.Id,op.id,'EMS');        
            system.debug('IAR:'+IAR);
            
            
            Blob b = Blob.valueOf('Test Data');
            Attachment attachment = new Attachment();
            attachment.ParentId = acc.Id;
            attachment.Name = 'TestAttachmentforParent.xls';
            attachment.Body = b;
            insert(attachment);
            List<Attachment> attachmentList = new List<Attachment>();
            attachmentList.add(attachment);
            Set<String> oldIdList = new set<String>();
            oldIdList.add('attachment');

            Test.stopTest();  
            IarCloneAttachment iarc = new IarCloneAttachment();
            iarc.cloneAttachments();
            
        }
    }
}
LINES NOT GETTING COVERED:


public void execute(QueueableContext context) {
		cloneAttachments();
	}






**********************************************************************

List<Attachment> attachmentList = [SELECT Body,ParentId,CreatedDate,ContentType,OwnerId,CreatedById,LastModifiedDate,IsPrivate,Description,Name,LastModifiedById FROM Attachment WHERE Id=:attch.Id];
			if (attachmentList.size()>0) {
				Attachment sAttachment = attachmentList[0].clone(false);
				sAttachment.ParentId = oldParentId_newParentId_Map.get(attachmentList[0].ParentId);
				sAttachment.ownerId = attachmentList[0].OwnerId;
				insert sAttachment;
				sAttachment.Body = null;

Kindly help me how to cover those lines pls

Thanks in Advance

 
Hi ,

I am trying to write a batch class for the following the below condition

Please create a new batch class for M2M_Activation_Status__c object. Below is the logic that is needed.
- Query records where Order Number(Order_Number__c) is not blank and Activation complete(Activation_Complete__c) is false


Kindly help me with the code pls

Thanks in Advance
Hi,

I have a following method where i am getting

System.null pointer exception : attempt to dereference a null object


Kindly help me how to fix it

This is my method where error occurs
METHOD :

public void CallPremisysQuote(Team_Form__c so)
			{ 
				
				list<Team_Form__c>lstTF = [select ID,Engagement_Script__r.GPS_VRD_Customer__c from Team_Form__c where Id = :so.Id];
				if(TFIdPSQuoteMap.get(so.Id)!= null && TFIdPSQuoteMap.get(so.Id).size()>0)
				{
					PremisysQuoteExist= True;      
				}
				
				if(so.Status__c=='Released to Sales')
				{
					
					if(!PremisysQuoteExist)
					{
						if(lstTF[0].Engagement_Script__r.GPS_VRD_Customer__c.touppercase() == 'NO'){
							
							if(so.PS_Engagement_Type__c=='New Order')
							{ 
								
								GPS_Premisys_CreateQuote.fnCreatePremisysQuote(so.Id);
							}
							
							else
							{
								if(so.GPS_Price_Impacting__c=='Yes')
								{
									
									GPS_Premisys_CreateQuote.fnCreatePremisysQuote(so.Id);                 
								}              
								
							}
						}
                /*else{
so.addError('PremiSys quote cannot be created for VRD customers. The sales team has chosen this option on the Engagement Script');        
}*/
            }      
        }

Kindly help me pls

Thanks in Advance
Hi ,

I am trying to write a batch class for the following the below condition

Please create a new batch class for M2M_Activation_Status__c object. Below is the logic that is needed.
- Query records where Order Number(Order_Number__c) is not blank and Activation complete(Activation_Complete__c) is false


Kindly help me with the code pls

Thanks in Advance