• Anish Singh
  • NEWBIE
  • 0 Points
  • Member since 2015
  • Mr
  • UHG

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 4
    Questions
  • 4
    Replies
I am getting NullPointerException for the below code. At second line(highlighted) the code is giving me exception.
Can anyone please suggest if there is any other way around or if I am missing anything. I can post the further code if required.

------------------------------------------------------------------------------------


public List<objectHistoryLine> getObjectHistory(){
    Id myObjectId = String.valueOf(myObject.get('Id'));
    //String myObjectIdString = String.valueOf(myObject.get('Id'));
    String myObjectAPIName;
    //String contactIdPrefix = Contact.SObjectType.getDescribe().getKeyPrefix();
    Schema.DescribeSObjectResult objectDescription = myObject.getSObjectType().getDescribe();
    
    myObjectFieldMap = objectDescription.fields.getMap();
    objectLabel = String.valueOf(objectDescription.getLabel());

-------------------------------------------------------------------------------------------   
    
Thanks in advance.
I want to merge two different contact by deleting the contact's associated account. My account is encripted because of which i cannot use a standard functionality.
Scenario:
Account (A1) ----> Contact (C1)
Account (A2) ----> Contact (C2)
I want to build a query where C2 gets merged with C1 by deleting A2.

Here is the query that i user, i know its not correct but trying to build. Need your help.


// Queries to get the inserted accounts
Account masterAcct = [SELECT Id, Name FROM Account WHERE Name = 'Acme Inc.' LIMIT 1];
Account mergeAcct = [SELECT Id, Name FROM Account WHERE Name = 'Acme' LIMIT 1];

// Add a contact to the account to be merged
Contact c = new Contact(FirstName='Joe',LastName='Merged'); c.AccountId = mergeAcct.Id;
insert c;

try {
       merge masterAcct mergeAcct;
} catch (DmlException e) {
       // Process exception
       System.debug('An unexpected error has occurred: ' + e.getMessage());
}



Thanks,
Anish Singh
My visual force page taking longer time to render or load the page if the records are more than 100. I am providing you with my VF page & controller class.
Please suggest do i have to use transient in order to overcome this.

---------------------------------------------------------------------------------------------
VF page: (for task):
<apex:pageBlock title="My Tasks" id="pb1" > <div class="slds-col--padded slds-size--1-of-1 myTaskList"> <apex:selectList value="{!selectedFilterTaskString}" styleClass="selectfld" size="1" onchange="filterTasks('{!JSENCODE(selectedFilterTaskString)}')"> <apex:selectOptions id="selectedOpt" value="{!filterTaskList}"/> <apex:actionFunction action="{!fetchRelatedTasks}" name="filterTasks" rerender="taskTabPanel,dataTableInitialization" status="spinnerStatus"> </apex:actionFunction> </apex:selectList> </div> <!-- List to iterate to be shown on page --> <apex:outputPanel id="taskTabPanel"> <div Class="slds-table slds-table--bordered"> <apex:pageBlockTable value="{!taskList}" var="task" styleClass="_dataTable">

____________________________________________________
Controller:
public with sharing class EngTaskListPageCtrl {

public List<Task> taskList   {get;set;} //list of tasks to be shown on page
public List<SelectOption> filterTaskList {get;set;} //option list to be displayed in filter
public String selectedFilterTaskString { get; set;} //selected option from option list options
public Set<ID> BHGroupUserIDs{get; set;}//List of user ids belongs to Behavior Health User Group
private List<String> taskStatusList;

 public void fetchRelatedTasks(){
        try{
            String whereClause = ''; //creates where clause based on various criteria to be passed in Database query
            Id currentUser = UserInfo.getUserId(); //get current logged in user Id
             
            if (selectedFilterTaskString != 'MASCO BH'){
            if(selectedFilterTaskString == 'All Open (next 30 days)'){ 
                whereClause = 'WHERE (ActivityDate <= NEXT_N_DAYS:30) and';
            }
            else if(selectedFilterTaskString == 'Overdue'){ 
                whereClause = 'WHERE ActivityDate <= YESTERDAY and';
            }
            else if(selectedFilterTaskString == 'Today'){
                whereClause = 'WHERE ActivityDate = TODAY and';
            }
            else if(selectedFilterTaskString == 'Today + Overdue'){
                whereClause = 'WHERE ActivityDate <= TODAY and';
            }
            else if (selectedFilterTaskString == 'Tomorrow'){
                whereClause = 'WHERE ActivityDate = TOMORROW and';
            }
            else if (selectedFilterTaskString == 'Next 7 Days'){
                whereClause = 'WHERE ActivityDate = NEXT_WEEK and';
            }
            else if (selectedFilterTaskString == 'Next 7 Days + Overdue'){
                whereClause = 'WHERE (ActivityDate < TODAY OR ActivityDate = NEXT_WEEK) and';
            }
            else if (selectedFilterTaskString == 'This Month'){
                whereClause = 'WHERE ActivityDate = THIS_MONTH and';
            }
            
            //get the tasks based on criteria selected from page
            //DE109368-On Call Communication - Empty Task
            taskList = Database.query('SELECT id,Account.Name,Priority ,Status,WhatID, WhoID,Who.name,ActivityDate,Subject, What.Name,RecordType.Name, Description, '+
                                      'RelatedTo__c,RelatedTo__r.Name,Facility__c,Facility__r.Name,Clinical_Note_Subject_Type__c,type,CreatedDate FROM Task '+whereClause+' OwnerId =:currentUser '+
                                      'AND Status IN :taskStatusList LIMIT 1000');

            }
            //US1115209: Create a Post hospitalization queue for MASCO/OH - Devashri 
            else if (selectedFilterTaskString == 'MASCO BH'  && BHGroupUserIDs.contains(currentUser)){
              taskList.clear();
              List<Engagement__c> mascoEngList = Database.query('SELECT id FROM Engagement__c WHERE Market__c LIKE \'%Masco%\'');
              List<String> engIdList = new List<String>();
            for (Engagement__c eng :  mascoEngList) {
              engIdList.add(eng.Id);
            }
            
              taskList = Database.query('SELECT id,Account.Name,Priority ,Status,WhatID, WhoID,Who.name,ActivityDate,Subject, What.Name,RecordType.Name, Description, '+
                                      'RelatedTo__c,RelatedTo__r.Name,Facility__c,Facility__r.Name,Clinical_Note_Subject_Type__c,type,CreatedDate FROM Task WHERE WhatId IN :engIdList LIMIT 1000');        
            /*List<Task>taskToShows = new List<Task>();
            
            for (Task currentTask :  taskList) {
                if(String.isNotEmpty(currentTask.WhatID) && String.valueOf(currentTask.WhatID).startsWith('a1Y') 
                && engIdList.contains(currentTask.WhatID)){
                    if(Date.Today().daysBetween(currentTask.ActivityDate) <=0){
                      taskToShows.add(currentTask);
                    }    
                }   
            }
            
            taskList.clear();
            taskList.addAll(taskToShows);*/             
            }
            else{
              taskList.clear();
            }
        }
        catch(Exception ex){
            IsErrorOnLoad = true;
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,ex.getMessage()));
            CustomLogger.log(ex,'',ApexPages.currentPage(),LoggingLevel.INFO);
        }
    }

_______________________________________________________

Thanks,
Anish Singh
Hi Guys,
I created a Visual force page and used it in opportunity custom button using Standard COntroller in VF page. The page is opening and redirecting me to desired URL, but I want the URL section on taskbar of VF page to be hidden or encrypted so that the end user cannot edit the opportunity record ID.
Can anyone help me how to achieve this? PFB screenshot for your reference which reflects the VF page URL that I want to hide or encrypt.
VF page link that I want to hide or encrypt
Thanks,
Anish
I am getting NullPointerException for the below code. At second line(highlighted) the code is giving me exception.
Can anyone please suggest if there is any other way around or if I am missing anything. I can post the further code if required.

------------------------------------------------------------------------------------


public List<objectHistoryLine> getObjectHistory(){
    Id myObjectId = String.valueOf(myObject.get('Id'));
    //String myObjectIdString = String.valueOf(myObject.get('Id'));
    String myObjectAPIName;
    //String contactIdPrefix = Contact.SObjectType.getDescribe().getKeyPrefix();
    Schema.DescribeSObjectResult objectDescription = myObject.getSObjectType().getDescribe();
    
    myObjectFieldMap = objectDescription.fields.getMap();
    objectLabel = String.valueOf(objectDescription.getLabel());

-------------------------------------------------------------------------------------------   
    
Thanks in advance.
I like the trailhead but I seem to have more endurace for watching videos.  It seems Udemy doesn't have any courses.   Can anyone recommend any other video resources.
My visual force page taking longer time to render or load the page if the records are more than 100. I am providing you with my VF page & controller class.
Please suggest do i have to use transient in order to overcome this.

---------------------------------------------------------------------------------------------
VF page: (for task):
<apex:pageBlock title="My Tasks" id="pb1" > <div class="slds-col--padded slds-size--1-of-1 myTaskList"> <apex:selectList value="{!selectedFilterTaskString}" styleClass="selectfld" size="1" onchange="filterTasks('{!JSENCODE(selectedFilterTaskString)}')"> <apex:selectOptions id="selectedOpt" value="{!filterTaskList}"/> <apex:actionFunction action="{!fetchRelatedTasks}" name="filterTasks" rerender="taskTabPanel,dataTableInitialization" status="spinnerStatus"> </apex:actionFunction> </apex:selectList> </div> <!-- List to iterate to be shown on page --> <apex:outputPanel id="taskTabPanel"> <div Class="slds-table slds-table--bordered"> <apex:pageBlockTable value="{!taskList}" var="task" styleClass="_dataTable">

____________________________________________________
Controller:
public with sharing class EngTaskListPageCtrl {

public List<Task> taskList   {get;set;} //list of tasks to be shown on page
public List<SelectOption> filterTaskList {get;set;} //option list to be displayed in filter
public String selectedFilterTaskString { get; set;} //selected option from option list options
public Set<ID> BHGroupUserIDs{get; set;}//List of user ids belongs to Behavior Health User Group
private List<String> taskStatusList;

 public void fetchRelatedTasks(){
        try{
            String whereClause = ''; //creates where clause based on various criteria to be passed in Database query
            Id currentUser = UserInfo.getUserId(); //get current logged in user Id
             
            if (selectedFilterTaskString != 'MASCO BH'){
            if(selectedFilterTaskString == 'All Open (next 30 days)'){ 
                whereClause = 'WHERE (ActivityDate <= NEXT_N_DAYS:30) and';
            }
            else if(selectedFilterTaskString == 'Overdue'){ 
                whereClause = 'WHERE ActivityDate <= YESTERDAY and';
            }
            else if(selectedFilterTaskString == 'Today'){
                whereClause = 'WHERE ActivityDate = TODAY and';
            }
            else if(selectedFilterTaskString == 'Today + Overdue'){
                whereClause = 'WHERE ActivityDate <= TODAY and';
            }
            else if (selectedFilterTaskString == 'Tomorrow'){
                whereClause = 'WHERE ActivityDate = TOMORROW and';
            }
            else if (selectedFilterTaskString == 'Next 7 Days'){
                whereClause = 'WHERE ActivityDate = NEXT_WEEK and';
            }
            else if (selectedFilterTaskString == 'Next 7 Days + Overdue'){
                whereClause = 'WHERE (ActivityDate < TODAY OR ActivityDate = NEXT_WEEK) and';
            }
            else if (selectedFilterTaskString == 'This Month'){
                whereClause = 'WHERE ActivityDate = THIS_MONTH and';
            }
            
            //get the tasks based on criteria selected from page
            //DE109368-On Call Communication - Empty Task
            taskList = Database.query('SELECT id,Account.Name,Priority ,Status,WhatID, WhoID,Who.name,ActivityDate,Subject, What.Name,RecordType.Name, Description, '+
                                      'RelatedTo__c,RelatedTo__r.Name,Facility__c,Facility__r.Name,Clinical_Note_Subject_Type__c,type,CreatedDate FROM Task '+whereClause+' OwnerId =:currentUser '+
                                      'AND Status IN :taskStatusList LIMIT 1000');

            }
            //US1115209: Create a Post hospitalization queue for MASCO/OH - Devashri 
            else if (selectedFilterTaskString == 'MASCO BH'  && BHGroupUserIDs.contains(currentUser)){
              taskList.clear();
              List<Engagement__c> mascoEngList = Database.query('SELECT id FROM Engagement__c WHERE Market__c LIKE \'%Masco%\'');
              List<String> engIdList = new List<String>();
            for (Engagement__c eng :  mascoEngList) {
              engIdList.add(eng.Id);
            }
            
              taskList = Database.query('SELECT id,Account.Name,Priority ,Status,WhatID, WhoID,Who.name,ActivityDate,Subject, What.Name,RecordType.Name, Description, '+
                                      'RelatedTo__c,RelatedTo__r.Name,Facility__c,Facility__r.Name,Clinical_Note_Subject_Type__c,type,CreatedDate FROM Task WHERE WhatId IN :engIdList LIMIT 1000');        
            /*List<Task>taskToShows = new List<Task>();
            
            for (Task currentTask :  taskList) {
                if(String.isNotEmpty(currentTask.WhatID) && String.valueOf(currentTask.WhatID).startsWith('a1Y') 
                && engIdList.contains(currentTask.WhatID)){
                    if(Date.Today().daysBetween(currentTask.ActivityDate) <=0){
                      taskToShows.add(currentTask);
                    }    
                }   
            }
            
            taskList.clear();
            taskList.addAll(taskToShows);*/             
            }
            else{
              taskList.clear();
            }
        }
        catch(Exception ex){
            IsErrorOnLoad = true;
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,ex.getMessage()));
            CustomLogger.log(ex,'',ApexPages.currentPage(),LoggingLevel.INFO);
        }
    }

_______________________________________________________

Thanks,
Anish Singh
Hi Guys,
I created a Visual force page and used it in opportunity custom button using Standard COntroller in VF page. The page is opening and redirecting me to desired URL, but I want the URL section on taskbar of VF page to be hidden or encrypted so that the end user cannot edit the opportunity record ID.
Can anyone help me how to achieve this? PFB screenshot for your reference which reflects the VF page URL that I want to hide or encrypt.
VF page link that I want to hide or encrypt
Thanks,
Anish
Hi guys, 

I am getting an error on challenge 3 (reports and dashboards) of the Business Admin Specialist superbadge. I used a brand new playground for this superbadge but I am getting an error which suggest I havent with error code: ZGREYDBI.

Can anyone help?

Thanks,
Craig