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

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 48
    Questions
  • 66
    Replies
Hi All,
I have a scenario where I have to assign owners based on various condition. Currently, we have Flows in place which checks the condition and does update Record. Now I am building an apex routing process where I need to check the conditions. In order to give flexibility, we want the condition should be configurable on UI and backend will do the calculation. e.g(1 OR 2) AND (3 OR 4) .

Any suggestion would be appreciated.
Hi All,
We have some routing processes configured using flow and process
builder. basically routing is based on category field. If category is A , its being routed to Queue abc. Our clients wants a way to view all the category which has been used in this routing process.

TIA.
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.