• Rohit SharmaG
  • NEWBIE
  • 95 Points
  • Member since 2014

  • Chatter
    Feed
  • 3
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 25
    Replies
Hi,
I got strucked in this example.I want to show the SOQL query result in table format in visualforce.
Apex Code:
public class AccountClass1
{
public list<Account> acc{get;set;}
public List<Contact> ccc{get;set;}
public  List<Account> AccountClass2()
{
 List<Account> acc = [select Name,Phone,Type from Account where Name='capital first'];
 return acc;
}
public  List<Contact>  AccountClass3()
{
  List<Contact> ccc = [SELECT AccountId,Name FROM Contact where AccountId IN(select Id  from Account where Name='capital first')];
  return ccc;
}
}
VIsualForce Code:
<apex:page controller="AccountClass1" sidebar="True" showHeader="true">
  <apex:form >
  <apex:commandButton action="{!AccountClass2}" value="Accountquery" id="ss"/>
  <apex:pageBlock>
  <apex:pageblockTable value="{!acc}" var="a" id="ss">
  <apex:column value="{!a.Name}"/>
  <apex:column value="{!a.Phone}"/>
  <apex:column value="{!a.Type}"/>
  </apex:pageblockTable>
  </apex:pageBlock>
  <apex:commandButton action="{!AccountClass3}" value="Contactquery" id="ds" />
  <apex:pageBlock>
  <apex:pageblockTable value="{!ccc}" var="c" id="ds">
  <apex:column value="{!c.AccountId}"/>
  <apex:column value="{!c.Name}"/>
  </apex:pageblockTable>
  </apex:pageBlock>
  <script>
  </script>
  </apex:form>
</apex:page>

output 
User-added image

After clicking on AccountQuery or ContactQuery I am getting the following output
User-added image

 
I hav a batch apex in account object . it will update account records . but when one single record failed to update then batch apex failed . please help me on this .. below is my code


global class batchAccount2 implements Database.Batchable<sobject>, Database.stateful {
  
    global Database.QueryLocator start(Database.BatchableContext bc){
      
        String query = 'SELECT Id, Name FROM Account';
        return Database.getQueryLocator(query);
    }
      
    global void execute(Database.BatchableContext bc, List<account> scope) {
      
        for(Account a : scope) {
            a.Name = a.Name + 'Updated';
        }
        // update scope;
        Database.update(scope, false);
    } 
      
    global void finish(Database.BatchableContext bc) {
       // Get the AsyncApexJob that represents the Batch job using the Id from the BatchableContext
 AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed,
  TotalJobItems, CreatedBy.Email, ExtendedStatus
  from AsyncApexJob where Id = :BC.getJobId()];
  
 // Email the Batch Job's submitter that the Job is finished.
 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
 String[] toAddresses = new String[] {a.CreatedBy.Email};
 mail.setToAddresses(toAddresses);
 mail.setSubject('BatchJob batchAccount2  Status: ' + a.Status);
 mail.setPlainTextBody('The batch Apex job processed ' + a.TotalJobItems +
  ' batches with '+ a.NumberOfErrors + ' failures. Please modify the error . ExtendedStatus: ' + a.ExtendedStatus);
   
 Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
}
Hi 

Iam trying to hide chatter as my legal team don't want the internal users to use it but it must be enabled to portal users.

How to hide chatter as there is no html area now for html component.

http://www.forcetree.com/2012/04/how-to-hide-chatter-by-default.html

From new release we dont have html area anybody help me with vf page or any othe option to hide on home page and also hide chatter box on right side down on every page.
USER_DEBUG [54]|DEBUG|[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}] using Named Credential: 


    Request code -
    
                HttpRequest feedRequest = new HttpRequest();
                feedRequest.setEndpoint('callout:full_dev_connection/services/apexrest/v1/getContacts');
                feedRequest.setMethod('GET');
                Http http = new Http();
                HTTPResponse res1= http.send(feedRequest);
                System.debug(res1.getBody());
                
                
>>>Destination org code for calling
    -
  @RestResource(urlMapping='/v1/getContacts/*')
   global with sharing class getContact {
     @Httpget
      global static list<contact> fetchAccount(){
        RestRequest req = RestContext.request;
        RestResponse res = Restcontext.response;
        Id accId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
    
        list<contact> lstcontact =[Select id , name,Phone,Fax,Email from contact where Accountid='001O000000Yk7tl'];
        
        return lstcontact ;
      }
   }    
Hi Team,

I am getting insufficient privileges while redirecting URL:
String partialURL = '/p/process/ProcessInstanceWorkitemWizardStageManager?id=' + strAppId;
Debug log : PageReference:/p/process/ProcessInstanceWorkitemWizardStageManager?id=04iA0000004iK3HIAU

Working with system admin but for custom profile getting error even if obejct has Read, create & Edit access.

Please advise.
Rohit Sharma
Hi All,

I have 2 trigger with before event and logic was one for insert and other for update :

Trigger 1:
trigger Test_trigger_event2 on Account (before insert, before update) {

   if (trigger.isBefore) {
        if (trigger.isInsert) {
            //DO SOMETHING
    system.debug('This is inser and Update');

        }
    }
------------------------------------------------------------------------------------------
Trigger 2.

trigger Test_Trigger_event on Account (before update) {

      
  if (trigger.isUpdate)  {
            //DO SOMETHING
        system.debug('@@@@@@@@@@@@ in Update');            

        }
 }

But When i am inserting record trigger 2 was firing , but it should not fired , it will fired only in update  operation ,not in insert operation.
Please let me know what changes needed in trigger 2.
Thanks!!
 
Hi Team,

I want to display dashboard on VF page but unable to disable the "« Go to Dashboard List" and "Find dashboard option". Please assist me on this.

User-added image

Thanks,
Rohit Sharma
 
Hi ALL,

I want to prevent the deletion of the case contact role from the case. So that i want to write a validation/Trigger. 

Please let me kwow Is there any ways to do this.

Thanks in Advance !!!!!!!

Rohit Sharma
Hi Dears,

I am using custom controller and without sharing keyword in apex class. But when i am trying to use a field of object as apex:inputfield then 
security setting are inforcing on VF page.

Object permission @ profile is read and i want to use that fied on vf page as input field. Please assist on this. Its very urgent.

Thanks,
Rohit Sharma
Hi Team,

I want to disable delete option from task. please assist on this.

Thanks,
Rohit Sharma
Hi Dears,

I am using javascript and the Service Console Integration Toolkit.

<A HREF="#" onClick="testOpenSubtab();return false">
    Click here to open a new subtab</A>

Now when i renderAs="pdf" then its is not working. Please assist on this.

Hi Folks,

I am using apex:outputLink in VF page and renderas = "pdf". But "Back" hyperlink is working fine in App, not in Service console.

<table  style="width:100%">
  <tr>
    <td ><apex:image id="theImage" value="{!$Resource.abbottlogo}" /></td>
    <td align="right">   <apex:outputLink value="https://cs11.salesforce.com/{!caseID}{!caseID}" >Back</apex:outputLink> </td>
  </tr>
  </table>

Please assist on this. Thanks in advance !!!!!!!
Hello Dears,

I used
<apex:outputLink value="https://cs11.salesforce.com/{!caseID}">Back</apex:outputLink>

in VF page and  render Pgae as PDF. But when i click on Back page in not navigation to the respective page in IE 10.

Working fine in Crome.

Please assist on this.
Is there any way/free Appexchange product for export all config setting from org/sandbox.

please let me know if any .

Thanks in advance :)


I want to hyperlink as "Back" on PDF to navigate Page to Case list view page -

<div align="right" >
     <b><apex:commandLink target="_blank" action="{!cancel}"  value="Back " id="theCommandLink" /></b>
 </div>

User-added image

It is not working. please assist on this.

Thanks for support !!!!!!!!!!!
/Rohit Sharma
Hello Dears,

I wrote a trigger on the EmailMessage to create a task with the due date value woulde be Date.today()+2. But, the activity date is not getting updated with the given value as Date.today()+2. 
Below is the my assignment for activitydate in the trigger:
ActivityDate = Date.today()+2


But, it is not updating with the given value. By default, it stores today's date.

Please suggest me how to update this field while creating a task.

Thanks, 
Rohitsharma

Hi Dears,

I want to enable Assign using active assignment rules via backend , not from pagelayout. please assist on this.

User-added image
Please let me know how to disable List and Feed :

User-added image
Hi All,

I want to assign task to user, Not to lead/contact .  Case Comment and Case has master details relationship.


trigger TaskForCaseCommentTrigger on Case_Comment__c (after insert)
{
  List<Task> newTasks = new List<Task>();

  //Loop through all records in the Trigger.new collection
  //for(Case_Comment__c cc: Trigger.new)
  
  
   for(integer i=0; i<trigger.new.size(); i++)
  {   
    //List<Case> cases = [select id,Owner.Id from Contact where accountId = :a.Id];
       system.debug('Owner ID----'+trigger.new[i].Case__r.OwnerId);
      
       newTasks.add(new Task(
            ActivityDate = Date.today(),
            WhoID = trigger.new[i].Case__r.OwnerId,
            Status = 'Not Started',
            type = 'Other',
            Priority = 'Normal',
            Subject = 'Case Comment Added',
            description = trigger.new[i].Comment__c
        ));
   }
   insert newTasks ;
}


Hello All,

I would like to display 30k records in the VF page. But as per the Governer limit we can not display 10k with pageblock and repeat.

My list having near 40k records.

please assist on this.

Thanks,
Rohit Sharma
Hello Dears,

Please let me know how to implement Pagination with Standard Controller and Extension used in Apex:Page.
Kindly assist on this.


Thanks,
Rohit Sharma
How to handle LimitException in Apex :

try {
  
//Dynamic SOQL builder
String soql= QueryBuilder+' '+cat1+' '+cat2+ ' '+cstatus+' '+reqCntry+' '+agentCntry+' '+empCntry+' '+reqFstName+' '+reqLstName+' '+reqstUPI+' '+mngUPI+' '+mngName+' '+csOwner;

  //Retrieve the Cases
  cases = Database.query(soql);
    system.debug('###Case search list '+cases);
    system.debug('@@@Case search size '+cases.size());
                 if(cases.size()> 0){
                           displayresult = true;
                           displayresult2 = false;
                  }
                    else{
                         displayresult = false;
                          displayresult2 = true;
                          msg ='No records to display';
                        }                   
    } catch (Exception e) {
                       
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, ''+e));
                   
   }
Hi Team,

I would like to develope a VF page for "Activity History". But Email activity is display as below:

User-added image

I need like as Standard formate  like :

User-added image

Please assist on this. Thanks !!!
Hi Team,

Can we Archive Knowledge automatically based on custom field like- Expiration Date.
Or any other way to archive article auto.



Thanks,
Rohit Sharma
USER_DEBUG [54]|DEBUG|[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}] using Named Credential: 


    Request code -
    
                HttpRequest feedRequest = new HttpRequest();
                feedRequest.setEndpoint('callout:full_dev_connection/services/apexrest/v1/getContacts');
                feedRequest.setMethod('GET');
                Http http = new Http();
                HTTPResponse res1= http.send(feedRequest);
                System.debug(res1.getBody());
                
                
>>>Destination org code for calling
    -
  @RestResource(urlMapping='/v1/getContacts/*')
   global with sharing class getContact {
     @Httpget
      global static list<contact> fetchAccount(){
        RestRequest req = RestContext.request;
        RestResponse res = Restcontext.response;
        Id accId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
    
        list<contact> lstcontact =[Select id , name,Phone,Fax,Email from contact where Accountid='001O000000Yk7tl'];
        
        return lstcontact ;
      }
   }    
Hi Dev's

trigger onecontactforoneaccount on Contact (before insert,before update) {

    if(Trigger.isInsert || Trigger.isUpdate){
        for(Contact con : Trigger.New){
            for(Contact c : [Select id,accountid from contact]){
                if(con.accountid == c.accountid && con.accountid != Trigger.oldmap.get(con.id).accountid){
                    Trigger.oldmap.get(con.id).addError('Duplicate account id');
                }
        }
        }
    }
}


Regards
Lakshmi
Hi,
I got strucked in this example.I want to show the SOQL query result in table format in visualforce.
Apex Code:
public class AccountClass1
{
public list<Account> acc{get;set;}
public List<Contact> ccc{get;set;}
public  List<Account> AccountClass2()
{
 List<Account> acc = [select Name,Phone,Type from Account where Name='capital first'];
 return acc;
}
public  List<Contact>  AccountClass3()
{
  List<Contact> ccc = [SELECT AccountId,Name FROM Contact where AccountId IN(select Id  from Account where Name='capital first')];
  return ccc;
}
}
VIsualForce Code:
<apex:page controller="AccountClass1" sidebar="True" showHeader="true">
  <apex:form >
  <apex:commandButton action="{!AccountClass2}" value="Accountquery" id="ss"/>
  <apex:pageBlock>
  <apex:pageblockTable value="{!acc}" var="a" id="ss">
  <apex:column value="{!a.Name}"/>
  <apex:column value="{!a.Phone}"/>
  <apex:column value="{!a.Type}"/>
  </apex:pageblockTable>
  </apex:pageBlock>
  <apex:commandButton action="{!AccountClass3}" value="Contactquery" id="ds" />
  <apex:pageBlock>
  <apex:pageblockTable value="{!ccc}" var="c" id="ds">
  <apex:column value="{!c.AccountId}"/>
  <apex:column value="{!c.Name}"/>
  </apex:pageblockTable>
  </apex:pageBlock>
  <script>
  </script>
  </apex:form>
</apex:page>

output 
User-added image

After clicking on AccountQuery or ContactQuery I am getting the following output
User-added image

 
What logic do I need to write to get the calls.I have written a wrapper class to fetch the details of the call.
Please help.
Dear Experts,

I have two Salesforce orgs, Sandbox and Production, both with person account enabled.

Now, in sandbox i added custom fields, page layouts and a trigger for person account and i want to deploy theese customization into Production.
I created and uploaded successfully the change set containing the above customization. When, in production, i validate the inbound change set, i get this error: "The PersonAccount object is missing or isn't visible to you." Attached a screenshot.

Could you please help me resolving this issue ? 

User-added image
Thank you very much

 
I hav a batch apex in account object . it will update account records . but when one single record failed to update then batch apex failed . please help me on this .. below is my code


global class batchAccount2 implements Database.Batchable<sobject>, Database.stateful {
  
    global Database.QueryLocator start(Database.BatchableContext bc){
      
        String query = 'SELECT Id, Name FROM Account';
        return Database.getQueryLocator(query);
    }
      
    global void execute(Database.BatchableContext bc, List<account> scope) {
      
        for(Account a : scope) {
            a.Name = a.Name + 'Updated';
        }
        // update scope;
        Database.update(scope, false);
    } 
      
    global void finish(Database.BatchableContext bc) {
       // Get the AsyncApexJob that represents the Batch job using the Id from the BatchableContext
 AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed,
  TotalJobItems, CreatedBy.Email, ExtendedStatus
  from AsyncApexJob where Id = :BC.getJobId()];
  
 // Email the Batch Job's submitter that the Job is finished.
 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
 String[] toAddresses = new String[] {a.CreatedBy.Email};
 mail.setToAddresses(toAddresses);
 mail.setSubject('BatchJob batchAccount2  Status: ' + a.Status);
 mail.setPlainTextBody('The batch Apex job processed ' + a.TotalJobItems +
  ' batches with '+ a.NumberOfErrors + ' failures. Please modify the error . ExtendedStatus: ' + a.ExtendedStatus);
   
 Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
}
Hi All,

I have 3 Profiles(Profile 1,Profile 2,Profile 3) and 3 List Views(List View 1,List View 2 & List View 3):

When user with "Profile 1" loggsin and clicks on "Invoice" object then List View 1 should be displayed on Tab Click.The below is my code for doing that.Within this code now i need to apply "IF Condition for Profile and List View Id".Please help me do this.
<apex:page showHeader="true" tabStyle="Invoice__c" action="/a3R?fcf=00B23000000O2Ou" ></apex:page>

Thanks for Any & All Help...!
Hello Team,

I add one customization filed on the Opportuntiy Object which Data type is Lookup (User). And when user create a new opportunity i want this filed has default vaule as same opportunity owner.

I try to use Processing builder or trigger to fulfill this requirement but the result is not what I expected , is there any customiztion way to fulfill this requirement ?

Thanks
Prabhat
Hello,

I'm trying to connect from a SF context tn another SF context of the same Org via REST API.  I've created a connected App, Auth provider and a Named credentials to be used as an end point.
When trying to send and request, I recieve the following error:
INVALID_SESSION_ID: Session expired or invalid

Any idea??
Thanks
Hi Team,

I am getting insufficient privileges while redirecting URL:
String partialURL = '/p/process/ProcessInstanceWorkitemWizardStageManager?id=' + strAppId;
Debug log : PageReference:/p/process/ProcessInstanceWorkitemWizardStageManager?id=04iA0000004iK3HIAU

Working with system admin but for custom profile getting error even if obejct has Read, create & Edit access.

Please advise.
Rohit Sharma
I have one object named "Order_batch__c" .In that i have records in such a way
I want to separate the data into two records one is parent object "order" and child object "order item"

order consists of fields : customer po,account name, customer id
order item consists of fields : nicomatic pin,quantity ordered

Trigger:
 
trigger orderitem on order_batch__c (after insert , after update) {
 Set<Id> Ids= new Set<Id>();
    for (order_batch__c member : Trigger.new){
        Ids.add(member.Id); 
        
        
        }
 List<order_batch__c> memberList = new List<order_batch__c>([Select Id,Or_customer_PO_Number__c,Or_Nicomatic_p_n__c, Or_clientpn__c,Quantity_Ordered__c,Requested_Date__c,Discount__c,Unit_price__c  From order_batch__c  where Id in :Ids]);
    for(order_batch__c temp : memberList )
    {
        order__c o= new order__c();
        o.Customer_Po__c=o=temp.Or_customer_PO_Number__c;
        insert o;
        Order_Item__c member2 = new Order_Item__c();
       // mermber2.Order__c=temp.Or_customer_PO_Number__c;
        member2.Name = temp.Or_Nicomatic_p_n__c;
        member2.Client_PN__c = temp.Or_clientpn__c;
         member2.Quantity__c = temp.Quantity_Ordered__c;
        member2.Request_Date__c = temp.Requested_Date__c;
         member2.Discount__c = temp.Discount__c;
        member2.Price__c = temp.Unit_price__c;
        insert member2;
        
        
    }
 }
My requirement is to separate records in parent and child records .when ever there is an update in order batch records it has to update accordingly parent or child.

I am getting error in the above trigger .can any body help me regarding this




User-added image
Hi 
I'm getting Error in Test Class like below :
System.DmlException: Upsert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Auto_generated: execution of AfterInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
Test Class:

@isTest 
private class Emailtocase_TestClass
{
     static TestMethod void Emailtocase_TestClass()
    {
        
        Test.StartTest();  
        
        Case c= new Case();
        c.Subject = 'Testing';
        //insert c;
       
        
       Contact con = new Contact();
       con.LastName = 'Testing Contact';
       con.Email = 'test1@gmail.com'; 
       insert con;  
       Contact c1 = [Select id,LastName,Email from Contact where Email = 'test1@gmail.com'];
        
        Case ca = new Case();
        ca.Id = c.Id;
        ca.Subject='Welcome';
        ca.Status = 'email';
        ca.Origin='New';
        ca.ContactId = c1.Id;
        ca.SuppliedEmail= 'test1@gmail.com';
        ca.Task_Taken__c=false;
        ca.OwnerId = '00G90000002Gb76';
        upsert ca;
        
        Account a = new Account();
        a.Domain_Name__c = 'gmail.com';        
        a.Name='Testing Account';
        insert a;
        Account a1 = [Select id,Domain_Name__c,Name,Phone from Account where Domain_Name__c = 'gmail.com'];
        Case cas1= new Case();
        cas1.Subject = 'Testing';
        cas1.SuppliedEmail= 'test@gmail.com';
        
        List<contact> lstcon =new List<contact>();
        contact con1=new contact(lastname='sas',Email = cas1.SuppliedEmail,AccountId=a1.Id);
        lstcon.add(con1);
        insert lstcon;
        
       
        
       Case ca1 = new Case();
        ca1.Id = cas1.Id;        
        ca1.Subject='Welcome';
        ca1.Status = 'email';
        ca1.Origin='New';       
        ca1.AccountId=a1.Id;
        ca1.Task_Taken__c=false;
        ca1.OwnerId = '00G90000002Gb76';       
        ca.ContactId = lstcon[0].Id;
        Upsert ca1;// Here I'm getting error line is -Class.Emailtocase_TestClass.Emailtocase_TestClass: line 57, column 1
      
        Test.StopTest();
        
        
        
    }
}
The above covers 54% so how to solve this error.

Thanks
Can anyone help in below code where i have used the output link under repeat block but its not showing the link.


   <apex:pageBlockTable value="{!sObjectList}" var="res" id="pg">
                <apex:repeat value="{!objectFields}" var="field">
<apex:outputLink title="xyz" value="/apex/payer">
link
</apex:outputLink>
                    <apex:column value="{!res[field]}"/>
                </apex:repeat>
            </apex:pageBlockTable>
Is this something that can be done?  Or do you have to use the standard salesforce tabs approach / all custom if you want to put your own VF pages into a community?
Hi 

Iam trying to hide chatter as my legal team don't want the internal users to use it but it must be enabled to portal users.

How to hide chatter as there is no html area now for html component.

http://www.forcetree.com/2012/04/how-to-hide-chatter-by-default.html

From new release we dont have html area anybody help me with vf page or any othe option to hide on home page and also hide chatter box on right side down on every page.
Hi ALL,

I want to prevent the deletion of the case contact role from the case. So that i want to write a validation/Trigger. 

Please let me kwow Is there any ways to do this.

Thanks in Advance !!!!!!!

Rohit Sharma
Hi Folks,

I am using apex:outputLink in VF page and renderas = "pdf". But "Back" hyperlink is working fine in App, not in Service console.

<table  style="width:100%">
  <tr>
    <td ><apex:image id="theImage" value="{!$Resource.abbottlogo}" /></td>
    <td align="right">   <apex:outputLink value="https://cs11.salesforce.com/{!caseID}{!caseID}" >Back</apex:outputLink> </td>
  </tr>
  </table>

Please assist on this. Thanks in advance !!!!!!!
Hello Dears,

I wrote a trigger on the EmailMessage to create a task with the due date value woulde be Date.today()+2. But, the activity date is not getting updated with the given value as Date.today()+2. 
Below is the my assignment for activitydate in the trigger:
ActivityDate = Date.today()+2


But, it is not updating with the given value. By default, it stores today's date.

Please suggest me how to update this field while creating a task.

Thanks, 
Rohitsharma