• deepak kumar 13
  • NEWBIE
  • 40 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 12
    Replies
Hi,
i am getting attempt de-reference null object error when i click save button in lightning component.

Here is my Lightning component code:

<aura:component implements="flexipage:availableForAllPageTypes,force:lightningQuickActionWithoutHeader,force:hasRecordId" 
                controller="PAY_SiteBudgetController">
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="sites" type="Clinical_Site__c" />
    <aura:attribute name="sitebudget" type="PAY_Site_Budget__c" 
                    default="{'sobjectType':'PAY_Site_Budget__c',
                              'Status__c': 'Planned',
                              'Name':'',
                              'Description__c':''}"/> <!--default to empty record-->
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
                                                                 
    <div class="slds-page-header" role="banner">
        <p class="slds-text-heading--label">Site Budget</p> 
        <h1 class="slds-page-header__title slds-m-right--small
                   slds-truncate slds-align-left">Create Site Budget</h1>
    </div>
    
    <ui:inputText aura:id="requestField" value="{!v.sitebudget.Name}" label="Site Budget ID" disabled="true"/>
    
    <ui:inputSelect label="Status" aura:id="requestField" value="{!v.sitebudget.Status__c}">
      <aura:iteration items="{!v.sitebudget}" var="sts">
          <option value="{!sts}" text="{!sts}"/>
      </aura:iteration>
    </ui:inputSelect>
     
     <lightning:textarea aura:id="requestField" name="desc" label="Description" maxlength="255"
                     value="{!v.sitebudget.Description__c}" />
    
    <lightning:button label="Save" onclick="{!c.handleSave}" variant="brand" class="slds-m-top--medium"/>
</aura:component>

And Lightning controller :
({
    doInit : function(component, event, helper) {       
        var action =component.get("c.getSite");
        action.setParams({"SiteId":component.get("v.recordId")});
        action.setCallback(this, function(response) {
            var state = response.getState();
            console.log('--rturn payee --' + JSON.stringify(response.getReturnValue()));
            if(component.isValid() && state === "SUCCESS") {
                component.set("v.sites", response.getReturnValue());
            } else {
                console.log('Problem getting account, response state: ' + state);
            }
        });
        
        $A.enqueueAction(action);
        
        var action_reqType = component.get("c.getStatusValues")       
        action_reqType.setCallback(this, function(response) {
            var state = response.getState();
            console.log('--rturn type --' + JSON.stringify(response.getReturnValue()));
            if(state === "SUCCESS") {
                component.set("v.sitebudget", response.getReturnValue());
            } else {
                console.log('Problem getting request Type, response state: ' + state);
            }
        });
        $A.enqueueAction(action_reqType);
    }, 
    
    handleSave:function(component, event, helper){
        var SaveSiteBudg = component.get("c.SaveSiteBudget");        
        SaveSiteBudg.setParams({            
            "budget":component.get("v.sitebudget"),
            "siteId":component.get("v.recordId")
        });
        
        SaveSiteBudg.setCallback(this, function(response){
            var state=response.getState();
            var resultsToast= $A.get("e.force:showToast");
            if(state=="SUCCESS"){
                resultsToast.setParams({
                    "title":"Success!",
                    "message":"New Site Budget is Created",
                    "type": "success,"
                });
                 $A.get("e.force:closeQuickAction").fire();
                 resultsToast.fire();
                 $A.get("e.force:refreshView").fire();
            }
        });        
         
          $A.enqueueAction(SaveSiteBudg);
    }
})

And apex controller :
public with sharing class PAY_SiteBudgetController {
 
 @AuraEnabled
 public static Clinical_Site__c getSite (Id SiteId){
       system.debug('--SiteId--'+SiteId);
       return [Select id,Name from Clinical_Site__c where id=:SiteId];
 }
 
 @AuraEnabled
 public static PAY_Site_Budget__c SaveSiteBudget (PAY_Site_Budget__c budget, Id siteId){
    system.debug('--sitebudget--'+budget.Status__c);
    system.debug('--siteId--'+siteId);
    system.debug('--budget--'+budget);
     if (siteId!=null)
     budget.Site__c=siteId;     
     try{     
          upsert budget;
      }
       catch(exception ex){
            
       }
      return budget;
 }
 
 /**/
 @AuraEnabled
 public static list<string> getStatusValues(){     
     List<string>options=new list<string>();     
    Schema.DescribeFieldResult fieldResult = PAY_Site_Budget__c.Status__c.getDescribe();
    List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
    for (Schema.PicklistEntry f: ple) {
        options.add(f.getLabel());
    } 
    return options; 
 }

Getting error : apex controller :SaveSiteBudget in this method as Attempt dereference null object and also 'budget' value i am getting null but in 'siteId' getting value in apex controller. 
Please Help me to fix it.

Thanks

 
Hi,

In my VF page i am using pagination using data tables. Datatable is working fine in pageblock table. And also i need to implement inline edit option in the datatable. When i edit any column using inline editor its working fine in 1st page. When i move to second page and next pages, inline edit option is not working. Please help to fix the code.

/* Datatable code */
j$ = jQuery.noConflict();
        var editor;    
        j$(document).ready( function () {
           var Searchtable1 = j$('[id$="Table1"]').DataTable({                                
          })


/* VF Page block table */

<apex:pageblock id="pgblk3" rendered="{!EditAll}" title="Edit All Line items">
      <apex:pageblockbuttons >
        <apex:commandbutton value="Save" action="{!SaveEditItems}" id="savebutton"/>
        <apex:commandbutton value="Cancel" action="{!cancelbton}" id="cancelbutton"/>
      </apex:pageblockbuttons>
        <apex:pageblocktable title="Edit Study Country Budget Items" value="{!EditAllItems}" var="scl" id="Table1">              
          <apex:column headerValue="Budget Item Id">         
             <apex:outputfield value="{!scl.Name}"/>                    
          </apex:column>         
       
         <apex:column headerValue="Description">
          <apex:actionregion >
             <apex:outputfield value="{!scl.Description__c}">
               <apex:inlineEditSupport event="ondblClick" showOnEdit="savebutton,cancelbutton" />
             </apex:outputfield> 
             </apex:actionregion>
         </apex:column>
                       
          <apex:column headerValue="Budget Library">
           <apex:actionregion >
             <apex:outputfield value="{!scl.Budget_Library__c}">
               <apex:inlineEditSupport event="ondblClick" showOnEdit="savebutton,cancelbutton" />
             </apex:outputfield>
            </apex:actionregion>
         </apex:column>
         
         <apex:column headerValue="Estimated Cost Max">
           <apex:actionregion >
            <apex:outputfield value="{!scl.Estimated_Cost_Max__c}">
             <apex:inlineEditSupport event="ondblClick" showOnEdit="savebutton,cancelbutton" />
            </apex:outputfield>
           </apex:actionregion>
         </apex:column>
         
         <apex:column headerValue="Estimated Cost Min">
           <apex:actionregion >
             <apex:outputfield value="{!scl.Estimated_Cost_Min__c}">
               <apex:inlineEditSupport event="ondblClick" showOnEdit="savebutton,cancelbutton" />
             </apex:outputfield>
            </apex:actionregion>
         </apex:column>
      </apex:pageblocktable>
    </apex:pageblock>


 
Hi Below is my VF page i have 3 lookup fields based on lookup field i am opening new custom lookup page. And selected records should get populated into lookup field. But the problem is if i select any record it navigates to new tab and opens record detail page. and i am using javascript to get selected values.Please suggest me where i am doing mistake in javascript.


Below is my vf page

<apex:page standardController="Target_Members__c" extensions="NewTargetMember">
<apex:sectionHeader title="Target Member Edit" subtitle="New Target Member"/>
<script type="text/javascript">
var objectName ;
var accId;
function openemailPopup(obj,objname,objlabel)
{
currConColumn = obj;
objectName=objname;
var likeString = (obj.getElementsByTagName('input')[0]).value;
var url ;
var additionalFilter=''; if(objname=='Account'){
additionalFilter='Email__c !=null and Status__c=\'Active\' and HasEmailOptOut__c!=true and Mail_Opt_Out__c!=true and Fax_Opt_Out__c!=true and Do_Not_Call__c!=true and Debarred__c != true and (Type=\'Clinical\'or Type=\'Hospital\')';
url = '{!$Page.CustomLookUpPopUpPage}'+"?likestring="+likeString+"&obj="+objname+"&objlb="+objlabel+"&additionalFilter="+additionalFilter;
}
if(objname=='Contact'){
additionalFilter='Accountid!=null and Email!=null and Status__c=\'Active\' and HasOptedOutOfEmail!=true and DoNotCall!=true and Mail_Opt_Out__c!=true and HasOptedOutOfFax!=true and Debarred__c!=true and (Type__c=\'Investigator\' OR Type__c=\'Physician\' OR Type__c =\'Physician Investigator\') ';
url = '{!$Page.CustomLookUpPopUpPage}'+"?likestring="+likeString+"&obj="+objname+"&objlb="+objlabel+"&additionalFilter="+additionalFilter;
}
if(objname=='CTMax__Patient__c') {
additionalFilter='Email__c!=null and Opt_In__c!=true and Do_Not_Call__c!=true and Fax_Opt_Out__c!=true and Mail_Opt_Out__c!=true'; url = '{!$Page.CustomLookUpPopUpPage}'+"?likestring="+likeString+"&obj="+objname+"&objlb="+objlabel+"&additionalFilter="+additionalFilter;
}
openWind(url);
return false;
}
function openWind(URL) {
curPopupWindow = window.open(URL, "_blank","width=600, height=400,dependent=no,resizable=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=1", false);
}
function setSelectedDocumentDetails(etId,etName) {
// alert('-etId--'+etId);alert('-etName--'+etName);
var inputArr = currConColumn.getElementsByTagName('input');//alert('inputArr--------'+inputArr);
inputArr[0].value = etName; inputArr[1].value = etId; //s = s.substring(0, s.length - 4) // alert(inputArr[1].value); inputArr[1].value = inputArr[1].value.substring(0, inputArr[1].value.length - 3); // alert(inputArr[1].value);
if(curPopupWindow != null) {
curPopupWindow.close();
}
currConColumn = null;
return false;
} </script>
<apex:form id="theForm">
<apex:actionFunction name="callme" action="{!setfieldvals}" reRender="theForm" status="sts"/>
<apex:pageMessages id="msg"/>
<apex:actionStatus id="sts" style="align:center;" >
<apex:facet name="start" >
<apex:image value="/img/loading.gif" title="Processing..."/>
</apex:facet>
<apex:facet name="stop">
</apex:facet>
</apex:actionStatus>
<apex:pageBlock Title="Target Member Edit" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!gosave}" />
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageblocksection title="Information">
<apex:inputfield value="{!target.Multi_Channel_Recruitment__c}"/>
<!--------------------------Field Set Goes Here--------------------------------> <apex:repeat value="{!$ObjectType.Target_Members__c.FieldSets.TargetMemberPage}" var="fs">
<apex:inputField value="{!target[fs]}" required="{!OR(fs.Required,fs.DBRequired)}"/>
</apex:repeat>
</apex:pageblocksection>
<!-----------------------------Target Institution-------------------------------->
<apex:pageblocksection title="Internal Target Member" columns="2">
<apex:pageblocksectionitem >
<apex:outputLabel value="{!$ObjectType.Target_Members__c.fields.Target_Institution__c.label}"/>
<apex:outputpanel id="p1">
<apex:inputtext value="{!accounText}">
<apex:actionSupport event="onchange" action="{!setfieldvals}" reRender="theForm" status="sts"/>
</apex:inputtext>
<a id="cclookup" href ="" style="cursor: pointer" onClick="javascript:return openemailPopup(this.parentNode,'Account')">
<img src="/s.gif" class="lookupIcon" onblur="this.className = 'lookupIcon';" onfocus="this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" /></a>
<apex:inputhidden value="{!accId}" id="hid">
</apex:inputhidden>
</apex:outputpanel>
</apex:pageblocksectionitem>
<!--<apex:inputField value="{!target.Target_Institution__c}"/>-->
<!-----------------------------Target Patient--------------------------------->
<apex:pageblocksectionitem >
<apex:outputLabel value="{!$ObjectType.Target_Members__c.fields.Target_Patient__c.label}"/>
<apex:outputpanel id="p2">
<apex:inputtext value="{!patientText}">
<apex:actionSupport event="onchange" action="{!setfieldvals}" reRender="theForm" status="sts"/>
</apex:inputtext>
<a id="cclookup" href ="" style="cursor: pointer" onClick="javascript:return openemailPopup(this.parentNode,'CTMax__Patient__c','Patient')"> <img src="/s.gif" class="lookupIcon" onblur="this.className = 'lookupIcon';" onfocus="this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" /></a>
<apex:inputhidden value="{!patId}" id="hid1">
</apex:inputhidden>
</apex:outputpanel>
</apex:pageblocksectionitem>
<!-----------------------------Target Physician--------------------------------->
<apex:pageblocksectionitem >
<apex:outputLabel value="{!$ObjectType.Target_Members__c.fields.Target_Physicians__c.label}"/>
<apex:outputpanel id="p3">
<apex:inputtext value="{!contactText}">
<apex:actionSupport event="onchange" action="{!setfieldvals}" reRender="theForm" status="sts"/>
</apex:inputtext> <a id="cclookup" href ="" style="cursor: pointer" onClick="javascript:return openemailPopup(this.parentNode,'Contact')">
<img src="/s.gif" class="lookupIcon" onblur="this.className = 'lookupIcon';" onfocus="this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" /></a>
<apex:inputhidden value="{!conId}" id="hid2">
</apex:inputhidden>
</apex:outputpanel>
</apex:pageblocksectionitem>
<apex:inputField value="{!target.Target_Clinical_Site__c}"/>
</apex:pageblocksection>
<!-----------------------------Field Set Goes here--------------------------------->
<apex:pageblocksection title="Prospect Information">
<apex:repeat value="{!$ObjectType.Target_Members__c.FieldSets.ProspectTargetMemPage}" var="fd">
<apex:inputField value="{!target[fd]}" required="{!OR(fd.Required,fd.DBRequired)}"/>
</apex:repeat>
</apex:pageblocksection>
</apex:pageBlock>
</apex:form>
</apex:page>


Thanks,
Deepak
hi,
I have a VF Page it contains search input search box and search button.If i entered any value in search text box like "Car" it should redirect from VF page to the google search page with keyword name and displays results regarding cars. 

Is it possible using VF page.
Please suggest me how to approach...

Thank you.
 
Hi all,

I have a requirement that i have to display 3 objects like contact,user and lead. According to the object selection it should display all fields of the corresponding object in dropdown list,also operators in dropdown and search value in input text box in a single row.

When i select add row button it should add one more row with corresponding object fields,operators and search text box and when i click remove row button it should remove rows.How can i approach this.?.

Thanks in advance,
Deepak
hi,
i have two custom object called functional requirement and system requirement..system requirement object having lookup relationship with functional requirement..When a new SR is created,i need to send email to user which is a user lookup field(Technical_Lead__c) in FR...please help me to query to retrive that user lookup email from FR when SR created...i have created this trigger but when i create record in application it showing error as
Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger SREmailSending caused an unexpected exception, contact your administrator: SREmailSending: execution of AfterUpdate caused by: System.QueryException: List has no rows for assignment to SObject: Trigger.SREmailSending: line 7, column 1
 
trigger SREmailSending on System_Requirements__c (after insert,after update) {
    List<Messaging.SingleEmailMessage>mails =new List<Messaging.SingleEmailMessage>();
    
  for(System_Requirements__c sr:trigger.new){
    if(sr.Status__c =='Development Completed'){  
         String emailAddr=[Select Email from User where id =:trigger.new[0].Functional_Requirement__r.Technical_Lead__c].Email; 
         Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
         String[] toAddresses = new String[] {emailAddr};
         mail.setToAddresses(toaddresses);
         mail.setSubject('SR Created');
         mail.setPlainTextBody('Status of SR is  Development Completed');
         mails.add(mail);
      }
     
       if(mails.size()>0){
         Messaging.sendEmail(mails);
      }
}

Thanks in advance
Hi,
I need to create edit and delete output link for contact object records which is lookup to account and my vf page looks like standard account detail page and when i click edit link it should edit the record and delete option should delete the record.
i dont know how to create the link..any help...

Thanks, in advance..
hi,

i got 57% code coverage and confused how to give values for objects like CMAX__Business_Requirement__c,CMAX__Functional_Requirements__c and CMAX__System_Requirements__c...
public with sharing class GenerateReport4mBC 
{
  public string recid{get;set;}
  public Map<string,CMAX__Business_Requirement__c> listBrs{get;set;}
  public Map<string,list<CMAX__Functional_Requirements__c>> Frlist{get;set;}
  public list<wrapBr> brListWrap{get;set;}
  public boolean showFr{get;set;}
  public boolean showSr{get;set;}
  public String getPrintView()
    {
        return
        '<!--[if gte mso 9]>' +
            '<xml>' +
            '<w:WordDocument>' +
            '<w:View>Print</w:View>' +
            '<w:Zoom>100</w:Zoom>' +
            '<w:DoNotOptimizeForBrowser/>' +
            '</w:WordDocument>' +
            '</xml>' +
            '<![endif]>';
    }
    public string getDocumentImageUrl()
  {
    List<Document> lstDocument = [Select Id,Name from Document where Name = 'Cvhs' limit 1];
    string strOrgId = UserInfo.getOrganizationId();
    string strDocUrl = 'https://c.na15.visual.force.com/servlet/servlet.ImageServer?oid=' + strOrgId + '&id=';
    system.debug('DocumentUrl*********' + strDocUrl + lstDocument[0].Id);
    return strDocUrl + lstDocument[0].Id;
  }
  public GenerateReport4mBC(ApexPages.StandardController controller)
    {
      recid = Apexpages.currentpage().getParameters().get('id');
      string Fr = Apexpages.currentpage().getParameters().get('showFr');
      string Sr = Apexpages.currentpage().getParameters().get('showSr');
      if(Fr != null && Fr != ''){
        showFr = Boolean.valueof(Fr);
      }
      if(Sr != null && Sr != ''){
        showSr = Boolean.valueOf(Sr);
      }
      if(recid != null && recid != '')
      {
        brListWrap = new list<wrapBr>();
        listBrs = new map<string,CMAX__Business_Requirement__c>([select id,Name,CMAX__Business_Requirements_Summary__c,CMAX__Use_Case__c,(select id,name,CMAX__FR_Description__c from CMAX__Functional_Requirements__r) from CMAX__Business_Requirement__c where CMAX__Business_Case__c=:recid]);
        if(!listBrs.isEmpty())
        {
          for(CMAX__Business_Requirement__c br :listBrs.values())
          {
            wrapBr wr = new wrapBr();
            if(br.CMAX__Functional_Requirements__r.size() > 0)
            {
              wr.FrExists = true;
            }
            wr.brList = br;
            brListWrap.add(wr);
          }
          Frlist = new Map<string,list<CMAX__Functional_Requirements__c>>();
          for(CMAX__Functional_Requirements__c frrecs : [select id,Name,CMAX__Business_Requirement__c,CMAX__FR_Description__c,(select Name,CMAX__SR_Description__c from CMAX__System_Requirements__r) from CMAX__Functional_Requirements__c where CMAX__Business_Requirement__c IN :listBrs.keyset()])
          {
            if(Frlist.containskey(frrecs.CMAX__Business_Requirement__c))
            {
              Frlist.get(frrecs.CMAX__Business_Requirement__c).add(frrecs);
            }
            else{
              Frlist.put(frrecs.CMAX__Business_Requirement__c,new list<CMAX__Functional_Requirements__c>{frrecs});
            }
          }
        }
      }
    }
    public class wrapBr
    {
      public Boolean FrExists{get;set;}
      public CMAX__Business_Requirement__c brList{get;set;}
    }
}

thanks in advance...
hi all,
i need to write test class for this trigger. Please give some idea


trigger accountTestTrggr  on Account (before insert,before update) {
 List<Account> accountsWithContacts = [select id, name,(select id,firstname, lastname,Description from Contacts) from Account where Id IN :Trigger.newMap.keySet()];         
 List<Contact> contactsToUpdate = new List<Contact>{};
    for(Account a: accountsWithContacts){
    for(Contact c: a.Contacts){
    c.Description=c.firstname+c.lastname;
    contactsToUpdate.add(c);
       }
}
update contactsToUpdate;
}
hi,
I have a VF Page it contains search input search box and search button.If i entered any value in search text box like "Car" it should redirect from VF page to the google search page with keyword name and displays results regarding cars. 

Is it possible using VF page.
Please suggest me how to approach...

Thank you.
 
Hi all,

I have a requirement that i have to display 3 objects like contact,user and lead. According to the object selection it should display all fields of the corresponding object in dropdown list,also operators in dropdown and search value in input text box in a single row.

When i select add row button it should add one more row with corresponding object fields,operators and search text box and when i click remove row button it should remove rows.How can i approach this.?.

Thanks in advance,
Deepak
hi,
i have two custom object called functional requirement and system requirement..system requirement object having lookup relationship with functional requirement..When a new SR is created,i need to send email to user which is a user lookup field(Technical_Lead__c) in FR...please help me to query to retrive that user lookup email from FR when SR created...i have created this trigger but when i create record in application it showing error as
Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger SREmailSending caused an unexpected exception, contact your administrator: SREmailSending: execution of AfterUpdate caused by: System.QueryException: List has no rows for assignment to SObject: Trigger.SREmailSending: line 7, column 1
 
trigger SREmailSending on System_Requirements__c (after insert,after update) {
    List<Messaging.SingleEmailMessage>mails =new List<Messaging.SingleEmailMessage>();
    
  for(System_Requirements__c sr:trigger.new){
    if(sr.Status__c =='Development Completed'){  
         String emailAddr=[Select Email from User where id =:trigger.new[0].Functional_Requirement__r.Technical_Lead__c].Email; 
         Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
         String[] toAddresses = new String[] {emailAddr};
         mail.setToAddresses(toaddresses);
         mail.setSubject('SR Created');
         mail.setPlainTextBody('Status of SR is  Development Completed');
         mails.add(mail);
      }
     
       if(mails.size()>0){
         Messaging.sendEmail(mails);
      }
}

Thanks in advance
hi all,
i need to write test class for this trigger. Please give some idea


trigger accountTestTrggr  on Account (before insert,before update) {
 List<Account> accountsWithContacts = [select id, name,(select id,firstname, lastname,Description from Contacts) from Account where Id IN :Trigger.newMap.keySet()];         
 List<Contact> contactsToUpdate = new List<Contact>{};
    for(Account a: accountsWithContacts){
    for(Contact c: a.Contacts){
    c.Description=c.firstname+c.lastname;
    contactsToUpdate.add(c);
       }
}
update contactsToUpdate;
}