• ForceCom
  • NEWBIE
  • 59 Points
  • Member since 2010

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 36
    Questions
  • 60
    Replies

Hello 

 

Automatically create account, opportunity and contact after incoming lead from the app exchange 

We are using custom objects for opportunity. We receive Leads in our system, when someone saves our app from the AppExchange.

We would like to convert immediately this leads to account, contact and opportunity (custom object).

 

Any ideas how to achieve this?

 

Thanks

 

  • July 25, 2013
  • Like
  • 0
Hi All, 

I am having a problem from past 2 days with the force:outputfield on lightning component.

   <force:outputField aura:id="accountLookupOutput" value="{!v.spoc.CBRE_SPOC_Employee__c}" class="slds-hide"></force:outputField>

When loading the component I see the below error . 

"Access Check Failed! ComponentService.getDef():'markup://force:outputLookup' is not visible to 'markup://c:AccountMatrixComponent ".

The locker service have been enabled since the winter 17 release which was few weeks ago. If I remove the force:outputfield , it seems to work fine but the first instance why force:outpufield was added was because of another salesforce bug as explained in below article.
http://salesforce.stackexchange.com/questions/119455/lightning-component-initialization-after-redirect

If I remove force:outputfield , it loads the component with no  issues, but cannot remove it because of the issue explained in above article. Any help is appreciated. 

Thank You, 
Dharani
 
Hi ,

I am trying to create a contentworkspaceDoc , contentWorkspaceDoc allows a document to be shared with multiple libraries. I am have a query where I pull all the existing contentworkspaceDoc from the existing documents.  , I have a query where I pull the workspaces which I have want to check against.
//get contentworkspace
Map<Id, ContentWorkspace>    contentWorkspaceMap =     new Map<Id, ContentWorkspace>([select Id, Name from ContentWorkspace Where Name IN: UserNames ORDER BY Id DESC]);
//Get documents from contentversions
        Map<Id, ContentVersion>        contentVersionMap     =     new Map<Id, ContentVersion>([Select Id, ContentDocumentId, ContentDocument.ParentId from ContentVersion where IsLatest = true AND (record__c IN: dealRecordMap.keySet() OR agreement__c IN: agreementMap.keySet())]);
        set<Id> documentIds = new set<Id>();
        for(contentVersion cvValue :  contentVersionMap.values()){
            documentIds.add(cvValue.contentDocumentId);
        }
        //get all documents
        Map<Id, ContentDocument> cDocumentsMap = new Map<Id, ContentDocument>([Select Id from ContentDocument where Id IN: documentIds]);
    
// get all contentworkspacedoc for which have contentdocumentId in those documentIds set.
        Map<Id, ContentworkspaceDoc> cwSpaceDocMap = new Map<Id, ContentWorkspaceDoc>();
           Map<Id, Id> bigMap;
        for(contentWorkspaceDoc cwSpaceDoc : [select  Id , contentDocumentId, contentWorkspaceId from ContentWorkspaceDoc where contentDocumentId IN: documentIds and isOwner = false ORDER BY contentWorkspaceId ASC]){
            cwSpaceDocMap.put(cwSpaceDoc.Id, cwSpaceDoc);
            bigMap = new Map<Id,Id>{cwSpaceDoc.ContentWorkspaceId => cwSpaceDoc.ContentDocumentId};
        }
      
I am trying to find for each contentworkspace , if there is a corresponding ContentworkspaceDoc with that contentworkspaceId and contentdocumentId. If Yes , do nothing , If no then create a new content workspace Doc , which allows me to share the content document Id with that contentworkspace. Below is the piece of code , I am trying to do this logic. But I am not sure , it works in some scenarios but in some scenarios it picks up the content document Id which is already shared and gives me an error. Any help or advise would be really great. Many Thanks.

Map<Id, contentworkspaceDoc> cwDocNewMap = new Map<Id, contentWorkspaceDoc>();
        for(Id cwId1 : contentWorkspaceMap.keySet()){
            system.debug('entered 1st loop');
            for(contentWorkspaceDoc spaceDoc1 : cwSpaceDocMap.values()){
                system.debug('cwSpaceDocMap '+ cwSpaceDocMap.size());
                system.debug('spaceDoc1'+ spaceDoc1.contentWorkspaceId);
                system.debug('cwId1'+ cwId1);
                system.debug('content document Id' + spaceDoc1.ContentDocumentId);
                if(spaceDoc1.contentWorkspaceId == cwId1){
                    cwSpaceDocMap.remove(spaceDoc1.Id);
                    break;
                }
                 else{
                    
                    ContentWorkspaceDoc cwdoc = new ContentWorkspaceDoc();
                    system.debug('entered');
                    cwDoc.ContentDocumentId = spaceDoc1.contentDocumentId;
                    cwDoc.ContentWorkspaceId = cwId1;
                    cwTocwDocMap.put(cwId1, cwDoc);
                 //   break;
                
                 //   
                }
 
Hi , 

I am trying to call a javascript function after all the required fields are completed. I have client side validation for required fields with  "required = true" on visualforce page. 

Appreciate any help !!

Thanks in advance !!!
Hi ,

I am trying to create a mock response for Http request , I receive the compile error as display below.
Type is not visible: httpcalloutmock

The class is :

@istest
global class MockHttpResponseGenerator implements HttpCalloutMock {
    // Implement this interface method
    global HTTPResponse respond(HTTPRequest req) {
        // Optionally, only send a mock response for a specific endpoint
        // and method.
       System.assertEquals('http://test.bhtp.com/api/quotes', req.getEndpoint());
        System.assertEquals('Post', req.getMethod());
       
        // Create a fake response
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody(mockJSON);
        res.setStatusCode(200);
        return res;
    }
}

Any help would be appreciated .

Thank you

Hi, 

 

I am trying to check if an integer field has a string value , if yes display an error. 

 

if(totalunit != '' && totalunit != null && !Pattern.matches('\\d*', totalunit)){
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'WARNING: Total Unit Quanitity Requested Only Accepts Number.'));
return null;
}

 

I am facing an error saying " Comparison arguments must be compatible types: Integer, String".

 

I would appreciate any help or pointers ...

 

Thank you 

 

Hi, 

 

I am trying to merge two lead records ,please find below the code. 

 

Lead leads= [SELECT Email,company, RFI_Record_Type__c FROM Lead
WHERE email IN:emailSet and Email !=null and Id not IN:leadIds Order By CreatedDate DESC Limit 1];

List<Lead> newLeads=[SELECT Email,company, RFI_Record_Type__c FROM Lead
WHERE Id IN:leadIds and Email !=null];


merge leads newleads;

 

Leads is the master record and newLeads is the duplicate/new records. Both the soql queries return a row , which is good. When I debug , it shows both are merged and the merged record deleted which is good. 

 

But When I again try to assert for the merged value by using a soql over leads as same as the first soql above, it returns the same old record but does not display any merged value. 

 

Any help would be nice to have . 

 

Thank You

 

HI , 

 

I have the below code , which is a part of the code that i am working on. I am able to retrieve the user  record , user Id and also contact Id . When I try to use the system.resetpassword(), it gives me an unknown exception with error Id, it is wierd  as it seems , since the system.resetpassword() tends to work correctly when i test this method in developer console , it does reset the password. Any help would be greatly appreciated.

 

Map<Id,User> usermap= new Map<Id,User>([Select Id,ContactId from User where ContactId IN: contactIdset]);

system.debug('reset password entered');
if(usermap.size()>0){

for(User user1:usermap.Values()){
system.debug('user id'+user1.Id);
system.debug('contact Id '+user1.ContactId);
system.resetPassword(user1.Id,true);

}
}

 

Thanks

HI , 

 

I have the below code , which is a part of the code that i am working on. I am able to retrieve the user  record , user Id and also contact Id . When I try to use the system.resetpassword(), it gives me an unknown exception with error Id, it is wierd  as it seems , since the system.resetpassword() tends to work correctly when i test this method in developer console , it does reset the password. Any help would be greatly appreciated.

 

Map<Id,User> usermap= new Map<Id,User>([Select Id,ContactId from User where ContactId IN: contactIdset]);

system.debug('reset password entered');
if(usermap.size()>0){

for(User user1:usermap.Values()){
system.debug('user id'+user1.Id);
system.debug('contact Id '+user1.ContactId);
system.resetPassword(user1.Id,true);

}
}

 

Thanks

Hi , 

 

I am trying to cover this code but I am not able to cover it even though I satisfy all the conditions. 

 

if(app1.Candidate_Type__c == 'Teacher' && app1.EnrollmentrxRx__Applicant__r.Certification_State__c=='Texas'){
if(app1.Access_Fee_Paid__c){
feeAmountStatement = 'There is no payment due.';
feeAmount = 0.00;
feeAmount=feeAmount.setScale(2, System.RoundingMode.UNNECESSARY);
}else{
if(app1.Application_Fee_Paid__c && app1.EnrollmentrxRx__Admissions_Status__c == 'Accepted'){
feeAmountStatement = 'Please pay the required $375.00 fee to process your application. The application fee is a non-refundable processing charge and is not applicable to any future bill.';
feeAmount = 375.00;
feeAmount=feeAmount.setScale(2, System.RoundingMode.UNNECESSARY);

}else if(app1.EnrollmentrxRx__Admissions_Status__c == 'Application Started'){
feeAmountStatement = 'Please pay the required $50.00 fee to process your application. The application fee is a non-refundable processing charge and is not applicable to any future bill.';
feeAmount = 50.00;
feeAmount=feeAmount.setScale(2, System.RoundingMode.UNNECESSARY);
}
}
}else if(app1.Candidate_Type__c == 'Teacher' && app1.EnrollmentrxRx__Applicant__r.Certification_State__c=='Louisiana'){
if(app1.Access_Fee_Paid__c){
feeAmountStatement = 'There is no payment due.';
feeAmount = 0.00;
feeAmount=feeAmount.setScale(2, System.RoundingMode.UNNECESSARY);
}else{
if(app1.Application_Fee_Paid__c && app1.EnrollmentrxRx__Admissions_Status__c == 'Accepted'){
feeAmountStatement = 'Please pay the required $375.00 fee to process your application. The application fee is a non-refundable processing charge and is not applicable to any future bill.';
feeAmount = 400.00;
feeAmount=feeAmount.setScale(2, System.RoundingMode.UNNECESSARY);

}else if(app.EnrollmentrxRx__Admissions_Status__c == 'Application Started'){
feeAmountStatement = 'Please pay the required $50.00 fee to process your application. The application fee is a non-refundable processing charge and is not applicable to any future bill.';
feeAmount = 50.00;
feeAmount=feeAmount.setScale(2, System.RoundingMode.UNNECESSARY);
}
}
}else if(app1.Candidate_Type__c == 'Principal'){
if(app1.Access_Fee_Paid__c){
feeAmountStatement = 'There is no payment due.';
feeAmount = 0.00;
feeAmount=feeAmount.setScale(2, System.RoundingMode.UNNECESSARY);
}else {
if(app1.Application_Fee_Paid__c && app1.EnrollmentrxRx__Admissions_Status__c == 'Accepted'){
feeAmountStatement = 'Please pay the required $425.00 fee to process your application. The application fee is a non-refundable processing charge and is not applicable to any future bill.';
feeAmount = 425.00;
feeAmount=feeAmount.setScale(2, System.RoundingMode.UNNECESSARY);

}else if(app1.EnrollmentrxRx__Admissions_Status__c == 'Application Started'){
feeAmountStatement = 'Please pay the required $75.00 fee to process your application. The application fee is a non-refundable processing charge and is not applicable to any future bill.';
feeAmount = 75.00;
feeAmount=feeAmount.setScale(2, System.RoundingMode.UNNECESSARY);
}
}
}

 

any help would be great.. thank you .. 

 

Hi , 

 

I want a render a field based on if the user clicks on a link or not. The same way how we can render a field based on the check box.

 

Any insights.....appreciated...

 

Thanks

Hi 

 

I am trying to parse the xml response as found below, but i am facing difficulty in parsing this using Xml Dom class....I am totally stuck here , any help , examples , solutions are  totally appreciated.

 

 
<?xml version="1.0" encoding="UTF-8"?>
<Service_User generator="zend" version="1.0">
<get_user_grades>
<users>
<id_35>
<user>
<id>35</id>
<fullname>SamSmith</fullname>
<username>test@erx.com</username>
<idnumber>003K0000002M9xJIAS</idnumber>
</user>
</id_35>
</users>
<courses>
<id_13>
<course>
<id>13</id>
<fullname>EDTC-5100: Fake Course</fullname>
<shortname>5100</shortname>
<idnumber>
</idnumber>
</course>
</id_13>
</courses>
<gradeitems>
<gradeitem>
<courseid>13</courseid>
<itemtype>mod</itemtype>
<itemname>Assessment 1 - Test Quiz A</itemname>
<itemmodule>quiz</itemmodule>
<iteminstance>10</iteminstance>
<grades>
<grade>
<id>29</id>
<userid>35</userid>
<registrationid></registrationid>
<finalgrade>90.00000</finalgrade>
<gradeletter>A-</gradeletter>
<gradepercent>90.00 %</gradepercent>
<timemodified>1317928200</timemodified>
<deleted>0</deleted>
</grade>
</grades>
</gradeitem>
</get_user_grades>
</Service_User>

 

Thanks

Hi 

 

I am trying to parse the xml response as found below, but i am facing difficulty in parsing this using Xml Dom class....I am totally stuck here , any help , examples , solutions are  totally appreciated.

 

 
<?xml version="1.0" encoding="UTF-8"?>
<Service_User generator="zend" version="1.0">
<get_user_grades>
<users>
<id_35>
<user>
<id>35</id>
<fullname>SamSmith</fullname>
<username>test@erx.com</username>
<idnumber>003K0000002M9xJIAS</idnumber>
</user>
</id_35>
</users>
<courses>
<id_13>
<course>
<id>13</id>
<fullname>EDTC-5100: Fake Course</fullname>
<shortname>5100</shortname>
<idnumber>
</idnumber>
</course>
</id_13>
</courses>
<gradeitems>
<gradeitem>
<courseid>13</courseid>
<itemtype>mod</itemtype>
<itemname>Assessment 1 - Test Quiz A</itemname>
<itemmodule>quiz</itemmodule>
<iteminstance>10</iteminstance>
<grades>
<grade>
<id>29</id>
<userid>35</userid>
<registrationid></registrationid>
<finalgrade>90.00000</finalgrade>
<gradeletter>A-</gradeletter>
<gradepercent>90.00 %</gradepercent>
<timemodified>1317928200</timemodified>
<deleted>0</deleted>
</grade>
</grades>
</gradeitem>
</get_user_grades>
</Service_User>

 

Thanks
ForceCom

Hi 

 

I am trying to reference a custom field on the home page tab of the customer portal. I tried to refer this field in the home page component but i am not able. 

 

Is there a way , how I can  show the custom field value on the home page tab of the customer portal.

 

Any suggestions would be really appreciated.

 

Thanks 

 

Hi 

 

I am trying to create a portal user with the license high volume customer portal user , I see this error....

 

Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: unknown (invalid user or group: 005K0000000DiWW): [unknown]

 

Any help or guidance ...i really appreciate ...

 

Thank you 

 

 

 

We have a custom field in Sales Force and a have a simple web-to-lead form on our website that uses ringlead to pass the lead to Sales Force.

The Custom ID and Name that Sales Force gave us for inclusion on this form (to be attached to the ‘region’ field) is:

0N30000000mnNj

This is a nightmare for clientside javacript/ajax validation as

IT IS NOT WEB COMPLIENT – name an id should not begin with a digit, should begin only with a letter. please see W3 ‘s website:

http://www.w3.org/TR/html401/types.html#type-id

This is a serious problem as I am unable to write ANY JavaScript validation for this field and subsequently data is lost and leads are not being distributed correctly which is harming our business. Why could sales force not spot this and is there a way to customise this custom field name and id so that at least it starts with a letter???

Has anyone come against this issue and found a work-around in JavaScript validation???

 

Any help would be greatly appreciated...

 

Thanks


 

public class reCAPTCHA {
    private static string secret = '6LdggcISAAAAADOONstoCow060IwYpcRXfWbbVvi';
    
    public string publicKey { 
    get
     { 
     return '6LdggcISAAAAAJe6PKGBbzrl3sBH4H6caMGexSrt';
     }
     } 
        private static string baseUrl = 'http://api-verify.recaptcha.net/verify'; 
    
    public string challenge {get; set;} { challenge = null; } 
    public string response {get; set; }  { response = null; } 
    public Boolean correctResponse { get; private set; } { correctResponse = false; } 
    
    public PageReference verify() {
      system.debug( 'verify called ');
          // first time thru, this parameter is null, so no request to make yet
    if ( challenge == null || response == null ) { 
            system.debug( 'verify called null ');
            return verify(); 
          }
                       
      HttpResponse r = makeRequest(  baseUrl ,
           'privatekey='+ secret + 
           '&remoteip=' + remoteHost + 
           '&challenge=' + challenge +
               '&response=' + response +
               '&error=incorrect-captcha-sol'
      );
        
          if ( r!= null ) {  // is null when test methods run
            correctResponse = ( r.getBody().contains('true') );
          } 
          return null;  
    }
    public PageReference reset() {
        challenge = null;
        response = null; 
        
        
        return null; 
    }   
    public static HttpResponse makeRequest(string url, string body)  {
          HttpRequest req = new HttpRequest();   
          HttpResponse response = null;
          req.setEndpoint('http://api-verify.recaptcha.net');
          req.setMethod('POST');
          req.setBody ( body);
          try {
            Http http = new Http();
            response = http.send(req);
            System.debug('response: '+ response);
            System.debug('body: '+ response.getBody());
           
          } catch( System.Exception e) {
             System.debug('ERROR: '+ e);
          }
          return response;
        }   
       
    public string remoteHost { get { string ret = '127.0.0.1';
        // also could use x-original-remote-host 
        map<string , string> hdrs = ApexPages.currentPage().getHeaders();
        if ( hdrs.get('x-original-remote-addr')!= null)
            ret =  hdrs.get('x-original-remote-addr');
        else if ( hdrs.get('X-Salesforce-SIP')!= null)
            ret =  hdrs.get('X-Salesforce-SIP');
        return ret;
    } }
        
    public static  testmethod void test_1() {
        reCaptcha re = new reCaptcha();
        string href = baseUrl;
        re.challenge = re.response = 'foo';
        string publick = re.publicKey; 
        string host = re.remoteHost; 
        re.verify();
    }
    public static  testmethod void test_2() {
        reCaptcha re = new reCaptcha();
        re.verify();
    }
    
}
HI 
I am trying to implement a captcha which is shown in one of the blog post of Salesforce. When I hit submit, the page goes to the next page rather than verifying the values entered by the user as a response....any help, sugggestions will be appreciated....
thanks 

 

Hi 

 

I am facing an issue in writing an test method for the custom controller. 

 

I am not able to capture the page parameters, in the test class.Please find below the code.

 

/*

public class multirecords{
    public List<Registration__c> regs {get; set;}
    public Semester_Schedule__c academic {get; set;}
    Id id = ApexPages.currentPage().getParameters().get('id');
    
    public multirecords(){ 
        
        academic=[Select Id, Name from Semester_Schedule__c where Id=:Id];
            
        regs = new List<Registration__c>();
        regs.add(new Registration__c(Semester_Schedule__c=academic.Id));
        
   
    }
    public void addrow(){
        
        regs.add(new Registration__c(Semester_Schedule__c=academic.Id));
    }
    
    public PageReference save(){
        insert regs;
        PageReference home = new PageReference('/home/home.jsp');
        home.setRedirect(true);
        return home;
    }
}

*/

 

any kind of help, guidance, is truly appreciated.

 

Thanks All

 

Hi 

 

I am trying to use the render function but it does not work for the if function ...

 

As an example...

 

rendered="{A.Session_Formula__c=='Fall 2010'}" works fine ....but 

 

rendered="If({A.Session_Formula__c=='Fall 2011'} || {A.Session_Formula__c=='Winter 2011'} ),true,false"

 

This does not work , I do not have an idea why this is behaving this way....

 

I would really appreciate any kind of help from anyone....

 

 

Thank you All .....

 

 

 

Hi

 

I want to assign a owner in queue on the contact record. There are no queues on the contact object. How can I do this. ???

 

 

Please help..!! Any help is appreciated.

 

 

Thanks All

 

Hi

 

I am trying to create an mail merge button on an custom object...I created the button it works well...but I cannot pre populate the contact record .....i.e the option which says  Specify the contact to merge with the Word document:....

 

/mail/mmchoose.jsp?id={!Custom_Object__c.Id}&2={!Contact.Contact_Record_ID__c}

 

 

I would really appreciate any help/advises....

 

Thanks All

 

 


 



Hi ,

I am trying to create a contentworkspaceDoc , contentWorkspaceDoc allows a document to be shared with multiple libraries. I am have a query where I pull all the existing contentworkspaceDoc from the existing documents.  , I have a query where I pull the workspaces which I have want to check against.
//get contentworkspace
Map<Id, ContentWorkspace>    contentWorkspaceMap =     new Map<Id, ContentWorkspace>([select Id, Name from ContentWorkspace Where Name IN: UserNames ORDER BY Id DESC]);
//Get documents from contentversions
        Map<Id, ContentVersion>        contentVersionMap     =     new Map<Id, ContentVersion>([Select Id, ContentDocumentId, ContentDocument.ParentId from ContentVersion where IsLatest = true AND (record__c IN: dealRecordMap.keySet() OR agreement__c IN: agreementMap.keySet())]);
        set<Id> documentIds = new set<Id>();
        for(contentVersion cvValue :  contentVersionMap.values()){
            documentIds.add(cvValue.contentDocumentId);
        }
        //get all documents
        Map<Id, ContentDocument> cDocumentsMap = new Map<Id, ContentDocument>([Select Id from ContentDocument where Id IN: documentIds]);
    
// get all contentworkspacedoc for which have contentdocumentId in those documentIds set.
        Map<Id, ContentworkspaceDoc> cwSpaceDocMap = new Map<Id, ContentWorkspaceDoc>();
           Map<Id, Id> bigMap;
        for(contentWorkspaceDoc cwSpaceDoc : [select  Id , contentDocumentId, contentWorkspaceId from ContentWorkspaceDoc where contentDocumentId IN: documentIds and isOwner = false ORDER BY contentWorkspaceId ASC]){
            cwSpaceDocMap.put(cwSpaceDoc.Id, cwSpaceDoc);
            bigMap = new Map<Id,Id>{cwSpaceDoc.ContentWorkspaceId => cwSpaceDoc.ContentDocumentId};
        }
      
I am trying to find for each contentworkspace , if there is a corresponding ContentworkspaceDoc with that contentworkspaceId and contentdocumentId. If Yes , do nothing , If no then create a new content workspace Doc , which allows me to share the content document Id with that contentworkspace. Below is the piece of code , I am trying to do this logic. But I am not sure , it works in some scenarios but in some scenarios it picks up the content document Id which is already shared and gives me an error. Any help or advise would be really great. Many Thanks.

Map<Id, contentworkspaceDoc> cwDocNewMap = new Map<Id, contentWorkspaceDoc>();
        for(Id cwId1 : contentWorkspaceMap.keySet()){
            system.debug('entered 1st loop');
            for(contentWorkspaceDoc spaceDoc1 : cwSpaceDocMap.values()){
                system.debug('cwSpaceDocMap '+ cwSpaceDocMap.size());
                system.debug('spaceDoc1'+ spaceDoc1.contentWorkspaceId);
                system.debug('cwId1'+ cwId1);
                system.debug('content document Id' + spaceDoc1.ContentDocumentId);
                if(spaceDoc1.contentWorkspaceId == cwId1){
                    cwSpaceDocMap.remove(spaceDoc1.Id);
                    break;
                }
                 else{
                    
                    ContentWorkspaceDoc cwdoc = new ContentWorkspaceDoc();
                    system.debug('entered');
                    cwDoc.ContentDocumentId = spaceDoc1.contentDocumentId;
                    cwDoc.ContentWorkspaceId = cwId1;
                    cwTocwDocMap.put(cwId1, cwDoc);
                 //   break;
                
                 //   
                }
 
Hello,

I have a trigger (see below) that works in my Sandbox and is covered by my test in my sandbox.  When I try to deploy to production, I get the error:

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, UniqueDelivID: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.UniqueDelivID: line 15, column 1: []

Can anyone help as to why I am getting this error?

Trigger:
//Assigns a unique ID to each deliverable in every Opportunity so DyNad can track.
trigger UniqueDelivID on OpportunityLineItem (before insert, before update) {   

    Set<ID> setOliIds = new Set<ID>();
        for(OpportunityLineItem oli:Trigger.new){
            setOliIds.add(oli.Id);
        }
        Map<ID, OpportunityLineItem> mapOli = new Map<ID, OpportunityLineItem>([SELECT Id, Opportunity.Max_Deliv_Hx__c, Max_Deliv__c
                                                                                FROM OpportunityLineItem
                                                                                WHERE Id in:setOliIds]);
        if(mapOli.size()>0){

            for(OpportunityLineItem oli1:Trigger.New){
                IF(mapOli.containsKey(oli1.Id) && oli1.Max_Deliv__c == null){
                    oli1.Max_Deliv__c = mapOli.get(oli1.Id).Opportunity.Max_Deliv_Hx__c + 1;
                }
            }
        }

}


  • July 23, 2014
  • Like
  • 0
More of an FYI post as I think I have a workaround for now, but my Force.com IDE (version 28.0) was having an issue with workflows all of a sudden.  This worked fine previously.  When selecting Workflow Field Updates, the package would appear empty.  The package.xml would include the field updates in the list, but there would be no workflow folder under Src.  It appears as though my IDE is pulling down the package as version 15.0, which presumably doesn't have workflow field update support (workflow rules still pulled down okay).  I update the package.xml version to = 28.0 and the workflow rules now appear correctly.  No idea how this versioning change is happening.  I've used this IDE for a while and had not previous issues until this month.  I've tried to go to the latest Eclipse plugin, but I have apparent JRE issues where the select component screen does not render correctly or is blank - no clue how to resolve that.
SOQL question : Here is what i am trying to do.

for (claim__c clm : shortlistedclaims){
Map<Date,Decimal> tad = new Map<Date,Decimal>();

AggregateResult[] groupedResults = [SELECT Begin_Date__c, SUM(Wages__c) FROM Wages__c where claim__c =: clm.id GROUP BY Begin_Date__c];

for (AggregateResult ar : groupedResults) {
tad.put((Date)ar.get('Begin_Date__c'),(Decimal)ar.get('expr0'));
}

ClaimtoMAP.put(clm.id,tad);
}

This works fine but leads to 'Too many SOQL statements' error since the query is inside the loop.

In general, Is it possible to populate Map<Id,Map<Date,Decimal>> in a single query? If not, any workaround to this problem?
Hi all,

I have multiple records in the list in Apex and want to display them like below by using apex:dataTable. Is it possible to do that?

Let's say I have three contact records,
Contact A
First Name : John
Phone No. : 123xx

Contact B
First Name: Emily
Phone No. 567xx

Contact C
First Name: Bob
Phone No. 987xx


I want to display three records like this table↓

==================
|  First Name  |  John    |
--------------------------------
|  Phone          |  123xx   |
================== 
First Name  |  Emily   |
--------------------------------
Phone          |  567xx   |
==================
First Name  |  Bob      |
--------------------------------
Phone          |  987xx   |
==================



*****
I could achieve this table sturucture by using apex:repeat and HTML table tag but I want to know if it is possible by using apex:dataTable
here is my sample code
<table>
 <apex:repeat value="{!lcontactList}" var="c">
  <tr><td>FirstName</td><td>{!c.FirstName}</td></tr>
  <tr><td>Phone</td><td>{!c.Phone}</td></tr>
 </apex:repeat>
</table>

Thank you in advance!
  • July 21, 2014
  • Like
  • 0
Hi Experts,

I have some confusion on Trigger please let me clarify. Below is my requirement,

I want to update one field(TaskCount) in lead when the task status is completed.I write the trigger for that it's working fine.Below is code


trigger TasksCountUpdateonLead on Task (after insert, after update)

    public set<Id> LeadIDs = new Set<Id>();
    public list<Lead> LeadsToUpdate = new List<Lead>();
    public List<Task> deletetskList=new List<Task>();
   
    //Build the list of Leads to update
    if(Trigger.isInsert || Trigger.isUnDelete || Trigger.isUpdate)
    {
       for(Task tsk: Trigger.new)
       {
           String objName = (tsk.WhoId).getSObjectType().getDescribe().getName();//fetching Object name from id
           system.debug('objName..........'+objName);
           if(objName=='Lead')
           LeadIDs.add(tsk.WhoId);
           system.debug('LeadIDs.....'+LeadIDs);
       }
     }
   
    if(LeadIDs.size()>0)
    {
        for(Lead l: [Select l.Id, l.TaskCount__c,l.Status, (Select Id From Tasks where IsClosed = True) From Lead l where Id in :LeadIDs])
        {
            Lead oldlead = trigger.oldmap.get(l.Id);
            LeadsToUpdate.add(new Lead(Id=l.Id, TaskCount__c = l.Tasks.size()));
            update LeadsToUpdate;
        }
    }
}


Here i want one change When the lead status is changed from 'open-not contacted' to 'closed-converted' the taskcount is reset to zero.after the status is changed to 'closed-converted' the new completed tasks only counted.

     Could you please help me how to achieve this.Thanks in advance

Thanks,
Venkat
 
Hi ,

I am trying to create a mock response for Http request , I receive the compile error as display below.
Type is not visible: httpcalloutmock

The class is :

@istest
global class MockHttpResponseGenerator implements HttpCalloutMock {
    // Implement this interface method
    global HTTPResponse respond(HTTPRequest req) {
        // Optionally, only send a mock response for a specific endpoint
        // and method.
       System.assertEquals('http://test.bhtp.com/api/quotes', req.getEndpoint());
        System.assertEquals('Post', req.getMethod());
       
        // Create a fake response
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody(mockJSON);
        res.setStatusCode(200);
        return res;
    }
}

Any help would be appreciated .

Thank you
Hi,
Can anyone help me. I am getting wrong date when i am trying to take object's date and time seperately in visualforce page. My code is given below.


<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
     <apex:param value="{!call.Call_Date_Time__c}"/>                                                   
 </apex:outputText>

If the date is given 11/25/2013 then it is Printing 11/26/2013
and the same thing happening with time. I want to print date and time seperately. Please help me.

Below button opens in a separate tab. Originally this is the functionality I wanted but now I need to change to have it open in the existing page. 

How can I do this?

<apex:column >
                   <apex:commandButton onclick="return window.open('{!obj.LoginURL__c}')" value="Login" >
                       <Apex:outputLink value="{!obj.LoginURL__c}"/>
                   </apex:commandbutton>
               </apex:column>
What is the use of Person Acccounts?

Hi All,

 

Now,am working on web-to-lead using custom controller.I have written a workflow to send a email alert.When I give the inputs for required fields and submit it. Lead info is not stored in Lead object and in debug log , i have seen the following exception,

System.DmlException: Insert failed. First exception on row 0; first error: UNAVAILABLE_RECORDTYPE_EXCEPTION, Unable to find default record type

 

I have set the default record type for Lead.But Lead is not stored.

 

Whenever I deactivated the workflow, it works fine and there is no exception arises .Please guide me to clear this one.

 

Thanks in advance.

I have a trigger I would like to roll out to production, but I am getting errors with test classes from installed packages.

 

Specifically related to Chatter Answers.  I am unable to delete or inactivate chatter_answers_question_escalation_to_case_trigger.

 

Any suggestions would be helpful.

 

 

  • July 24, 2013
  • Like
  • 0

I'd like to use Eclipse's Task Tags to manage TODO's, FIXME's, etc. inside of Apex Classes.

 

Currently, this functionality works on components, but not on classes.

 

Are there any plans to add support to the IDE for this feature?