• Abhishek Singh 88
  • NEWBIE
  • 188 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 45
    Questions
  • 63
    Replies
Hi All,
I have query in for loop.I tried it to pull out side but it is not behaving properly. It is not updating respective record properly if take query out of loop.here is my code.
for(BMCServiceDesk__BMC_BaseElement__c berec:childCis)
        {       
             
               for(BMCServiceDesk__BMC_BaseRelationship__c brrec:sourcedestinationlist)
               {    
		            
                      if(brrec.BMCServiceDesk__Destination_ClassName__c=='BMC_Application')
						  
                          besourceid.add(brrec.BMCServiceDesk__Destination__c);
                   
               }
                   baseapplist=[select id,name,HITRUST__c,PCI__c,PHI__c,Fisma_High_New__c,Fisma_Low_New__c,Fisma_Mod_New__c,SOC__c,SOC2__c,SOX__c,Environment__c,UAR__c,BMCServiceDesk__ClassName__c from BMCServiceDesk__BMC_BaseElement__c where ID IN:besourceid];
			   
                   for(BMCServiceDesk__BMC_BaseElement__c baseapp:baseapplist)
                     {
                              if(baseapp.HITRUST__c)
                                  
                                  flag1=true;
                     }
				   for(BMCServiceDesk__BMC_BaseElement__c basebe:newbelist1)
                     {
						 
                        if(oldbelist1.get(basebe.id).HITRUST__c!=basebe.HITRUST__c && basebe.HITRUST__c==false)
                        {
                            if(flag1)
                            {
								
                              berec.HITRUST__c=true; 
                            }
                              else{
                                     berec.HITRUST__c=false;
                                }
                              baseelementlist.add(berec);								
		}}}

baseapplist is inside for loop. Want to keep outside of loop.
Thanks.
Hi All, 
Trigger recursion is still persisting , i have used static variable though. here is code snippet.
public void decommising(List<BMCServiceDesk__BMC_BaseElement__c> newbelist,map<id,BMCServiceDesk__BMC_BaseElement__c> oldbelist)
    {    
       
           for(BMCServiceDesk__BMC_BaseElement__c be:newbelist)
        {
            beid.add(be.id);
        }
if(CheckRecursive.cmdbserver1==false)
{
           serverdecommission(newbelist,oldbelist);
    }
}
public void serverdecommission(List<BMCServiceDesk__BMC_BaseElement__c> newbelist1,map<id,BMCServiceDesk__BMC_BaseElement__c> oldbelist1)
for(BMCServiceDesk__BMC_BaseElement__c berec:childCis)//related base element record could be source or destination
        {
//putting relationship for ci's in map, to get id of cis level 2.
              if(destinationmap1.get(berec.id)!=null)
              destinationList.addAll(destinationmap1.get(berec.id));
               system.debug('destinationList'+destinationList);
               if(sourcemap1.get(berec.id)!=null)
               sourceList.addAll(sourcemap1.get(berec.id));
                system.debug('sourceList'+sourceList);
                if(sourceList.size()>0)
                sourcedestinationlist.addAll(sourceList);
                  if(destinationList.size()>0)
                sourcedestinationlist.addAll(destinationList);
               system.debug('sourcedestinationlist'+sourcedestinationlist);
               for(BMCServiceDesk__BMC_BaseRelationship__c brrec:sourcedestinationlist)
               {
                   if(brrec.BMCServiceDesk__Source_ClassName__c=='BMC_Application')
                       besourceid.add(brrec.BMCServiceDesk__Source__c);
                      if(brrec.BMCServiceDesk__Destination_ClassName__c=='BMC_Application')
                          besourceid.add(brrec.BMCServiceDesk__Destination__c);
                   
               }
               if(besourceid.size()>0)
                   baseapplist=[select id,name,HITRUST__c,PCI__c,PHI__c,Fisma_High_New__c,Fisma_Low_New__c,Fisma_Mod_New__c,SOC__c,SOC2__c,SOX__c,Environment__c,UAR__c,BMCServiceDesk__ClassName__c from BMCServiceDesk__BMC_BaseElement__c where ID IN:besourceid];
                   system.debug('baseapplist'+baseapplist);
                   
                   for(BMCServiceDesk__BMC_BaseElement__c baseapp:baseapplist)
                     {
                              if(baseapp.HITRUST__c)
                                  
                                  flag1=true;
                     }
                     for(BMCServiceDesk__BMC_BaseElement__c basebe:newbelist1)
                     {
                        if(oldbelist1.get(basebe.id).HITRUST__c!=basebe.HITRUST__c && basebe.HITRUST__c==false)
                        {
                            if(flag1)
                            {
                              berec.HITRUST__c=true;  
                            }
                              else{
                                     berec.HITRUST__c=false;
                                }                           
                     }
                     }
        baseelementlist.add(berec); 
        }
basemap.putAll(baseelementlist);
        system.debug('base map'+basemap.values());
           if (basemap.size()>0)
           {
              update basemap.values();
            CheckRecursive.cmdbserver1=true;
 
               system.debug(basemap);
              }   
    }

Any help would be appriciated.
Hi all,
My trigger is being called twice, even I have used a static variable. Please find the class.
public void decommissioning(List<Incident>newlist,map<id,incident>oldmap) 
{
      if(checkrecursive.run==true)
 {
       serverdecomissioning(newlist,oldmap);
    checkrecursive.run=false;
}
}
public void serverdecomissioning(List<Incident>newlist1,map<id,incident>oldmap1)
{
//code
}

 
Hi developer,
I have a doubt regarding to filtering the SOQL query.
I have a three set of id's that is:
Set<id> source;
Set<id>destination;
Set<id> sharedserver;(contains id of source and destination as well)
I have wrote query 
baselist=[select id ,name from base element where id in:sharedserver And( not in:source And not in: destination)]

but its not giving exact output. Can anyone help me out?
Thanks.
Hi All, I have queried parent object through child . and want to update parent object with some values. Here is query.
List<BMC_Servicedesk_BaseElement> belist=new List<BMC_Servicedesk_BaseElement>();
belist=[select name, Fisma_Low,Fisma_High from BMC_Servicedesk_BaseElement ];
List<BMC_Servicedesk_BaseRelationShip> bsrelation=new List<BMC_Servicedesk_BaseRelationShip> ();
List<BMC_Servicedesk_BaseRelationShip> bsrelation1=new List<BMC_Servicedesk_BaseRelationShip> ();
bsrelation=[select name, Destination__r.Hitrust,Destination__r.Fisma_Low,Destination__r.Fisma_High from BMC_Servicedesk_BaseRelationShip];
for(BMC_Servicedesk_BaseElement be: belist)
{
   for(BMC_Servicedesk_BaseRelationShip berel:bsrelation)
  {
     if(be.Fisma_Low==true)
  berel.Destination__r.Fisma_Low=be.Fisma_Low;
   bsrelation1.add(berel);
}
}
update bsrelation1;
//Note Base Relationship has two lookup filed with same object Base Element As destination__c and Source__c
Hi All,

I have a formula field called as "Number of days breached" which have formula
RCA_dueDate__c-NOW()
I want this formula should run only when RCA status is apprved somthing like this
IF(RCA_status='Approved',RCA_dueDate__c-NOW(),do nothing)

i tried this way
IF(RCA_status='Approved',RCA_dueDate__c-NOW(),Number_of_Brached_days__c)

But it gave error.

Any help would be appriciated​​​​​​​
 
Hi All,

I have below data in Description Field of incident.

Application: Oracle eBusiness Suite (eBS)
Change Driver: Migration
Change Category: New scripts
Is this Change part of a Project?: Yes
Non-Technical Reason for Change?: Importing Fieldglass invoices programatically
Do we need a WebEx?: No
Why is WebEx NOT Required?: It is a new component. And all the details are discussed with the functional team.
WebEx/Bridge Information: 
Number of Users Affected: Internal – None
Worst Case if not Implemented: Oracle might not able to import fieldglass invoices
End user experience if Change fails: Oracle might not able to import fieldglass invoices
End User Experience during Change: Once change implemented successfully. User might able to import fieldglass invoice

I want to parse it and want to store only bold text(Number of Users Affected)

Any Suggestion would be appriciated
Hi All,
I have a vf page which have two radio button Yes or No. I want selected value in constructor after clicking on submit buton.
here is code.
<apex:page controller="CCO_ScheduleACallController">
<apex:form >
<apex:pageBlock >
<apex:outputLabel style="Bold">Are you able to launch your software or service?</apex:outputLabel>
<apex:selectRadio value="{!radiovalue}">
          <apex:selectOption itemLabel="Yes" itemValue="1"></apex:selectOption>
          <apex:selectOption itemLabel="No" itemValue="2"></apex:selectOption>
      </apex:selectRadio>
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!Submit}" value="Submit"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

Since in the exisitng contrroler most of the logic is implemented in constructor. And now i have to add condition
IF(selected value=='Yes')
{
//code
}
else
{
// code
}
Hi everyone,
I want to create a picklist on a visualforce page , And the values of picklist should be values in a List.
Eg. I have a list called "CCO_producttype". And now on the VF page i want to display Values(CCO_producttype) in a dropdown format.
How would i approach. Any suggestion on this would be highly appriciated.
There are some users which have "Automatically add my default opportunity team to opportunities that I create or open opportunities that are transferred to me" check box is true .So as soon as they create opportunity opportunity team member gets created. Is there any way where we can create an user with this capability in test class.
Thanks.
Hi All,
I have written a small trigger on opportunity.Which is updating field 'opportunity sales Leader' with the user in opportunity team member.Here is trigger.
trigger UpdateOpportunity on Opportunity (after insert) 
{
    Set<Id> setOfOppty = new Set<Id>();
    List<Opportunity> listOfOpptyToUpdate = new List<Opportunity>();
    for(Opportunity opp : Trigger.New){
        if(opp != null && (opp.RecordTypeId == Label.Oppty_Record_Type_ISV || opp.RecordTypeId == Label.Oppty_Record_Type_OEM || opp.RecordTypeId == Label.Oppty_Record_Type_Wholesale || opp.RecordTypeId == Label.Oppty_Record_Type_xSP)){
            setOfOppty.add(opp.Id);
        }
    }
    List<OpportunityTeamMember> listOTM = new List<OpportunityTeamMember>([SELECT Id, UserId, OpportunityId, User.Name FROM OpportunityTeamMember WHERE OpportunityId in :setOfOppty AND TeamMemberRole = :Label.Opportunity_Sales_Leader]);
    for(OpportunityTeamMember otmObj: listOTM){
        
        if(otmObj != null && otmObj.UserId!=null && otmObj.OpportunityId != null){
            Opportunity opp = new Opportunity(Id = otmObj.OpportunityId, Opportunity_Team_Member_Sales_Leader__c = otmObj.UserId);
            listOfOpptyToUpdate.add(opp);
        }
    }   
    if(!listOfOpptyToUpdate.IsEmpty()){
        Database.SaveResult[] saveResultList = Database.update(listOfOpptyToUpdate,false);
        for(Database.SaveResult svResult : saveResultList){
            if(!svResult.isSuccess()){                
                system.debug('Error::'+svResult);
                break;
            }
        }
    }
}

And Here Is Test clas.;
@Istest(SeeAllData=false)
Private class Test_opportunity 
{
     public static testmethod void testOpportunity()
     {   
         //ProId = [SELECT Id FROM Profile WHERE Name = 'Consumer Sales Ops'].Id;
         User user = new User();
        
        user.FirstName = 'Test';
        user.LastName = 'Name';
        user.CompanyName = 'IT Test Company';
        user.MobilePhone = '123-456-7890';
        
        user.Username = 'testUser-' + '@test.com';
        user.Email = 'testUser-' +'@test.com';
  user.Alias = 'test';
        user.CommunityNickname = 'test1';
        user.TimeZoneSidKey = 'America/New_York';
        user.LocaleSidKey = 'en_US';
        user.EmailEncodingKey = 'UTF-8';
        user.ProfileId = '00e1I000000Veel';
        user.LanguageLocaleKey = 'en_US';
        
        user.Street = '123 Test St';
        user.City = 'Testcity';
        user.State = 'va';
        user.PostalCode = '23223';
        user.Country = 'USA';
        
        insert user;
         Date myDate = Date.today();
         Opportunity opp=new opportunity();
         opp.RecordTypeId='0122F0000004ot9';
         opp.name='test opp';
         opp.AccountId='0012F00000EXcyQ';
         opp.CurrencyIsoCode='AED';
         opp.CloseDate= myDate;
         opp.StageName='Identification';
         opp.Opportunity_Team_Member_Sales_Leader__c=user.Id;
         insert opp;
         OpportunityTeamMember opptyteam=new OpportunityTeamMember();
         opptyteam.opportunityId=opp.Id;
         opptyteam.TeamMemberRole='Sales Leader';
         opptyteam.UserId=user.Id;
         insert opptyteam;
         opp.Opportunity_Team_Member_Sales_Leader__c = opptyteam.UserId;
         update opp;
         
     }
}

But its covering only 53 %
if(otmObj != null && otmObj.UserId!=null && otmObj.OpportunityId != null){
            Opportunity opp = new Opportunity(Id = otmObj.OpportunityId, Opportunity_Team_Member_Sales_Leader__c = otmObj.UserId);
            listOfOpptyToUpdate.add(opp);
        }

this if condition and also error statment is not been covered.any suggestion on this would be really help full
Hi Developers.
I have written a trigger to update a lookup field in an object i.e. Incident. once field is updated based on that i have implemented a workflow which have email alert action.But i could see that field is being updated but the workflow is triggering even the entry criteria is matching..

Any help would be appriciated.
Hi Developers,
I am trying to trace some class but in debug it is showing somthing like this

User-added image

How can i view those 4 entries.
Any help would be appriciated.
Hi Developers,
I am Facing strange issue. My class has 94% code coverage, i checked in eclipse as well. but while deploying this class it shows code coverage failure, only  61% code coverage, Even though i used RUN specified tests option.

Any help on this will be appriciated.
Hi Developer,
I want to trace an apex class let say class A. Basically it is an email service. When i am sending an email to particular email service address,Class A should invoke but it's not happening. To trace the class i have ganereted debug log for user as myself.
But i am not getting any entry in debug log. Wheareas for other email service i am getting debug log.

Any Help would be appriciated. 
Hi Developers,
I have written test class but it is not covering catch block.
APex class is here.
try
               {  
                 
                   history.Status__c='success';
                   history.Description__c=myPlainText;
                   //if(newIncident !=null)
                   history.Incident__c=newIncident.ID;
                   if(user != null && user.size() > 0)
                   history.account__c=user[0].BMCServiceDesk__Account_Name__c;
                   //emailhistory.add(history);
                   insert history;
               }
               catch(Exception ex){
      myPlainText = '';
      RF_Exception_Util.createException('McKesson','handleInboundEmail','McKessonNewIncidentCreation',ex.getMessage(),null);
    }

RF_Exception_Util is a class and createException is a static method. from here we are storing exception in some custom object.
Any suggestion will be appriciated.
Hi developers,
Here i have written a class, which is inserting an incident and after insertion i am trying put id of that incident in another child object
BMCServiceDesk__Incident__c newincident= new BMCServiceDesk__Incident__c();
newincident.Name='Wellspan';
newincident.description__c='Test cases.'
insert newincident;
// second object related as lookup, incident__c is field related to it.
email_to_incident_history__c emailincident=new email_to_incident_history__c();
emailincident.incident__c=newincident.Name;
insert emailincident;
But it is throwing an error, saying invalid id.
 
Hi Developers.
Here i have written a class
Global class Email_History_schedule implements system.Schedulable
{
     global void execute(SchedulableContext sc)
     {
         try
         {
            List<Email_to_incident_History__c>emailtoincident=new List<Email_to_incident_History__c>();
             for(Email_to_incident_History__c einci:[select id from Email_to_incident_History__c])
             {
                 emailtoincident.add(einci);
             }
             delete emailtoincident;
             system.debug('Email history List'+emailtoincident);
         }
         catch(exception ex)
         {
             
         }
     }
}

And here is my test class
@istest
public class Email_History_schedule_Test 
{
   public static testMethod void testschedule() {
Test.StartTest();
Email_to_incident_History__c abc= new Email_to_incident_History__c();
abc.account__c='Mckesson';
abc.Description__c='Success';
insert abc;
List<Email_to_incident_History__c> emailto=new List<Email_to_incident_History__c>();
 emailto.add(abc);
 delete emailto;
 Email_History_schedule sh1 = new Email_History_schedule();
String sch = '0 0 23 * * ?';
system.schedule('CHS SR Report', sch, sh1);
Test.stopTest();
}   
}

But it is covering only 62%.
This line is not been covered
{
                 emailtoincident.add(einci);

 
Hi Developers,
I have writtent code where i am checking that object__c have any duplicate value in text area field.I have written bellow code
if( ( email.subject.containsIgnoreCase('Ticket#') || email.subject.containsIgnoreCase('Ticket #') || email.subject.containsIgnoreCase('Incident#') || email.subject.containsIgnoreCase('Incident #') ) && email.subject.contains('[')){
        ticketid = email.Subject.substring(email.Subject.indexOf('[')+1, email.Subject.indexOf(']'));
      }else if(email.subject.containsIgnoreCase('Ref:IN:')){
        ticketid = email.subject.substring(email.Subject.indexOf('IN:')+3,email.Subject.indexOf(')'));
      }
      List<BMCServiceDesk__Incident__c> newinci=new List<BMCServiceDesk__Incident__c>();
      system.debug('trying to insert ticket values');
      for(BMCServiceDesk__Incident__c inci:[select id,BMCServiceDesk__EmailServiceAddress__c from BMCServiceDesk__Incident__c])
      {
          if (inci.BMCServiceDesk__EmailServiceAddress__c.contains(ticketid))
          {
              newinci.add(inci);
              system.debug('ticket id added to incident');
          }
      }
it showing  Attempt to de-reference a null object error 
for this one
for(BMCServiceDesk__Incident__c inci:[select id,BMCServiceDesk__EmailServiceAddress__c from BMCServiceDesk__Incident__c])
      {
          if (inci.BMCServiceDesk__EmailServiceAddress__c.contains(ticketid))
          {
              newinci.add(inci);
              system.debug('ticket id added to incident');
          }
}

Any help will be appriciated.
Hi Developers.

i have writtent few code to test that whether sms api is working properly.Here is my code.
 
String username = '************' ;
            String password = '**********************';
            String message= 'Hi this msg. is for testing of "sending msg.on mobile when SLA breach"';
             HttpRequest req = new HttpRequest();
            req.setEndpoint('https://api.us1.corvisa.io/sms/');
            req.setMethod('POST'); 
            String phonenumber='+15123355101';
           "+15123355101"}';
            
            String body= '[{"from_number": "","messages": [{"text":  "text of message","to_number": "+15551239876"}]}]';
            //String jsonbody= json.serializePretty(body);
            Blob headerValue = Blob.valueOf(username + ':' + password);
            String authorizationHeader = 'Basic ' +  EncodingUtil.base64Encode(headerValue);
                 req.setHeader('Authorization', authorizationHeader);
                 req.setHeader('Content-Type','application/json');
                 HTTPResponse res= new HTTPResponse();
                 req.setBody(body); 
                 system.debug(req.getBody());
                 //req.setBody(jsonbody);
                 Http http = new Http();
                 //res.setStatusCode(200);
                 res = http.send(req);
                 system.debug(res.toString());
                  system.debug(res.getBody());

the format of body i copied from respective vendor's portal. format is mention like.
[
    {
        "from_number": "+15554447001",
        "messages": [
            {
                "text":  "text of message",
                "to_number": "+15551239876",
                
            }
        ]
    }
]

But when i looked at debug log is showing some error.
User-added image


Any suggestion will be appriciated.
Hi All,
I have query in for loop.I tried it to pull out side but it is not behaving properly. It is not updating respective record properly if take query out of loop.here is my code.
for(BMCServiceDesk__BMC_BaseElement__c berec:childCis)
        {       
             
               for(BMCServiceDesk__BMC_BaseRelationship__c brrec:sourcedestinationlist)
               {    
		            
                      if(brrec.BMCServiceDesk__Destination_ClassName__c=='BMC_Application')
						  
                          besourceid.add(brrec.BMCServiceDesk__Destination__c);
                   
               }
                   baseapplist=[select id,name,HITRUST__c,PCI__c,PHI__c,Fisma_High_New__c,Fisma_Low_New__c,Fisma_Mod_New__c,SOC__c,SOC2__c,SOX__c,Environment__c,UAR__c,BMCServiceDesk__ClassName__c from BMCServiceDesk__BMC_BaseElement__c where ID IN:besourceid];
			   
                   for(BMCServiceDesk__BMC_BaseElement__c baseapp:baseapplist)
                     {
                              if(baseapp.HITRUST__c)
                                  
                                  flag1=true;
                     }
				   for(BMCServiceDesk__BMC_BaseElement__c basebe:newbelist1)
                     {
						 
                        if(oldbelist1.get(basebe.id).HITRUST__c!=basebe.HITRUST__c && basebe.HITRUST__c==false)
                        {
                            if(flag1)
                            {
								
                              berec.HITRUST__c=true; 
                            }
                              else{
                                     berec.HITRUST__c=false;
                                }
                              baseelementlist.add(berec);								
		}}}

baseapplist is inside for loop. Want to keep outside of loop.
Thanks.
Hi all,
My trigger is being called twice, even I have used a static variable. Please find the class.
public void decommissioning(List<Incident>newlist,map<id,incident>oldmap) 
{
      if(checkrecursive.run==true)
 {
       serverdecomissioning(newlist,oldmap);
    checkrecursive.run=false;
}
}
public void serverdecomissioning(List<Incident>newlist1,map<id,incident>oldmap1)
{
//code
}

 
Hi All, I have queried parent object through child . and want to update parent object with some values. Here is query.
List<BMC_Servicedesk_BaseElement> belist=new List<BMC_Servicedesk_BaseElement>();
belist=[select name, Fisma_Low,Fisma_High from BMC_Servicedesk_BaseElement ];
List<BMC_Servicedesk_BaseRelationShip> bsrelation=new List<BMC_Servicedesk_BaseRelationShip> ();
List<BMC_Servicedesk_BaseRelationShip> bsrelation1=new List<BMC_Servicedesk_BaseRelationShip> ();
bsrelation=[select name, Destination__r.Hitrust,Destination__r.Fisma_Low,Destination__r.Fisma_High from BMC_Servicedesk_BaseRelationShip];
for(BMC_Servicedesk_BaseElement be: belist)
{
   for(BMC_Servicedesk_BaseRelationShip berel:bsrelation)
  {
     if(be.Fisma_Low==true)
  berel.Destination__r.Fisma_Low=be.Fisma_Low;
   bsrelation1.add(berel);
}
}
update bsrelation1;
//Note Base Relationship has two lookup filed with same object Base Element As destination__c and Source__c
Hi All,

I have a formula field called as "Number of days breached" which have formula
RCA_dueDate__c-NOW()
I want this formula should run only when RCA status is apprved somthing like this
IF(RCA_status='Approved',RCA_dueDate__c-NOW(),do nothing)

i tried this way
IF(RCA_status='Approved',RCA_dueDate__c-NOW(),Number_of_Brached_days__c)

But it gave error.

Any help would be appriciated​​​​​​​
 
Hi everyone,
I want to create a picklist on a visualforce page , And the values of picklist should be values in a List.
Eg. I have a list called "CCO_producttype". And now on the VF page i want to display Values(CCO_producttype) in a dropdown format.
How would i approach. Any suggestion on this would be highly appriciated.
Hi All,
I have written a small trigger on opportunity.Which is updating field 'opportunity sales Leader' with the user in opportunity team member.Here is trigger.
trigger UpdateOpportunity on Opportunity (after insert) 
{
    Set<Id> setOfOppty = new Set<Id>();
    List<Opportunity> listOfOpptyToUpdate = new List<Opportunity>();
    for(Opportunity opp : Trigger.New){
        if(opp != null && (opp.RecordTypeId == Label.Oppty_Record_Type_ISV || opp.RecordTypeId == Label.Oppty_Record_Type_OEM || opp.RecordTypeId == Label.Oppty_Record_Type_Wholesale || opp.RecordTypeId == Label.Oppty_Record_Type_xSP)){
            setOfOppty.add(opp.Id);
        }
    }
    List<OpportunityTeamMember> listOTM = new List<OpportunityTeamMember>([SELECT Id, UserId, OpportunityId, User.Name FROM OpportunityTeamMember WHERE OpportunityId in :setOfOppty AND TeamMemberRole = :Label.Opportunity_Sales_Leader]);
    for(OpportunityTeamMember otmObj: listOTM){
        
        if(otmObj != null && otmObj.UserId!=null && otmObj.OpportunityId != null){
            Opportunity opp = new Opportunity(Id = otmObj.OpportunityId, Opportunity_Team_Member_Sales_Leader__c = otmObj.UserId);
            listOfOpptyToUpdate.add(opp);
        }
    }   
    if(!listOfOpptyToUpdate.IsEmpty()){
        Database.SaveResult[] saveResultList = Database.update(listOfOpptyToUpdate,false);
        for(Database.SaveResult svResult : saveResultList){
            if(!svResult.isSuccess()){                
                system.debug('Error::'+svResult);
                break;
            }
        }
    }
}

And Here Is Test clas.;
@Istest(SeeAllData=false)
Private class Test_opportunity 
{
     public static testmethod void testOpportunity()
     {   
         //ProId = [SELECT Id FROM Profile WHERE Name = 'Consumer Sales Ops'].Id;
         User user = new User();
        
        user.FirstName = 'Test';
        user.LastName = 'Name';
        user.CompanyName = 'IT Test Company';
        user.MobilePhone = '123-456-7890';
        
        user.Username = 'testUser-' + '@test.com';
        user.Email = 'testUser-' +'@test.com';
  user.Alias = 'test';
        user.CommunityNickname = 'test1';
        user.TimeZoneSidKey = 'America/New_York';
        user.LocaleSidKey = 'en_US';
        user.EmailEncodingKey = 'UTF-8';
        user.ProfileId = '00e1I000000Veel';
        user.LanguageLocaleKey = 'en_US';
        
        user.Street = '123 Test St';
        user.City = 'Testcity';
        user.State = 'va';
        user.PostalCode = '23223';
        user.Country = 'USA';
        
        insert user;
         Date myDate = Date.today();
         Opportunity opp=new opportunity();
         opp.RecordTypeId='0122F0000004ot9';
         opp.name='test opp';
         opp.AccountId='0012F00000EXcyQ';
         opp.CurrencyIsoCode='AED';
         opp.CloseDate= myDate;
         opp.StageName='Identification';
         opp.Opportunity_Team_Member_Sales_Leader__c=user.Id;
         insert opp;
         OpportunityTeamMember opptyteam=new OpportunityTeamMember();
         opptyteam.opportunityId=opp.Id;
         opptyteam.TeamMemberRole='Sales Leader';
         opptyteam.UserId=user.Id;
         insert opptyteam;
         opp.Opportunity_Team_Member_Sales_Leader__c = opptyteam.UserId;
         update opp;
         
     }
}

But its covering only 53 %
if(otmObj != null && otmObj.UserId!=null && otmObj.OpportunityId != null){
            Opportunity opp = new Opportunity(Id = otmObj.OpportunityId, Opportunity_Team_Member_Sales_Leader__c = otmObj.UserId);
            listOfOpptyToUpdate.add(opp);
        }

this if condition and also error statment is not been covered.any suggestion on this would be really help full
Hi Developers,
I am trying to trace some class but in debug it is showing somthing like this

User-added image

How can i view those 4 entries.
Any help would be appriciated.
Hi Developers,
I am Facing strange issue. My class has 94% code coverage, i checked in eclipse as well. but while deploying this class it shows code coverage failure, only  61% code coverage, Even though i used RUN specified tests option.

Any help on this will be appriciated.
Hi Developers,
I have written test class but it is not covering catch block.
APex class is here.
try
               {  
                 
                   history.Status__c='success';
                   history.Description__c=myPlainText;
                   //if(newIncident !=null)
                   history.Incident__c=newIncident.ID;
                   if(user != null && user.size() > 0)
                   history.account__c=user[0].BMCServiceDesk__Account_Name__c;
                   //emailhistory.add(history);
                   insert history;
               }
               catch(Exception ex){
      myPlainText = '';
      RF_Exception_Util.createException('McKesson','handleInboundEmail','McKessonNewIncidentCreation',ex.getMessage(),null);
    }

RF_Exception_Util is a class and createException is a static method. from here we are storing exception in some custom object.
Any suggestion will be appriciated.
Hi developers,
Here i have written a class, which is inserting an incident and after insertion i am trying put id of that incident in another child object
BMCServiceDesk__Incident__c newincident= new BMCServiceDesk__Incident__c();
newincident.Name='Wellspan';
newincident.description__c='Test cases.'
insert newincident;
// second object related as lookup, incident__c is field related to it.
email_to_incident_history__c emailincident=new email_to_incident_history__c();
emailincident.incident__c=newincident.Name;
insert emailincident;
But it is throwing an error, saying invalid id.
 
Hi Developers.
Here i have written a class
Global class Email_History_schedule implements system.Schedulable
{
     global void execute(SchedulableContext sc)
     {
         try
         {
            List<Email_to_incident_History__c>emailtoincident=new List<Email_to_incident_History__c>();
             for(Email_to_incident_History__c einci:[select id from Email_to_incident_History__c])
             {
                 emailtoincident.add(einci);
             }
             delete emailtoincident;
             system.debug('Email history List'+emailtoincident);
         }
         catch(exception ex)
         {
             
         }
     }
}

And here is my test class
@istest
public class Email_History_schedule_Test 
{
   public static testMethod void testschedule() {
Test.StartTest();
Email_to_incident_History__c abc= new Email_to_incident_History__c();
abc.account__c='Mckesson';
abc.Description__c='Success';
insert abc;
List<Email_to_incident_History__c> emailto=new List<Email_to_incident_History__c>();
 emailto.add(abc);
 delete emailto;
 Email_History_schedule sh1 = new Email_History_schedule();
String sch = '0 0 23 * * ?';
system.schedule('CHS SR Report', sch, sh1);
Test.stopTest();
}   
}

But it is covering only 62%.
This line is not been covered
{
                 emailtoincident.add(einci);

 
Hi Developers,
I have writtent code where i am checking that object__c have any duplicate value in text area field.I have written bellow code
if( ( email.subject.containsIgnoreCase('Ticket#') || email.subject.containsIgnoreCase('Ticket #') || email.subject.containsIgnoreCase('Incident#') || email.subject.containsIgnoreCase('Incident #') ) && email.subject.contains('[')){
        ticketid = email.Subject.substring(email.Subject.indexOf('[')+1, email.Subject.indexOf(']'));
      }else if(email.subject.containsIgnoreCase('Ref:IN:')){
        ticketid = email.subject.substring(email.Subject.indexOf('IN:')+3,email.Subject.indexOf(')'));
      }
      List<BMCServiceDesk__Incident__c> newinci=new List<BMCServiceDesk__Incident__c>();
      system.debug('trying to insert ticket values');
      for(BMCServiceDesk__Incident__c inci:[select id,BMCServiceDesk__EmailServiceAddress__c from BMCServiceDesk__Incident__c])
      {
          if (inci.BMCServiceDesk__EmailServiceAddress__c.contains(ticketid))
          {
              newinci.add(inci);
              system.debug('ticket id added to incident');
          }
      }
it showing  Attempt to de-reference a null object error 
for this one
for(BMCServiceDesk__Incident__c inci:[select id,BMCServiceDesk__EmailServiceAddress__c from BMCServiceDesk__Incident__c])
      {
          if (inci.BMCServiceDesk__EmailServiceAddress__c.contains(ticketid))
          {
              newinci.add(inci);
              system.debug('ticket id added to incident');
          }
}

Any help will be appriciated.
here i have a table
User-added image
so after clicking on customer id i have to show related records.so for that i have implemented pagination.
here is my apex class:
public ApexPages.StandardSetController setCon //pagignation for customer incident
                     {
                       get{
                        if(setcon==null)
                          {
                             size=10;
                string queryString = 'select id,Name,BMCServiceDesk__shortDescription__c,PHS_Category__c,PHS_Sub_Category__c,BMCServiceDesk__FKStatus__c from BMCServiceDesk__Incident__c where account__r.customerId__c=:currentSiteCust';
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
                setCon.setPageSize(size);
                noOfRecords = setCon.getResultSize();  
                         }
                          return setCon;
                       }set;
                    }
                   public Boolean hasNext {
                                get {
                                        return setCon.getHasNext();
                                        }
                                               set;
                                     }
                    public void first()
                     {
                            setcon.first();
                    }
                    public void last()
                     {
                            setcon.last();
                    }
                    public void previous()
                     {
                            setcon.previous();
                    }
                  public void next()
                     {
                            setcon.next();
                    }
 public pagereference searchincidents()//getting records from setcon
                        {   
                         for(BMCServiceDesk__Incident__c  a : (List<BMCServiceDesk__Incident__c >)setCon.getRecords())
                           {
                              custincidentLst.add(a);
                           }
                           return null;
                          }

here is my VF page
<apex:pageBlock title="Incidents" rendered="{!showIncidents}" id="pb">
<apex:pageblocktable value="{!custincidentLst}" var="inci">
<apex:column headerValue="Name">                    
                     <apex:outputField value="{!inci.Name}"/>
                 </apex:column>
</apex:pageblocktable>
<apex:panelGrid columns="7">
               <apex:commandButton status="fetchStatus" reRender="pb" value="|<" action="{!first}" disabled="{!!setcon.hasPrevious}" title="First Page"/>
                 <apex:commandButton status="fetchStatus" reRender="pb" value="<" action="{!previous}" disabled="{!!setcon.hasPrevious}" title="Previous Page"/>
                 <apex:commandButton status="fetchStatus" reRender="pb" value=">" action="{!next}" disabled="{!!setcon.hasnext}" title="Next Page"/>
                 <apex:commandButton status="fetchStatus" reRender="pb" value=">|" action="{!last}" disabled="{!!setcon.hasnext}" title="Last Page"/>
                <apex:outputText >{!(setCon.pageNumber * size)+1-size}-{!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,(setCon.pageNumber * size))} of {!noOfRecords}</apex:outputText>
                 <apex:outputPanel style="color:#4AA02C;font-weight:bold">
                    <apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/>
                </apex:outputPanel>
                </apex:panelGrid>
</apex:pageblock>

But the problem is,i am not able to refresh the fresh data,means when i am clicking on nex button it showing only those old records.
any suggestion will be appriciated. 

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.