• Parvinder Singh
  • 49 Points
  • Member since 2014
  • Appirio

  • Chatter
  • 1
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
  • 28
Iam getting the null pointer exception while useing the wrapper class my other wrapper class code are working fine not able to understand what went wrrong in this code. need Help ASAP

public list<WrapperClass> wrapper_variable    {get;set;}
Account_Project_Junction__c projRec             = [SELECT Id,Name,Project__c,Project__r.Name from Account_Project_Junction__c WHERE Id = 'a00O000000KWbzsIAD'];
Escalation_Project_Junction__c EscaProjJunRec     = new Escalation_Project_Junction__c();
EscaProjJunRec.Project__c                         = projRec.Id;
EscaProjJunRec.Project_Name__c                     = projRec.Project__r.Name;
wrapper_variable.add(new WrapperClass(EscaProjJunRec));
//wrapper class
public class WrapperClass{
    public Escalation_Project_Junction__c projectEsca_wrapper{get;set;}
    public WrapperClass(Escalation_Project_Junction__c EPJ){
        projectEsca_wrapper = EPJ;

05:29:16:077 FATAL_ERROR System.NullPointerException: Attempt to de-reference a null object
this error is for the line
wrapper_variable.add(new WrapperClass(EscaProjJunRec));
Wanted to share this as I though this will be helpful for the community, we had a sneario where High Volume Customer Users were getting OP_WITH_INVALID_USER_TYPE_EXCEPTION when creating cases from the community, after some analysis we figure out that the issue was caused by case assignment rules which were adding case teams on cases. Salesforce does not let customer users add cases teams on cases and in our case when Customer creates a Case --> Assignment Rule Fire --> Matching step has a case team assignmnet --> Which fails for customer users.
Hi there,

Is there a way to create a formula field that can help me to identify the last user that changed a specific set of fileds in an opportunity? "Last Modified By" tells me about any changes made to an opportunity but I'd like to limit it to specific fields. 

For example - who was the last user to modify only the Ammount, Contract Start Date or Contract End Date Fields. How can the formula field identify the user that changed only a set list of fields. 

I have a scenario where there are two visualforce pages and two controllers. But I want one VF page with controller to display the details on other VF page is this possible? Please can some one guide?

We have a test class with (SeeAllData=true),
The class recently started failing due to 'Too many SOQL queries: 101 in test class'.

We understand the problem in the code but now we don't seem to be able to update the test class on the live organization 
(In a change set from the sandbox) because the test fails on deploy.

Any way to solve this issue?


I am not sure what I am missing.
when I assigning first  approver getting error. 
(1873818027)|WF_NEXT_APPROVER|Tibisay Montilva|Usuario relacionado|: Channel Manager User 09:40:29.527 (2527557929)|PUSH_NOTIFICATION_INVALID_APP|sf_app_internal|Chatter_for_iOS_Enterprise 09:40:29.687 (2687899006)|PUSH_NOTIFICATION_NO_DEVICES|sf_chttr_apps|Chatter_for_Android 09:40:29.687 (2687919613)|PUSH_NOTIFICATION_NO_DEVICES|sf_chttr_apps|Chatter_for_iOS 09:40:30.344 (3344372401)|CODE_UNIT_FINISHED|Workflow:ApprovalProcessActions 09:40:30.344 (3344506164)|DML_END|[120] 09:40:30.344 (3344608924)|EXCEPTION_THROWN|[120]|System.DmlException: Process failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] 09:40:30.345 (3345319343)|SYSTEM_METHOD_EXIT|[120]|Approval.process(Approval.ProcessRequest) 09:40:30.345 (3345348108)|METHOD_EXIT|[88]|01pU0000001CTpf|My_Class.submitToApprovalProcess(Custom_Object__c)
09:40:30.345 09:40:30.345 (3345518872)|USER_DEBUG|[92]|DEBUG|****ExceptionSystem.DmlException: Process failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] 09:40:30.345 (3345525814)|SYSTEM_METHOD_EXIT|[92]|System.debug(ANY) 09:40:30.345 (3345555691)|SYSTEM_METHOD_ENTRY|[93]|System.DmlException.getMessage() 09:40:30.345 (3345586143)|SYSTEM_METHOD_EXIT|[93]|System.DmlException.getMessage() 09:40:30.345 (3345661592)|SYSTEM_METHOD_ENTRY|[93]|ApexPages.addMessage(ApexPages.Message) 09:40:30.345 (3345690763)|VF_PAGE_MESSAGE|Exception occuredProcess failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] 

The same code works fine in sandbox for same profile and in prod .it is failing.
For some other Partner user it works fine

My code looks like this
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
        req.setComments('Request submitted for approval automatically.');
        req.setNextApproverIds(new Id[] {newApplication.Channel_Manager__c});
        Approval.ProcessResult result = Approval.process(req);

Am I missing any permission or configuration that is causing this error on submitting from partner Portal user.

I have prrovided all the permissions for the object for this user profile.


  • November 06, 2014
  • Like
  • 0
Hi All,

Please bear with me. I only have very basic knowledge in APEX and I'm just reading around. I need assistance creating a button that will generate PDF form on Contact and should contain Contact details. The output would be:

1. Click Generate Job Offer button.
2. There should be a PDF format details.
3. Job Offer should be attached to Notes and Attachment section.

I've tried to use this link from GitHub and it works perfectly fine but my problem is I don't know how to modify this code that will merge the fields in Contact Record. Any assistance is greatly appreciated on how to call the values from Contacts.

Thanks in advance.
Hi all, I am fairly new to apex coding and have created a scheduled class that checks a number of records to fit a criteria then performs a simple update to a checkbox field. The problem is I am getting the Apex CPU time limit exceeded as it is checking through over 5000 records. I believe I need to set this up as a batch to make it work. Can someone help me convert this code to a batch

global class SalesInvoicePaid implements Schedulable {

// Execute method
global void execute(SchedulableContext SC) {

// Code to be executed when the schedule class wakes up
    List <c2g__codaInvoice__c> siv = [SELECT ID, Paid__c
                           FROM c2g__codaInvoice__c
                           WHERE c2g__PaymentStatus__c = 'Paid' AND Paid__c = False AND c2g__InvoiceDate__c > 2014-07-01];        

    for(c2g__codaInvoice__c s: siv){
        s.Paid__c = true;           

// this section of code will abort the current schedule job
try {
} catch (exception e) {system.debug('#### schedule job exception while aborting:' + e);}

// reschedule the job
system.debug('#### schedule job executing');


global static void scheduleNow() {

// this section of code will schedule the next execution 1 minute from now
datetime thisTime = system.now().addHours(24);
integer minute = thisTime.minute();
integer second = thisTime.second();
integer hour = thisTime.hour();
integer year = thisTime.year();
integer month = thisTime.month();
integer day = thisTime.day();

String timeStamp = second + ' ' + minute + ' ' + hour + ' ' + day + ' ' + month + ' ? ' + year;
string jobName = 'SalesInvoicePaid';

SalesInvoicePaid p = new SalesInvoicePaid();
system.schedule(jobName, timeStamp , p);

HI Everyone,

I have been having a weird issue and I don't know where to turn. I have a visualforce component with a Apex Controller. The Compoenent has a Command Button on it and has a method linked to it. When I click the button the method does not seem to trigger. The page just seems to reload and call the controllers constructor. I'm not sure why this is happening. The same code was working yesterday. I did make some changes but when I look at the code I can't seem to find anything wrong. When I put a breakpoint at the beginnig of the Apex Method it doesn't look like the method is even called. The Visualforce compoent is embbeded in a visualforce page that has a controller of it's own. I have no clue as to what the issue is. If you have run into a simmialr situation please let me know what your solution was if you found one. I am running out of options and ideas.

[SELECT Contact.FirstName, Contact.Account.Name from Contact order by Contact.Account.Name  limit 1000]

Why is this query not working
I am currently implementing a pre-chat screen for Live Agent. I want the prescreen to open the account based on screen name (which is working correctly) and then open a case - bypassing record type screen. (Which is not working, it always opens to the "select record type" for case.)

Below is the code. Help me stackexchange, you're my only hope. :-/
<!-- Map the detail inputs to the Account fields --> 
  <input type="hidden" name="liveagent.prechat.findorcreate.map:Account" value="FirstName,first-name;LastName,last-name;Screen_Name__c,screen-name;" />
<!-- Try to find the Account by screen name (exact match) -->
  <input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Account" value="Screen_Name__c,true;" />
  <input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Account" value="Screen_Name__c,true;" />
<!-- If the Account is not found, then create one with the following fields set -->
  <input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Account" value="FirstName,true;LastName,true;Screen_Name__c,true;" />
<!-- Save the Account on the Live Chat Transcript's Account's Loookup -->
  <input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Account" value="Account" />
<!-- Show the Account when it is found or created -->
  <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Account" value="true" />
<!-- Create a Case every time -->
 <input type="hidden" name="liveagent.prechat:caseOrigin" value="Chat" />
  <input type="hidden" name="liveagent.prechat:caseRecordType" value="Incident" />
  <input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Origin,caseOrigin;RecordType,caseRecordType;Subject,drop-down;Description,issue" />
  <input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Origin,true;RecordType,true;Subject,true;Description,issue" />
  <input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Case" value="Case" />
  <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true" />

<!-- Link the Contact to the Case -->
  <input type= "hidden" name="liveagent.prechat.findorcreate.linkToEntity:Account" value="Case,AccountId" />

I have a trigger just with one line of code calling a method in APEX class. The code has 100% coverage in salesforce sandbox, but when I try to deploy the code in live it say 0% of covered and not allowing to deploy.. Can anyone please give suggestions on it?
Hello Developers,
I need to write a schedulable apex class that sends email notifications to users who have not logged in the past 30 days. This is what I have so far but I am getting the error "Error: Compile Error: Method does not exist or incorrect signature: [Messaging.MassEmailMessage].setTargetObjectIds(LIST<User>) at line 12 column 17"

I am not sure where I am going wrong here.
global class NotifyUsers implements Schedulable {

global void execute(SchedulableContext ctx){

    dateTime dt = date.today()-30;    
    id sysAdm = [SELECT id from Profile where Name =: 'System Administrator' LIMIT 1].id;
    List <User> userList = [SELECT Name, Email, LastLoginDate, ISActive, Id From User WHERE IsActive = true AND LastLoginDate <: +dt AND Name != 'IRIS Help' AND ProfileId !=: sysAdm LIMIT 10000];
    if(userList.size() > 0)
                Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
                mail.setTargetObjectIds(userList); // List of  ids of the contact, lead, or User
                mail.setTemplateId('00***********XU'); // Id of the email template
                Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });

  • November 05, 2014
  • Like
  • 0
Can any one help me out in writting test classes for the triggers.I shall appreciate your help.

trigger ReparentComment on CaseComment (before insert) {
Map<String, Case> newCaseMap = new Map<String, Case>();
Set<Id> caseIds = new Set<Id>();
Map<Id, List<CaseComment>> ccMap = new Map<Id, List<CaseComment>>();
List<CaseComment> newCCList = new List<CaseComment>();
for(CaseComment cc : trigger.new) {
List<CaseComment> ccList = ccMap.get(cc.ParentId);
if(ccList == null) ccList = new List<CaseComment>();
ccList.add(cc); ccMap.put(cc.ParentId, ccList);
for(Case c : [Select Id, Subject From Case Where Id in :caseIds Order by CreatedDate])
if(newCaseMap.containsKey(c.Subject)) for(CaseComment cc : ccMap.get(c.Id)) {
CaseComment newCC = cc.clone();
newCC.ParentId = newCaseMap.get(c.Subject).Id;
else newCaseMap.put(c.Subject, c);
for(Case c : [Select Id, Subject From Case Where Subject in :newCaseMap.keySet() And Id not in :caseIds And Status != 'Closed']) for(CaseComment cc : ccMap.get(newCaseMap.get(c.Subject).Id)) {
CaseComment newCC = cc.clone();
newCC.ParentId = c.Id;
insert newCCList;
Thanks in Advance
  • November 05, 2014
  • Like
  • 0
here, my requirments i am create a new lead form web to lead form, insert to attachments objects is it possiable ?
could you send me sample code using javascript or rest api 

Hi all,

I have a problem regarding tying an attribute in a visualforce component to a Controller. THe thing is, i needed some new functionality so i created new controller PaginatorController2. There, i have a property defined like this: 

public object pCon {get;set;}

next I added an attribute to a component: 

<apex:component controller="PaginatorController2"> 
<apex:attribute name="pCon" description="" assignTo="{!pCon }" type="object" required="true"/>

The compiler reports an error: 

<apex:attribute assignTo> cannot be the same as the <apex:attribute name> ( pCon )


Ok, i change the name of the attribute to 'xxxx' or whatever else, but now compiler prints an error: 

Type mismatch for <apex:attribute assignTo>. Value binding to a property of type ANY is required, property specified (pCon) is of type Object.

Now, i can't do anything with this, i have a feeling it's some bug with compilor but it is veeery frustrating, can't create any new component. I didn't want to bother you so i tried the forum first but with no luck. 
http://salesforce.stackexchange.com/questions/54628/cant-create-attribute-with-type-object-in-custom-vf-component?noredirect=1#comment71901_54628  (http://salesforce.stackexchange.com/questions/54628/cant-create-attribute-with-type-object-in-custom-vf-component?noredirect=1#comment71901_54628)

After this, i tried setting the attribute type to be specific, type="BaseListExtension" and it worked, both component and controller compiled properly, but when i wanted to add the component to a page, like any other component, on any other page, it didn't want to accept my changes 
(MyController is of BaseListExtension type)

<c:Paginator2 controller="{!MyController }"></c:Paginator2>

The error produced is 

Wrong type for attribute <urbanhawks:paginator3 controller="{!MyController}">. Expected BaseListExtensionS, found String

And i know i am not doing anything wrong with the code because i am trying to accomplish something that works on several places throughout the project in the same way. 
I would appreciate any help I can get. Thanks.



I'm trying to change the ownership of files in Content to the new owner of an Account when it changes.  I have changed the ownerId field in both ContentDocument and ContentVersion to the new account ownerId.  If I open up the documents in Content and check the File sharing settings I can see that the new Account owner is showing as being shared on all the documents. 

However if I log in as the Account owner and go to 'Files' tab and select 'Files I own' these documents do not show up.  

The files are in Library folders which the Account owners do not have access to.  If however I open a document in the folder and manually share the document in the folder with the new Account Owner (even though it already shows it being shared) then the account owner can then see it.

From this I assume there must be another object that I need to update with the changed ownerId , maybe a FeedItem?? so that the new Account owner can see the document that it is the owner for.

Any ideas?

Posting this in order to help others who, months from now, might Google "OP_WITH_INVALID_USER_TYPE_EXCEPTION" and find this explanation.


We wrote an Apex trigger on the User object, to insert a custom object record anytime a user updates their Chatter status.  This was done to fulfill a client's requirement to audit all Chatter activity.


The trigger worked fine, until one day the client signed up some Chatter Free users.  When such a user tried to update their status, they got a pop-up with an OP_WITH_INVALID_USER_TYPE_EXCEPTION error.


We scratched our collective heads for awhile.  After all, Apex triggers run in "system mode," right?  That is supposed to mean that "object and field-level permissions of the current user are ignored."  And yet this trigger seemed like it was running in "user mode," enforcing restrictions based on who the current user was.


The root cause turned out to be that a Chatter Free user cannot be the owner of a custom object record, and SFDC by default sets the current user as a new record's first owner.  We discovered this when we realized, via experiment, that Apex triggers fired as the result of actions by Chatter Free users could definitely update an existing record, but were having problems creating records.


So the simple solution was to explicitly set the owner of the new record to some fully-licensed user prior to inserting it.