• SFDC16
  • NEWBIE
  • 80 Points
  • Member since 2017
  • Sales force Develoer

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 38
    Questions
  • 37
    Replies
Hello,

I am getting below error.

Error:
System.NullPointerException: Attempt to de-reference a null object

Class.BMCRF_GetAssetDetails.assetDetails: line 52, column 1
Class.BMCRF_GetAssetDetails_Test.setupTestData: line 43, column 


@isTest 
public class BMCRF_GetAssetDetails_Test
{  
            // insert base element data    
                @isTest
                static void setupTestData() 
                {  
                    Profile profile1 = [Select Id from Profile where name = 'System Administrator'];
                    System.debug('What is the profile id---------------------------------> ' + profile1);
                    UserRole portalRole = [Select Id From UserRole Where PortalType = 'None' Limit 1];
                    System.debug('portalRole--------------------------------->  ' + portalRole);
                    date tDate = date.today();
                    date uDate = Date.today().addDays(30);
                    User us2 = new User(
                    UserRoleId = portalRole.Id,
                    ProfileId = profile1.Id,
                    Username = 'test@networks.com',
                    Alias = 'sal',
                    Email='test@networks.com',
                    EmailEncodingKey='UTF-8',
                    Firstname='test',
                    Lastname='testDemo',
                    LanguageLocaleKey='en_US',
                    LocaleSidKey='en_US',
                    TimeZoneSidKey='Asia/Singapore',BMCServiceDesk__Account_Name__c='test');
                    insert us2;
                    
                     System.runAs(us2)
                     {
                         List<BMCServiceDesk__BMC_BaseElement__c> bas=new List<BMCServiceDesk__BMC_BaseElement__c>();
                         BMCServiceDesk__BMC_BaseElement__c baseElement= new BMCServiceDesk__BMC_BaseElement__c();   
                         baseElement.BMCServiceDesk__Name__c= 'Test Company';
                         baseElement.BMCServiceDesk__PrimaryClient__c=us2.id;
                         baseElement.BMCRF_ResourceId__c='34784';
                         baseElement.BMCServiceDesk__CMDB_Class__c= 'a2Z1X000000RXZaUAO';
                         
                         insert baseElement;
              
                     }  
                           
                         Test.startTest();
                         BMCRF_GetAssetDetails s=new BMCRF_GetAssetDetails();
                         s.assetDetails();
                         Test.StopTest();
                                          
                   
                   } 
 }
Hello,

Requirement:

Assign user id while inserting a new record.

I am getting the username from the response and  comparing username with salesforce user if is  it exists then assign while inserting a new record in a custom object in custom object userid is a lookup of the user object

XML file response example:
<userinfo>
<userid>1233</userid>
<name> ram patil</name>
<Domain>xyz</Domain>
<userInfo>


Below is my code :




global class BmcrfgettassetDetails implements Database.Batchable < sObject >,Database.AllowsCallouts {

    global Database.QueryLocator start(Database.BatchableContext BC)
     {

        String query = 'Select id ,name from BMCServiceDesk__BMC_BaseElement__c';
        System.debug('Inside start methode');
        return Database.getQueryLocator(query);
        
     }

global void execute(Database.BatchableContext BC, List< BMCServiceDesk__BMC_BaseElement__c> accList) 
{
    if(accList.size()>0)
    {
            System.debug('accListaccList--->'+accList);
            String Username = 'xyz';
            String Password = 'xyz';
            HttpRequest req = new HttpRequest();
            req.setMethod('GET');
            req.setHeader('content-type','text/xml');
            req.setHeader('SOAPAction','xyz');
            req.setEndpoint('xyz');
            String body = 'xyz';
        req.setBody(body);
            Http http = new Http();   
            HTTPResponse res = new HTTPResponse();
            res = http.send(req);   
            String responseBody=res.getBody();
            System.debug('Response='+responseBody);  
            if(res.getStatusCode()==200)
            {   
                list<user> usernames=[Select id,username from user];
                list<BMCServiceDesk__CMDB_Class__c> listclass=[SELECT Id, Name,BMCServiceDesk__ClassName__c FROM BMCServiceDesk__CMDB_Class__c];
                List<BMCServiceDesk__BMC_BaseElement__c> newaccount=new List<BMCServiceDesk__BMC_BaseElement__c>();
                System.debug('Inside If Condition');
                Dom.Document docx = new Dom.Document();
                docx.load(responseBody);
                Dom.XmlNode root = docx.getRootElement();
                Dom.XmlNode[] childElements = root.getChildElements();
                for(Dom.XmlNode child : childElements)
                {   
                   
                    if(child.getName()=='body')
                    {
                      
                       Dom.XmlNode GetAssetDetailsResponse = child.getChildElement('GetAssetDetailsResponse','http://tempuri.org/');
                       Dom.XmlNode GetAssetDetailsResult = GetAssetDetailsResponse.getChildElement('GetAssetDetailsResult','http://tempuri.org/');
                       Dom.XmlNode Customers = GetAssetDetailsResult.getChildElement('Root',''); 
                       system.debug('Customers------>'+Customers);
                       Dom.XmlNode[] Customer=Customers.getChildElements(); 
                       system.debug('Customer------->'+Customer);         
                       Integer count=0;
                       for(Dom.XmlNode cust : Customer)
                       {
                           
                           
                           if(cust.getName()=='UserInfo') 
                           {
                                System.debug('Userinfo------'); 
                                if(count>0)
                                {
                                    Dom.XmlNode[] custasset=cust.getChildElements();
                                    for(Dom.XmlNode c:custasset)
                                    {
                                         String assetId;
                                         String resourcename;
                                         String userinfo;
                                         String classtype;
                                         String referenceID;
                                         String userid;
                                         String classid;
                                        
                                        if(C.getName()=='NAME') 
                                        {
                                            userinfo=c.getText();
                                            System.debug('userinfo---->'+userinfo);
                                        }
                                        if(c.getName()=='ResourceInfo')
                                        {
                                           Dom.XmlNode[] resourceInfochild=c.getChildElements();
                                            for(Dom.XmlNode d:resourceInfochild)
                                            {
                                                System.debug('D------>'+d);
                                                
                                                if(d.getName()=='RESOURCENAME')
                                                {
                                                    resourcename=d.getText();
                                                    System.debug('resourcename---->'+resourcename);
                                                }
                                                if(d.getName()=='TYPENAME')
                                                {
                                                    classtype=d.getText();
                                                    System.debug('classtype----->'+classtype);
                                                    
                                                }
                                                if(d.getName()=='RESOURCEID')
                                                {
                                                    referenceID=d.getName();
                                                    System.debug('referenceID------>'+referenceID);
                                                }
                                                
                                            }
                                            
                                        }
                                       
                                        for(User  usID : usernames)
                                        {
                                          System.debug('usID----->'+usID);    
                                          if(usID.username==userinfo)
                                          userid=usId.id;
                                        }
                                        
                                        /*for(BMCServiceDesk__CMDB_Class__c cmdbclass : listclass)
                                        {
                                             if(cmdbclass.BMCServiceDesk__ClassName__c==RESOURCENAME)
                                              classid=cmdbclass.id;
                                        }*/
                                        
                                        System.debug('userid---->'+userid);
                                        if(resourcename!=null)
                                        {     
                                            BMCServiceDesk__BMC_BaseElement__c c1=new BMCServiceDesk__BMC_BaseElement__c();
                                            c1.BMCServiceDesk__Name__c=resourcename;
                                            c1.BMCServiceDesk__PrimaryClient__c=userId;     // Assign user
                                            c1.BMCServiceDesk__CMDB_Class__c='a2Z1X000000Qt1uUAC';
                                            newaccount.add(c1);                               
                                            System.debug('listassets---->'+newaccount);
                                            System.debug('listassets size()---->'+newaccount.size());
                                       } 
                                  }
                                    System.debug('custasset---->'+custasset);
                                }
                              
                               count++;
                               
                           }
                      }    
                    }           
                }   
                
                if(newaccount.size()>0)
                {
                 
                  Database.upsert(newaccount);
                    
                }
              } 
       }                 
    }
    
         global void finish(Database.BatchableContext BC)
         {
           System.debug('xyz');
         }
}


Regards,
SFDC16
Hello Developer,

My  Http callouts in batch class not working.

But normal class working fine 
Hello developer.

I am getting an error while inserting record after parsing XML file in web services 

Error:

System.DmlException: Upsert failed. First exception on row 1491; first error: DUPLICATE_VALUE, duplicate value found: BMCServiceDesk__Name__c duplicates value on record with id: a0K2v00000ovAav: []

Note: There is a no duplicate value found  in the XML response file


Below is my code 

String Username = 'demo';
String Password = 'demo';
HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setHeader('content-type','text/xml');
req.setHeader('');
req.setEndpoint('');
String body = '';
req.setBody(body);
Http http = new Http();   
HTTPResponse res = new HTTPResponse();
res = http.send(req);   
String responseBody=res.getBody();
System.debug('Response='+responseBody);  
if(res.getStatusCode()==200)
{
    List
<BMCServiceDesk__CMDB_Class__c> cmdbclass=[SELECT Id, Name, BMCServiceDesk__ClassID__c, BMCServiceDesk__ClassName__c, BMCServiceDesk__Class__c FROM BMCServiceDesk__CMDB_Class__c ];
    List
    <User> us=[Select id,name from user];  
    List
        <BMCServiceDesk__BMC_BaseElement__c> listassets=new List<BMCServiceDesk__BMC_BaseElement__c>();
    System.debug('Inside If Condition');
      Dom.Document docx = new Dom.Document();
    docx.load(responseBody);
    Dom.XmlNode root = docx.getRootElement();
    Dom.XmlNode[] childElements = root.getChildElements();
    for(Dom.XmlNode child : childElements)
    {    
       
        if(child.getName()=='body')
        {
          
           Dom.XmlNode GetAssetDetailsResponse = child.getChildElement('GetAssetDetailsResponse','http://tempuri.org/');
           Dom.XmlNode GetAssetDetailsResult = GetAssetDetailsResponse.getChildElement('GetAssetDetailsResult','http://tempuri.org/');
           Dom.XmlNode Customers = GetAssetDetailsResult.getChildElement('Root',''); 
           system.debug('Customers------>'+Customers);
           Dom.XmlNode[] Customer=Customers.getChildElements(); 
           system.debug('Customer------->'+Customer);         
             Integer count=0;
           for(Dom.XmlNode cust : Customer)
           {
               
               
               if(cust.getName()=='UserInfo') 
               {
                    System.debug('Userinfo------'); 
                    if(count>0)
                    {
                        Dom.XmlNode[] custasset=cust.getChildElements();
                        for(Dom.XmlNode c:custasset)
                        {
                             String assetId;
                                String resourcename;
                               String userinfo;
                               String classtype;
                             String referenceID;
                            
                            if(C.getName()=='NAME') 
                            {
                                userinfo=c.getText();
                                System.debug('userinfo---->'+userinfo);
                            }
                            if(c.getName()=='ResourceInfo')
                            {
                               Dom.XmlNode[] resourceInfochild=c.getChildElements();
                                for(Dom.XmlNode d:resourceInfochild)
                                {
                                    System.debug('D------>'+d);
                                    
                                    if(d.getName()=='RESOURCENAME')
                                    {
                                        resourcename=d.getText();
                                        System.debug('resourcename---->'+resourcename);
                                    }
                                    if(d.getName()=='TYPENAME')
                                    {
                                        classtype=d.getText();
                                        System.debug('classtype----->'+classtype);
                                        
                                    }
                                    if(d.getName()=='RESOURCEID')
                                    {
                                        referenceID=d.getName();
                                        System.debug('referenceID------>'+referenceID);
                                    }
                                    
                                }
                                
                            }
                            
                            if(resourcename!=null)
                            {    
                                    BMCServiceDesk__BMC_BaseElement__c base1=new BMCServiceDesk__BMC_BaseElement__c();
                                       base1.BMCServiceDesk__Name__c=resourcename;
                                    base1.BMCServiceDesk__PrimaryClient__c='0052v00000WzxmKAAR';
                                    base1.BMCServiceDesk__CMDB_Class__c='a1y2v00000BikscAAB';
                                       listassets.add(base1);
                                    System.debug('listassets---->'+listassets);
                            } 
                     }
                            
                            
                        }
                    }
                  
                   count++;
                   
               }
          }    
        }   
        
        if(listassets.size()>0)
        {
            System.debug('listassets---->'+listassets);
            upsert listassets;
            
        }
 }



 
Schedulbale Class:

User-added image

global class DeletAccount implements Schedulable
{
     
     global void execute(SchedulableContext ctx)
     {
         list<Account> acc=new list<Account>();
         for(Account acc1:[Select id,name from account where name like '%Demo%'])        
             acc.add(acc1);--------------->Error Line
             
   
         delete acc;      
     }
       
}

Test Class:

@isTest
public class Testclass {
 public static testmethod void test1()
 {
     Test.startTest();
           list<account> acc=new list<Account>(); 
        Account a1 = new Account();
          a1.name='Dummy account';
         acc.add(a1);    
         insert acc; 
        String CRON_EXP = '0 0 0 3 9 ? 2022';
        String jobId = System.schedule('test111', CRON_EXP, new DeletAccount());
         CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
          System.debug('ct'+ct);
        System.assertEquals(0, ct.TimesTriggered);
        System.assertEquals('2022-09-03 00:00:00', String.valueOf(ct.NextFireTime));
     Test.stopTest();  
 }
                
}
 
Hi,
How to call Scheduler class from the trigger?

Regards,
SFDC16
Hello Developer,
 
I am trying to create a trigger when a new lead is created it will check lead email in the account exist or not.

If  "YES" then update the account name with the lead name.

 If  "No" the create a new account with lead name.

  Any help would be greatly appreciated.

trigger leadMap on Lead (before insert) 
{
       List<String> lea=new List<String>();
      
       for(lead le:trigger.new)
       {
           lea.add(le.Email);
           
       }   
       System.debug('Email------------------------>'+lea);
    
       list<account> accList=[Select id,name,Email__C from Account where Email__C =:lea];
       System.debug('accList------------->'+accList);
  if(accList.size()>0)
  {
    for(Lead l:trigger.new)
      {
              System.debug('before first for loop');
            
               for(Account ac:accList)
                {
                    System.debug('ac===========>'+ac.name);
                    if(ac.email__C==l.email)
                    {
                        System.debug('ac.email__C===============>'+ac.email__C);
                        System.debug('l.email===================>'+l.email);
                        ac.name=l.LastName;
                        ac.Description='trigger fire';
                        System.debug('Inside if statement');

                    }
                    
                    
                }
            }
      }
          else
          { 
              for(lead ls:trigger.new)
              {
                  Account a=new Account();
                  a.Name=ls.name;
                  accList.add(a);
                  
              }
              
          }
}

Regards,
SFDC16
  • April 26, 2019
  • Like
  • 0
hello,

I am getting an error for below code 
System.NullPointerException: Attempt to de-reference a null object


  Account[] acc1=[Select id,name from account];
       Case ca=new Case();
       ca.Status='New';
       ca.Origin='Phone';
       ca.Account.name=acc1[0].name; // --------> error line
       ca.Subject='hello';       
       insert ca;
       system.debug('Account Name'+ca);
      
  • April 18, 2019
  • Like
  • 0
Hello,
 I am not able to fetch the dashboard name based on the string variable.

Below highlighted code is not working. 

  List<User> userList=[Select id,BMCServiceDesk__Account_ID__c, BMCServiceDesk__Account__c  from user where id=:userInfo.getUserId()];
  System.debug('userList-------->'+userList); // return value
 
  List<String> userAccount=new List<String>();
   for(User u:userList)
   {
       userAccount.add(u.BMCServiceDesk__Account__c);
       
   }
  
    System.debug('User Account------->'+userAccount);
     String sData = String.valueof(userAccount);
    System.debug('String----->'+sData);//return Values
    List<Dashboard> dash=[Select id,title From Dashboard where title=:sData]; 
    if(dash.size()>0)
    System.debug('Dashboard Name------>'+dash);//return null    List<Dashboard> sobjList = Database.query('Select id,title From  Dashboard where title IN:userAccount');
    if(sobjList.size()>0)
    System.debug('Dashboard---------------->'+sobjList);   //return null
    

          
 
  • April 17, 2019
  • Like
  • 0
Hello Developer,

I am trying to insert a new record from vf page I have some custom fields
but I don't know exactly how to insert picklist value from vf page.



Note: State is custom filed which contains all Indian state.

Below is my vf and apex code.


                                <apex:pageBlock id="insertMaserData">

                                            <div class="slds-align_absolute-center" style="height: 3rem;">

                                            </div>
                                            <table class='table'>

                                                <tr>
                                                    <td><b>Name</b></td>
                                                    <td><apex:inputtext value="{!customerName}" label="Customer Name" styleClass="slds-input"  style="width:150px" required="true"/> </td>
                                                    <td><b>Contact Number</b></td>
                                                    <td><b><apex:inputtext value="{!contactNumber}" label="Customer Name" styleClass="slds-input"  style="width:150px"  required="true"/> </b></td>
                                               </tr>
                                                
                                                <tr>
                                                    <td><b>Customer Email</b></td>
                                                    <td><apex:inputtext value="{!customerEmail}" label="Customer Name" styleClass="slds-input"  style="width:150px" required="true"/> </td>
                                                    <td><b>Customer Address</b></td>
                                                    <td><b><apex:inputtext value="{!customerAddres}" label="Customer Name" styleClass="slds-input"  style="width:150px"  required="true"/> </b></td>
                                               </tr>
                                                
                                                <tr>
                                                    <td><b>Customer Age</b></td>
                                                    <td><apex:inputtext value="{!customerAge}" label="Customer Name" styleClass="slds-input"  style="width:150px" required="true"/> </td>
                                                    <td><b>PAN Number</b></td>
                                                    <td><b><apex:inputtext value="{!panNumber}" label="Customer Name" styleClass="slds-input"  style="width:150px"  required="true"/> </b></td>
                                                </tr>
                                                
                                                <tr>
                                                   
                                                    <td><b>State Name</b></td>
                                                    <td><apex:inputtext value="{!stateName}" label="Customer Name" styleClass="slds-input"  style="width:150px" required="true"/> </td>
                                              
                                                </tr>

                                               
                                            </table>
                                            <div class="slds-align_absolute-center" style="height: 3rem;">

                                                <apex:commandButton action="{!insertMasterRecord}" value="Save" styleClass="slds-button slds-button_neutral" oncomplete="alert('Record Inserted SuccessFully..!!');" />
                                                <button type="button" class="slds-button slds-button_neutral" data-dismiss="modal">Close</button>

                                            </div>

                                        
                                </apex:pageBlock>

=======Apex code===============

public class InsertMasterData {
 public String customerName{get;set;}
    public Integer contactNumber{get;set;}
    public String customerAddres{get;set;}
    public String customerEmail{get;set;}
    public Integer customerID{get;set;}
    public String panNumber{get;set;}
    public String stateName{get;set;}
    public String customerAge{get;set;}
 
    public InsertMasterData()
    {

        
    }
    

   public PageReference  insertMasterRecord()
    {
        
        Customer_Master__c cm=new Customer_Master__c();
        cm.Name=customerName;
        cm.Contact_Number__c=contactNumber;
        cm.Customer_Address__c=customerAddres;       
        cm.Customer_Email__c=customerEmail;
        cm.Pan_Number__c=panNumber;
        cm.State__c=stateName; // picklist value
        cm.Age__c=customerAge;
        
        insert cm;
}
  • April 09, 2019
  • Like
  • 0

Hello Developer,

How to use map for below code 



global class DisplayDashboard
{
             
    public List <Dashboard>  fetchdashboard{get;set;}

    Public DisplayDashboard()
    {
       
        List<User> cuurentUser=[SELECT Id, Username,Title FROM User where username=:UserInfo.getUsername()];
        System.debug('Title-------->'+cuurentUser);
        
        System.debug(cuurentUser);
       
        List<String> str=new List<String>();    
        System.debug('str----------->'+str);
        for(User u:cuurentUser) 
        {
            str.add(cuurentUser[0].Title);
            
        }
       System.debug('str----------->'+str);

        for(Dashboard dash : [SELECT Id, Title FROM Dashboard])
        {
            for(User u:[SELECT Id, Username,Title FROM User where Title In:str] )
            {     
                if(dash.title.Contains(u.title))
                    {
                    fetchdashboard=[SELECT Id, Title FROM Dashboard];    
                    System.debug('fetchdashboard-------------->'+fetchdashboard);
                }
            }    
        }
    
    }     
 }


Regards,
SFDC16
  • April 07, 2019
  • Like
  • 0
Hello Developers,

I have a requirement when all incident (Incident is a custom object) related task closed to close incident automatically.

I have written below trigger for the single task when the task is closed incident close automatically.

Note: Incident and Task both are the Custom object

trigger ClostTaskRelatedIncident on BMCServiceDesk__Task__c (after  update) {
    List<BMCServiceDesk__Task__c> cse = Trigger.new;

    Set<ID> cseIds = new Set<ID>();
    System.debug('------------------->'+cseIds);
    for (BMCServiceDesk__Task__c t:cse)
    {  
      System.debug('Before If condition of t.BMCServiceDesk__Status_ID__c');
      if (t.BMCServiceDesk__FKStatus__c=='a3w0w0000000AslAAE')
      {
         cseIds.add(t.BMCServiceDesk__FKIncident__c);
      }
      System.debug('After Case IDs'+cseIds);
      for (BMCServiceDesk__Incident__c c : [select id,BMCServiceDesk__incidentDescription__c from BMCServiceDesk__Incident__c where id in :cseIds])
      {
          if(c.BMCServiceDesk__incidentDescription__c!='')
          {     
              c.BMCServiceDesk__FKStatus__c='a3w0w0000000AslAAE';
              c.BMCServiceDesk__incidentDescription__c='Trigger Fire';
              update c;
              
          }    
      }
    }

}
Regards,
SFDC16
  • April 01, 2019
  • Like
  • 0
Below are trigger and error.


Error: Compile Error: Variable does not exist: whatId at line 13 column 14

trigger LinkdTaskToIncident on BMCServiceDesk__Incident__c (before insert) 
{

    List<BMCServiceDesk__Task__c>  task=new  List<BMCServiceDesk__Task__c>();
        
        for(BMCServiceDesk__Incident__c c:Trigger.new)
        {
           if(c.BMCServiceDesk__Is_New_Record__c==true)
           {    
            
             BMCServiceDesk__Task__c t = new BMCServiceDesk__Task__c();
             t.BMCServiceDesk__taskDescription__c=c.BMCServiceDesk__incidentDescription__c;
             whatId=c.id;

             task.add(t);
           }
        }
          
             insert task;    
}
  • March 31, 2019
  • Like
  • 0
Hello Developers,

First Code 
 
   BMCServiceDesk__Incident__c inc=new          BMCServiceDesk__Incident__c();
       inc.BMCServiceDesk__FKClient__c='0050o00000X3wMPAAZ';    
       inc.BMCServiceDesk__FKOpenBy__c='0050o00000X3wMPAAZ'; 
       inc.BMCServiceDesk__FKStatus__c='a3w0w0000000AskAAE'; 
       inc.BMCServiceDesk__FKImpact__c='a2M0w0000000dcYEAQ';
       inc.BMCServiceDesk__FKUrgency__c='a470w00000001G0AAI';
       inc.BMCServiceDesk__Is_New_Record__c=true;
       inc.BMCServiceDesk__FKCategory__c='a210w00000009pbAAA';
       insert inc; 
---------------------------------------------------------------------------------------------

Second Code 
       
       BMCServiceDesk__Status__c[] sta=[select id from BMCServiceDesk__Status__c where name='Opened'];
       User[] user=[Select id from User];
       BMCServiceDesk__Category__c[] cat=[select id from BMCServiceDesk__Category__c where name='Hardware'];
       BMCServiceDesk__Impact__c[] imp=[select id from BMCServiceDesk__Impact__c where name='Low']; 
       BMCServiceDesk__Urgency__c[] urgency=[select id from BMCServiceDesk__Urgency__c where name='Low'];    
       BMCServiceDesk__SYSTemplate__c[] temp=[select id from BMCServiceDesk__SYSTemplate__c where name like '%Test%'];
        
        if(sta.size()> 0 && user.size()>0 &&  cat.size()>0 && imp.size()>0  && urgency.size()> 0 && temp.size()>0 )
        {
               List<BMCServiceDesk__Incident__c> a =new List<BMCServiceDesk__Incident__c>();
             BMCServiceDesk__Incident__c inc=new BMCServiceDesk__Incident__c();
               inc.BMCServiceDesk__FKStatus__c=sta[0].id;     
               inc.BMCServiceDesk__FKClient__c=user[0].id;
               inc.BMCServiceDesk__FKOpenBy__c=user[0].id;
                inc.BMCServiceDesk__FKCategory__c=cat[0].id; 
               inc.BMCServiceDesk__FKImpact__c=imp[0].id;
               inc.BMCServiceDesk__FKTemplate__c=temp[0].id;
               inc.BMCServiceDesk__FKUrgency__c=urgency[0].id;
               insert inc;        
        }

First code is working fine but secod code is not working

I tried  Execute Anonymous.
  • March 30, 2019
  • Like
  • 0
Below is my apex trigger and test class 

Apex trigger 

/**
 * @File Name          : NotifyWhenCreated.trigger
 * @Description        : 
 * @Author             : ChangeMeIn@UserSettingsUnder.SFDoc
 * @Group              : 
 * @Last Modified By   : ChangeMeIn@UserSettingsUnder.SFDoc
 * @Last Modified On   : 3/30/2019, 6:06:55 PM
 * @Modification Log   : 
 *==============================================================================
 * Ver         Date                     Author                    Modification
 *==============================================================================
 * 1.0    3/30/2019, 5:55:07 PM   ChangeMeIn@UserSettingsUnder.SFDoc     Initial Version
**/
trigger NotifyWhenCreated on BMCServiceDesk__Incident__c (before insert,before update) {
    
    
       if(trigger.isBefore)
       {
                for(BMCServiceDesk__Incident__c a:trigger.new)
                {
                   
                   if(a.BMCServiceDesk__Is_New_Record__c==true)
                    {
                       
                        a.BMCServiceDesk__incidentDescription__c='Hello Customer Incident Has Been Created And Assigned To You';
                    
                        
                    }
                } 
       }
       
       if(trigger.isUpdate)
       {
           
            for(BMCServiceDesk__Incident__c inc:trigger.new )
            {
                
                   if( inc.BMCServiceDesk__Is_New_Record__c==False)
                   {
                       
                       inc.BMCServiceDesk__incidentDescription__c='Dear Staff Incident Has Been Created And  Assigned To You' ;
                       
                   }
                
            }
       }
}

Test class 

/**
 * @File Name          : NotifyCustomer_Test.cls
 * @Description        : 
 * @Author             : ChangeMeIn@UserSettingsUnder.SFDoc
 * @Group              : 
 * @Last Modified By   : ChangeMeIn@UserSettingsUnder.SFDoc
 * @Last Modified On   : 3/30/2019, 6:12:05 PM
 * @Modification Log   : 
 *==============================================================================
 * Ver         Date                     Author                    Modification
 *==============================================================================
 * 1.0    3/30/2019, 6:10:25 PM   ChangeMeIn@UserSettingsUnder.SFDoc     Initial Version
**/
@isTest()
public  class  NotifyCustomer_Test1
{
        
    public  static testMethod void testNotifyCustomer()
    {
       BMCServiceDesk__Status__c[] status=[SELECT Id, Name FROM BMCServiceDesk__Status__c where name like '%OPENED%'];
       User[] Us =[Select Id,name from user];
       BMCServiceDesk__Impact__c[] impact=[Select id,name from BMCServiceDesk__Impact__c];
       BMCServiceDesk__Category__c[] category=[SELECT Id, Name FROM BMCServiceDesk__Category__c];
        BMCServiceDesk__Urgency__c[] urgency=[select id,name from BMCServiceDesk__Urgency__c];        
             
   if(Us.size()>0 && status.size()>0 && impact.size()>0 && urgency.size()>0)
    {
       BMCServiceDesk__Incident__c inc=new BMCServiceDesk__Incident__c();
       inc.BMCServiceDesk__FKClient__c=Us[0].id;    
       inc.BMCServiceDesk__FKOpenBy__c=Us[0].id; 
       inc.BMCServiceDesk__FKStatus__c=status[0].id; 
       inc.BMCServiceDesk__FKImpact__c=impact[0].id;
       inc.BMCServiceDesk__FKUrgency__c=urgency[0].id;
       inc.BMCServiceDesk__Is_New_Record__c=true;
       insert inc; 
     }
    }              
                   
}
  • March 30, 2019
  • Like
  • 0

public class BMCRF_Export_CSV_Format_AC {

   

    public string fileName {get;set;}
    Public string assignID{get; set;}
    public List<BMCServiceDesk__BMC_BaseRelationship__c> fetchallAsset{get;set;}
    public List<BMCServiceDesk__BMC_BaseElement__c> fetchallAssetnamecsv{get;set;}
    public List<BMCServiceDesk__BMC_BaseElement__c > AllContracts{get;set;}

   
    public BMCRF_Export_CSV_Format_AC()
    {
         User U=[select id, name,BMCServiceDesk__Account_Name__c,BMCServiceDesk__Account_ID__c from User where id=:Userinfo.getUserId()];

        fileName ='Asset Detail';
        assignID=ApexPages.currentPage().getParameters().get('assignID');
        System.debug('------------------>'+assignID);
        if(assignID!= null)
        fetchallAsset=[select id,BMCServiceDesk__Destination_InstanceName__c,BMCServiceDesk__Source_InstanceName__c from BMCServiceDesk__BMC_BaseRelationship__c where BMCServiceDesk__Source_InstanceName__c=:assignID];

         
        System.debug('------------------>'+fetchallAsset); 
        
        List<String> assetnamecsv=new List<String>();
         
        
         for(BMCServiceDesk__BMC_BaseRelationship__c  val : fetchallAsset)
         {
             assetnamecsv.add(val.BMCServiceDesk__Destination_InstanceName__c);

         }//End Of For Loop
         
         AllContracts=[SELECT Id, Name,BMCServiceDesk__Description__c,BMCRF_Account_Name__c,BMCServiceDesk__Class__c,BMCRF_SOR__c,BMCRF_Terms_In_Months__c,BMCRF_Commissioned_Date__c, BMCServiceDesk__ContractID__c, BMCServiceDesk__StartDate__c,BMCServiceDesk__EndDate__c,BMCServiceDesk__ContractType__c, BMCServiceDesk__SerialNumber__c,BMCRF_3D_Start_Date__c,BMCRF_B2B_SLA__c,BMCRF_Qty__c,BMCRF_B2B_Start_Date__c,BMCRF_B2B_End_Date__c,BMCServiceDesk__Asset_Status__c,BMCRF_3D_End_Date__c,BMCServiceDesk__FKModel__r.name,BMCRF_X3D_SLA_Coverage__c,BMCServiceDesk__PrimaryClient__c FROM BMCServiceDesk__BMC_BaseElement__c where BMCServiceDesk__Class__c='BMC_Contract' and Name =:assignID];
         System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=All Contracts'+ AllContracts);    
             
        
         System.debug('Assetname------------------------------------------------------------------'+assetnamecsv);
         System.debug('AllAssets'+assetnamecsv);
        
         fetchallAssetnamecsv=[select id,name,BMCServiceDesk__SerialNumber__c,BMCRF_Account_Name__c,BMCRF_3D_Start_Date__c,BMCRF_B2B_SLA__c,BMCRF_Qty__c,BMCRF_B2B_Start_Date__c,BMCRF_B2B_End_Date__c,BMCServiceDesk__Asset_Status__c,BMCRF_3D_End_Date__c,BMCServiceDesk__FKModel__r.name,BMCRF_X3D_SLA_Coverage__c,BMCServiceDesk__PrimaryClient__c , BMCServiceDesk__Description__c from BMCServiceDesk__BMC_BaseElement__c where name IN: assetnamecsv and BMCRF_Retired_Pool__c=false];     
         System.debug('------------------->'+fetchallAssetnamecsv); 
         
 
    }
    
}
  • March 06, 2019
  • Like
  • 0
Test class for the conditional constructor.

for example '

public class Test()
{
          public List <Dashboard>  fetchdashboard{get;set;}

      Test()
      {
           List<user> s=[select id,name from user]
         if(s.name='xyz')
         {
                 fetchdashboard=[select id name from  Dashboard where                     name like '%test12323%']
         }
        else if()
        {
        }
     }
}

Test class for above code
  • March 05, 2019
  • Like
  • 0
Hello,

I want create dynamically field on vf page after click on save button.For Example I wiil select data type from picklist and give name to that field xyz that inserted values display input field on another page.
PFA
User-added image

 
  • September 05, 2018
  • Like
  • 0
Hello,

I have requirment to crate field as from vf by selecting data type.
If I selected data type from picklist as text data type  and input value Enter Name for that field this field display as input field(Enter Name With text box) on another page or same page.

PFA
  


User-added image
  • September 03, 2018
  • Like
  • 0
Create field from vf page by selecting data type and created field display as input in vf page.

For example from picklist If selected text field with label name this field I want display on another page as a input field.
  • September 03, 2018
  • Like
  • 0
Hello,

I am getting below error.

Error:
System.NullPointerException: Attempt to de-reference a null object

Class.BMCRF_GetAssetDetails.assetDetails: line 52, column 1
Class.BMCRF_GetAssetDetails_Test.setupTestData: line 43, column 


@isTest 
public class BMCRF_GetAssetDetails_Test
{  
            // insert base element data    
                @isTest
                static void setupTestData() 
                {  
                    Profile profile1 = [Select Id from Profile where name = 'System Administrator'];
                    System.debug('What is the profile id---------------------------------> ' + profile1);
                    UserRole portalRole = [Select Id From UserRole Where PortalType = 'None' Limit 1];
                    System.debug('portalRole--------------------------------->  ' + portalRole);
                    date tDate = date.today();
                    date uDate = Date.today().addDays(30);
                    User us2 = new User(
                    UserRoleId = portalRole.Id,
                    ProfileId = profile1.Id,
                    Username = 'test@networks.com',
                    Alias = 'sal',
                    Email='test@networks.com',
                    EmailEncodingKey='UTF-8',
                    Firstname='test',
                    Lastname='testDemo',
                    LanguageLocaleKey='en_US',
                    LocaleSidKey='en_US',
                    TimeZoneSidKey='Asia/Singapore',BMCServiceDesk__Account_Name__c='test');
                    insert us2;
                    
                     System.runAs(us2)
                     {
                         List<BMCServiceDesk__BMC_BaseElement__c> bas=new List<BMCServiceDesk__BMC_BaseElement__c>();
                         BMCServiceDesk__BMC_BaseElement__c baseElement= new BMCServiceDesk__BMC_BaseElement__c();   
                         baseElement.BMCServiceDesk__Name__c= 'Test Company';
                         baseElement.BMCServiceDesk__PrimaryClient__c=us2.id;
                         baseElement.BMCRF_ResourceId__c='34784';
                         baseElement.BMCServiceDesk__CMDB_Class__c= 'a2Z1X000000RXZaUAO';
                         
                         insert baseElement;
              
                     }  
                           
                         Test.startTest();
                         BMCRF_GetAssetDetails s=new BMCRF_GetAssetDetails();
                         s.assetDetails();
                         Test.StopTest();
                                          
                   
                   } 
 }
Hello developer.

I am getting an error while inserting record after parsing XML file in web services 

Error:

System.DmlException: Upsert failed. First exception on row 1491; first error: DUPLICATE_VALUE, duplicate value found: BMCServiceDesk__Name__c duplicates value on record with id: a0K2v00000ovAav: []

Note: There is a no duplicate value found  in the XML response file


Below is my code 

String Username = 'demo';
String Password = 'demo';
HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setHeader('content-type','text/xml');
req.setHeader('');
req.setEndpoint('');
String body = '';
req.setBody(body);
Http http = new Http();   
HTTPResponse res = new HTTPResponse();
res = http.send(req);   
String responseBody=res.getBody();
System.debug('Response='+responseBody);  
if(res.getStatusCode()==200)
{
    List
<BMCServiceDesk__CMDB_Class__c> cmdbclass=[SELECT Id, Name, BMCServiceDesk__ClassID__c, BMCServiceDesk__ClassName__c, BMCServiceDesk__Class__c FROM BMCServiceDesk__CMDB_Class__c ];
    List
    <User> us=[Select id,name from user];  
    List
        <BMCServiceDesk__BMC_BaseElement__c> listassets=new List<BMCServiceDesk__BMC_BaseElement__c>();
    System.debug('Inside If Condition');
      Dom.Document docx = new Dom.Document();
    docx.load(responseBody);
    Dom.XmlNode root = docx.getRootElement();
    Dom.XmlNode[] childElements = root.getChildElements();
    for(Dom.XmlNode child : childElements)
    {    
       
        if(child.getName()=='body')
        {
          
           Dom.XmlNode GetAssetDetailsResponse = child.getChildElement('GetAssetDetailsResponse','http://tempuri.org/');
           Dom.XmlNode GetAssetDetailsResult = GetAssetDetailsResponse.getChildElement('GetAssetDetailsResult','http://tempuri.org/');
           Dom.XmlNode Customers = GetAssetDetailsResult.getChildElement('Root',''); 
           system.debug('Customers------>'+Customers);
           Dom.XmlNode[] Customer=Customers.getChildElements(); 
           system.debug('Customer------->'+Customer);         
             Integer count=0;
           for(Dom.XmlNode cust : Customer)
           {
               
               
               if(cust.getName()=='UserInfo') 
               {
                    System.debug('Userinfo------'); 
                    if(count>0)
                    {
                        Dom.XmlNode[] custasset=cust.getChildElements();
                        for(Dom.XmlNode c:custasset)
                        {
                             String assetId;
                                String resourcename;
                               String userinfo;
                               String classtype;
                             String referenceID;
                            
                            if(C.getName()=='NAME') 
                            {
                                userinfo=c.getText();
                                System.debug('userinfo---->'+userinfo);
                            }
                            if(c.getName()=='ResourceInfo')
                            {
                               Dom.XmlNode[] resourceInfochild=c.getChildElements();
                                for(Dom.XmlNode d:resourceInfochild)
                                {
                                    System.debug('D------>'+d);
                                    
                                    if(d.getName()=='RESOURCENAME')
                                    {
                                        resourcename=d.getText();
                                        System.debug('resourcename---->'+resourcename);
                                    }
                                    if(d.getName()=='TYPENAME')
                                    {
                                        classtype=d.getText();
                                        System.debug('classtype----->'+classtype);
                                        
                                    }
                                    if(d.getName()=='RESOURCEID')
                                    {
                                        referenceID=d.getName();
                                        System.debug('referenceID------>'+referenceID);
                                    }
                                    
                                }
                                
                            }
                            
                            if(resourcename!=null)
                            {    
                                    BMCServiceDesk__BMC_BaseElement__c base1=new BMCServiceDesk__BMC_BaseElement__c();
                                       base1.BMCServiceDesk__Name__c=resourcename;
                                    base1.BMCServiceDesk__PrimaryClient__c='0052v00000WzxmKAAR';
                                    base1.BMCServiceDesk__CMDB_Class__c='a1y2v00000BikscAAB';
                                       listassets.add(base1);
                                    System.debug('listassets---->'+listassets);
                            } 
                     }
                            
                            
                        }
                    }
                  
                   count++;
                   
               }
          }    
        }   
        
        if(listassets.size()>0)
        {
            System.debug('listassets---->'+listassets);
            upsert listassets;
            
        }
 }



 
Schedulbale Class:

User-added image

global class DeletAccount implements Schedulable
{
     
     global void execute(SchedulableContext ctx)
     {
         list<Account> acc=new list<Account>();
         for(Account acc1:[Select id,name from account where name like '%Demo%'])        
             acc.add(acc1);--------------->Error Line
             
   
         delete acc;      
     }
       
}

Test Class:

@isTest
public class Testclass {
 public static testmethod void test1()
 {
     Test.startTest();
           list<account> acc=new list<Account>(); 
        Account a1 = new Account();
          a1.name='Dummy account';
         acc.add(a1);    
         insert acc; 
        String CRON_EXP = '0 0 0 3 9 ? 2022';
        String jobId = System.schedule('test111', CRON_EXP, new DeletAccount());
         CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
          System.debug('ct'+ct);
        System.assertEquals(0, ct.TimesTriggered);
        System.assertEquals('2022-09-03 00:00:00', String.valueOf(ct.NextFireTime));
     Test.stopTest();  
 }
                
}
 
hello,

I am getting an error for below code 
System.NullPointerException: Attempt to de-reference a null object


  Account[] acc1=[Select id,name from account];
       Case ca=new Case();
       ca.Status='New';
       ca.Origin='Phone';
       ca.Account.name=acc1[0].name; // --------> error line
       ca.Subject='hello';       
       insert ca;
       system.debug('Account Name'+ca);
      
  • April 18, 2019
  • Like
  • 0
Hello,
 I am not able to fetch the dashboard name based on the string variable.

Below highlighted code is not working. 

  List<User> userList=[Select id,BMCServiceDesk__Account_ID__c, BMCServiceDesk__Account__c  from user where id=:userInfo.getUserId()];
  System.debug('userList-------->'+userList); // return value
 
  List<String> userAccount=new List<String>();
   for(User u:userList)
   {
       userAccount.add(u.BMCServiceDesk__Account__c);
       
   }
  
    System.debug('User Account------->'+userAccount);
     String sData = String.valueof(userAccount);
    System.debug('String----->'+sData);//return Values
    List<Dashboard> dash=[Select id,title From Dashboard where title=:sData]; 
    if(dash.size()>0)
    System.debug('Dashboard Name------>'+dash);//return null    List<Dashboard> sobjList = Database.query('Select id,title From  Dashboard where title IN:userAccount');
    if(sobjList.size()>0)
    System.debug('Dashboard---------------->'+sobjList);   //return null
    

          
 
  • April 17, 2019
  • Like
  • 0
Hello Developer,

I am trying to insert a new record from vf page I have some custom fields
but I don't know exactly how to insert picklist value from vf page.



Note: State is custom filed which contains all Indian state.

Below is my vf and apex code.


                                <apex:pageBlock id="insertMaserData">

                                            <div class="slds-align_absolute-center" style="height: 3rem;">

                                            </div>
                                            <table class='table'>

                                                <tr>
                                                    <td><b>Name</b></td>
                                                    <td><apex:inputtext value="{!customerName}" label="Customer Name" styleClass="slds-input"  style="width:150px" required="true"/> </td>
                                                    <td><b>Contact Number</b></td>
                                                    <td><b><apex:inputtext value="{!contactNumber}" label="Customer Name" styleClass="slds-input"  style="width:150px"  required="true"/> </b></td>
                                               </tr>
                                                
                                                <tr>
                                                    <td><b>Customer Email</b></td>
                                                    <td><apex:inputtext value="{!customerEmail}" label="Customer Name" styleClass="slds-input"  style="width:150px" required="true"/> </td>
                                                    <td><b>Customer Address</b></td>
                                                    <td><b><apex:inputtext value="{!customerAddres}" label="Customer Name" styleClass="slds-input"  style="width:150px"  required="true"/> </b></td>
                                               </tr>
                                                
                                                <tr>
                                                    <td><b>Customer Age</b></td>
                                                    <td><apex:inputtext value="{!customerAge}" label="Customer Name" styleClass="slds-input"  style="width:150px" required="true"/> </td>
                                                    <td><b>PAN Number</b></td>
                                                    <td><b><apex:inputtext value="{!panNumber}" label="Customer Name" styleClass="slds-input"  style="width:150px"  required="true"/> </b></td>
                                                </tr>
                                                
                                                <tr>
                                                   
                                                    <td><b>State Name</b></td>
                                                    <td><apex:inputtext value="{!stateName}" label="Customer Name" styleClass="slds-input"  style="width:150px" required="true"/> </td>
                                              
                                                </tr>

                                               
                                            </table>
                                            <div class="slds-align_absolute-center" style="height: 3rem;">

                                                <apex:commandButton action="{!insertMasterRecord}" value="Save" styleClass="slds-button slds-button_neutral" oncomplete="alert('Record Inserted SuccessFully..!!');" />
                                                <button type="button" class="slds-button slds-button_neutral" data-dismiss="modal">Close</button>

                                            </div>

                                        
                                </apex:pageBlock>

=======Apex code===============

public class InsertMasterData {
 public String customerName{get;set;}
    public Integer contactNumber{get;set;}
    public String customerAddres{get;set;}
    public String customerEmail{get;set;}
    public Integer customerID{get;set;}
    public String panNumber{get;set;}
    public String stateName{get;set;}
    public String customerAge{get;set;}
 
    public InsertMasterData()
    {

        
    }
    

   public PageReference  insertMasterRecord()
    {
        
        Customer_Master__c cm=new Customer_Master__c();
        cm.Name=customerName;
        cm.Contact_Number__c=contactNumber;
        cm.Customer_Address__c=customerAddres;       
        cm.Customer_Email__c=customerEmail;
        cm.Pan_Number__c=panNumber;
        cm.State__c=stateName; // picklist value
        cm.Age__c=customerAge;
        
        insert cm;
}
  • April 09, 2019
  • Like
  • 0
Hello Developers,

I have a requirement when all incident (Incident is a custom object) related task closed to close incident automatically.

I have written below trigger for the single task when the task is closed incident close automatically.

Note: Incident and Task both are the Custom object

trigger ClostTaskRelatedIncident on BMCServiceDesk__Task__c (after  update) {
    List<BMCServiceDesk__Task__c> cse = Trigger.new;

    Set<ID> cseIds = new Set<ID>();
    System.debug('------------------->'+cseIds);
    for (BMCServiceDesk__Task__c t:cse)
    {  
      System.debug('Before If condition of t.BMCServiceDesk__Status_ID__c');
      if (t.BMCServiceDesk__FKStatus__c=='a3w0w0000000AslAAE')
      {
         cseIds.add(t.BMCServiceDesk__FKIncident__c);
      }
      System.debug('After Case IDs'+cseIds);
      for (BMCServiceDesk__Incident__c c : [select id,BMCServiceDesk__incidentDescription__c from BMCServiceDesk__Incident__c where id in :cseIds])
      {
          if(c.BMCServiceDesk__incidentDescription__c!='')
          {     
              c.BMCServiceDesk__FKStatus__c='a3w0w0000000AslAAE';
              c.BMCServiceDesk__incidentDescription__c='Trigger Fire';
              update c;
              
          }    
      }
    }

}
Regards,
SFDC16
  • April 01, 2019
  • Like
  • 0
Below are trigger and error.


Error: Compile Error: Variable does not exist: whatId at line 13 column 14

trigger LinkdTaskToIncident on BMCServiceDesk__Incident__c (before insert) 
{

    List<BMCServiceDesk__Task__c>  task=new  List<BMCServiceDesk__Task__c>();
        
        for(BMCServiceDesk__Incident__c c:Trigger.new)
        {
           if(c.BMCServiceDesk__Is_New_Record__c==true)
           {    
            
             BMCServiceDesk__Task__c t = new BMCServiceDesk__Task__c();
             t.BMCServiceDesk__taskDescription__c=c.BMCServiceDesk__incidentDescription__c;
             whatId=c.id;

             task.add(t);
           }
        }
          
             insert task;    
}
  • March 31, 2019
  • Like
  • 0
Below is my apex trigger and test class 

Apex trigger 

/**
 * @File Name          : NotifyWhenCreated.trigger
 * @Description        : 
 * @Author             : ChangeMeIn@UserSettingsUnder.SFDoc
 * @Group              : 
 * @Last Modified By   : ChangeMeIn@UserSettingsUnder.SFDoc
 * @Last Modified On   : 3/30/2019, 6:06:55 PM
 * @Modification Log   : 
 *==============================================================================
 * Ver         Date                     Author                    Modification
 *==============================================================================
 * 1.0    3/30/2019, 5:55:07 PM   ChangeMeIn@UserSettingsUnder.SFDoc     Initial Version
**/
trigger NotifyWhenCreated on BMCServiceDesk__Incident__c (before insert,before update) {
    
    
       if(trigger.isBefore)
       {
                for(BMCServiceDesk__Incident__c a:trigger.new)
                {
                   
                   if(a.BMCServiceDesk__Is_New_Record__c==true)
                    {
                       
                        a.BMCServiceDesk__incidentDescription__c='Hello Customer Incident Has Been Created And Assigned To You';
                    
                        
                    }
                } 
       }
       
       if(trigger.isUpdate)
       {
           
            for(BMCServiceDesk__Incident__c inc:trigger.new )
            {
                
                   if( inc.BMCServiceDesk__Is_New_Record__c==False)
                   {
                       
                       inc.BMCServiceDesk__incidentDescription__c='Dear Staff Incident Has Been Created And  Assigned To You' ;
                       
                   }
                
            }
       }
}

Test class 

/**
 * @File Name          : NotifyCustomer_Test.cls
 * @Description        : 
 * @Author             : ChangeMeIn@UserSettingsUnder.SFDoc
 * @Group              : 
 * @Last Modified By   : ChangeMeIn@UserSettingsUnder.SFDoc
 * @Last Modified On   : 3/30/2019, 6:12:05 PM
 * @Modification Log   : 
 *==============================================================================
 * Ver         Date                     Author                    Modification
 *==============================================================================
 * 1.0    3/30/2019, 6:10:25 PM   ChangeMeIn@UserSettingsUnder.SFDoc     Initial Version
**/
@isTest()
public  class  NotifyCustomer_Test1
{
        
    public  static testMethod void testNotifyCustomer()
    {
       BMCServiceDesk__Status__c[] status=[SELECT Id, Name FROM BMCServiceDesk__Status__c where name like '%OPENED%'];
       User[] Us =[Select Id,name from user];
       BMCServiceDesk__Impact__c[] impact=[Select id,name from BMCServiceDesk__Impact__c];
       BMCServiceDesk__Category__c[] category=[SELECT Id, Name FROM BMCServiceDesk__Category__c];
        BMCServiceDesk__Urgency__c[] urgency=[select id,name from BMCServiceDesk__Urgency__c];        
             
   if(Us.size()>0 && status.size()>0 && impact.size()>0 && urgency.size()>0)
    {
       BMCServiceDesk__Incident__c inc=new BMCServiceDesk__Incident__c();
       inc.BMCServiceDesk__FKClient__c=Us[0].id;    
       inc.BMCServiceDesk__FKOpenBy__c=Us[0].id; 
       inc.BMCServiceDesk__FKStatus__c=status[0].id; 
       inc.BMCServiceDesk__FKImpact__c=impact[0].id;
       inc.BMCServiceDesk__FKUrgency__c=urgency[0].id;
       inc.BMCServiceDesk__Is_New_Record__c=true;
       insert inc; 
     }
    }              
                   
}
  • March 30, 2019
  • Like
  • 0
Test class for the conditional constructor.

for example '

public class Test()
{
          public List <Dashboard>  fetchdashboard{get;set;}

      Test()
      {
           List<user> s=[select id,name from user]
         if(s.name='xyz')
         {
                 fetchdashboard=[select id name from  Dashboard where                     name like '%test12323%']
         }
        else if()
        {
        }
     }
}

Test class for above code
  • March 05, 2019
  • Like
  • 0
Hello,

How to fetch all data type in picklist in vf page 
  • September 03, 2018
  • Like
  • 0
Hello,
Data not displaying in vf page for the below code .
 public String caseId{get;set;}
*--------Controller--------------*
             public  List<Case> casListId{get; set;}
                  
             public void getDetails()
             {
              //String caseId= System.currentPageReference().getParameters().get('row_id');
                     casListId=new List<Case>();
                     System.debug('Case ID'+caseId);                    
                     casListId=[Select id,CaseNumber from Case where Id ='5007F00000K8gwH'];
                     System.debug('casListId'+casListId);
                  //   return null;
             }
           *----------Vf Page---------*  
<apex:form >
           <apex:pageBlock >
              <table class="Table">
               
                     <apex:repeat value="{!casListId}" var="a" >
                        <tr>
                       <td> <apex:outputText value="{!a.CaseNumber}"/></td>  
                        </tr>
                     </apex:repeat>
               </table>      
             </apex:pageBlock>        
           </apex:form>
I want to delete a specific record (row )from wrapper class on click checkbox. By using a wrapper class I displayed the record on vf page along with a checkbox 

On click checkbox I want delete the record