• Devendra Natani
  • NEWBIE
  • 265 Points
  • Member since 2010
  • Salesforce Practice Head
  • Appcino Technologies Pvt Ltd

  • Chatter
    Feed
  • 10
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 73
    Replies

So I am kind of new to field sets. I have put them in my visualforce page but I have a question. 

 

I have some Long Text Area fields in my field set and when I render them on the page inside of <apex:inputField> tag they are really small. I was wondering is there a way to resize these fields? I ask because I have multiple fields with different field types in the field set and I don't think changing the style of the <apex:inputField> tag will help me much.

Hi All,

 

I need to use controller class variable in javascript onClick event. For this I used below code.

I am getting NULL value instead of  "samplevariable" which hardcoded in class variable while click Javascript function and m

VFP:

 

<apex:page id="pageForm" controller="formController">
    <apex:form id="form">
         <apex:inputHidden value="{!myObject.textdata}" id="hidBusiness"/>
        <apex:commandButton id="btnSave" onclick="javascript&colon;if(!confirmation()) return false;" value="save"/>
    <script>
       function confirmation()
        {
          var hidBusiness= document.getElementById("{!$Component.hidBusiness}");
          alert('Hi'+hidBusiness);
        }
    </script>
    </apex:form>
</apex:page>

 

Controller class:

public class formController {

  public class MyObject {
     public String textdata = 'samplevariable';

    public String getTextData() { return textdata; }
    public void setTextData(String data) { textdata = data; }

  }

  • November 25, 2011
  • Like
  • 0

hey Ragjesh your code helped me a lot but am getting null value in my controller can you suggest me the exact solution of this problem

 

 

here is my code:

Apex Code:

<apex:actionFunction name="sendTimeStamp" action="{!sendTimeStamp}">
    <apex:param name="x" value="x" assignTo="{!timeStampValue}" />
    </apex:actionFunction>

javascript code:

timeStamp = Number(new Date());
          sendTimeStamp(timeStamp);

controller code:


public string sendTimeStamp() 
    {
        return timeStampValue;
    }
    public string timeStampValue{
    get
    {
        timeStampValue = timeStamp;
        return timeStampValue;
    }
    set;}

 please Help me i am newbie in salesforce

 

i dont know where i am making mistakes?

hi lets say we have trigger that is triggered when object__c is update. then what does for (Object__c c: Trigger.New) mean. Is it a for each loop that goes through every record that has just been updated for the object__c

im trying to write a visualforce page where you can create a new custom object project. the field status in object Project is a picklist. i want to be able to make a new picklist value when selecting "--other--" in a drop down. when "--Other--" is selected an inputText should be rendered and you are able to enter the new picklist value from the inputText. My code doesnt seem to work. if u select Other from the dropdown. the inputText does not appear.

<apex:page standardController="Proj__c" tabStyle="Proj__c">
  <apex:sectionHeader title="Create Project"/>
    <apex:form id="Header">
      <apex:pageBlock title="General Information" mode="edit">
      <apex:pageMessages />
      <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!save}"/>
        <apex:commandButton value="Cancel" action="{!cancel}"/>
      </apex:pageBlockButtons>
      <apex:pageBlockSection columns="2">
           <apex:inputField required="true" value="{!Proj__c.Name}"/>
           <apex:inputField required="true" value="{!Proj__c.Expense_Budget__c}"/>
            <apex:inputField required="true" value="{!Proj__c.Billable_hours__c}"/> 
            <apex:inputField required="true" value="{!Proj__c.Location__c}"/>
         
           <apex:inputField value="{!Proj__c.Status__c}" id="values">             
            <apex:actionSupport event="onchange" reRender="newvalue" />              
           </apex:inputField>  
             
      
                                               
      
       <apex:outputpanel id="newvalue" >
       <apex:outputpanel rendered="{!Proj__c.Status__c == '--Other--'}">       
                
        <div style="position:relative;left:75px;"> 
        <apex:outputlabel value="new value" for="newval1"/>                            
          <apex:inputText value="{!Proj__c.Status__c}" id="newval1"/>              
              </div>            
        </apex:outputpanel>
         </apex:outputpanel>
        
        
                         
              </apex:pageBlockSection>    
   
    </apex:pageBlock>
     </apex:form>
</apex:page>

 

 

 

Hi,

 

I have created one object called Job which has lookup relationship with Schedule Template object.

I have another object Schedule Template Item which has master-detail relationship with Schedule Template object.


Job (Master) and Schedule Template (Child) : Lookup Relationship

Schedule Template (Master) and  Schedule Template Item (Child) : Master-Detail Relationship

I want to retrive Schedule Template Items.

How to do it?

Using visualforce,apex code how can i display related Schedule Template Items of particular Schedule Template?

 

Cheers,

Devendra S

hi,

I am using wrapper class to display the date in vf but here it works fine but i need to display in ascending order 

can any one please help 

here is my code sample

Public lass finalpay()
{
   public void prepareMap()
   {
        salesPerformanceData = new Map<Date, FRSummaryWrap>();
        List<Time_Card__c> empList = [select name,day__c,date__c,days__c from Time_Card__c where Month__c=:month and Employee__r.name=:emp and Year__c=:year order by date__c ASC];
        for(Time_Card__c emp: empList){
               
            salesPerformanceData.put(emp.Date__c,new FRSummaryWrap(emp.Date__c,amount));
        }
		}
		
		 public List<FRSummaryWrap> getWrapSummaryList(){
        return salesPerformanceData.values();
    }
	
	   
    public class FRSummaryWrap{
    
       public Date tdate{get;set;}
	   
	    public FRSummaryWrap(Date dat,String prunitamt){
             
            tdate = dat;
           }
                    
        }
        }

 Here is my VF page

 <apex:repeat value="{!wrapSummaryList}" var="Wrp">
 
 <tr border="1"> 
 <td  Style="font-family: Arial; font-size: 10pt; font-weight: bold;">{!Wrp.tdate}</td>
</tr>  
 </apex:repeat> 

 

Hi All,

 

I have a simple form with a customer controller which I now need to create the test code so I can deploy to live system, however, I'm havig some issues creating the test method as I'm relatively new to testing.  So I'm hoping someone can help as I can't seem to find the answer anywhere.

 

The VisualForce Page is called New_Reserve_Entry.

 

And here is the Reserve Controller Code:

 

public with sharing class Reserve {
   
    public Lead lead {get; private set;}
   
    public String company {get; set;}
    public String email {get; set;}
    public String phone {get; set;}
    public String firstName {get; set;}
    public String lastName {get; set;}
    public String title {get; set;}
    public string primary_campaign {get; set;}

    public String getName() {
        return 'Reserve';
    }

    // save button is clicked
    public PageReference save() {

        Lead l = new Lead(
        OwnerId = '00GE0000000hCBH',
        LeadSource = 'Reserve',
        FirstName = firstName,
        LastName = lastName,
        Email = email,
        Phone = phone,
        Title = title,
        Company = company,
        );
       
      
    try {
      insert l; // inserts the new record into the database
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error,'Error adding Candidate to Reserve List.'));
      return null;
    }
     
        return Page.New_Reserve_Entry_Confirmation;
}

}

@isTest
private with sharing class Reserve_Test {
	
 	public static testMethod void testReserve_Test() {
        PageReference pageRef = Page.New_Reserve_Entry;
        Test.setCurrentPage(pageRef);
      
        reserve controller = new reserve();
        String nextPage = controller.save().getUrl();
              

        //Controller and Data
        controller = new reserve(); 
        Lead l = new Lead(
        OwnerId = '00GE0000000hCBH',
        LeadSource = 'Reserve',
        FirstName = 'FirstName',
        LastName = 'LastName',
        Email = 'test@test.com',
        Phone = '001',
        Title = 'Junior',
        Company = 'Acme'
        );

        //Save
        nextPage = controller.save().getUrl();


        // Verify
        Lead[] leads = [select id, email from lead where Company = 'Mystry'];
        System.assertEquals('firstlast@acme.com', leads[0].email);
        System.assertEquals('lastname',leads[0].LastName);
        
        
    }
		
}

 

So I understand that the test code must call the page, load the controller, insert the lead data, save, confirm return page and check data was inserted.  However, writing it is the problem:

 

I got this far and then got stuck:  Currently I get an error for string nextpage = controller.save().getUrl() saying "Attempt to de-reference a null object"



 

 

 

I would really appreciate if someone could help me out either by fixing the test code, showing me a test code they have for something similar or any links that could help.


Thanks

Kev

 

 

 

 

 

 

 

The below code is driving two dependant picklists with the second picklist being an aggregated list of campaign names.

 

Objective:

Use the aggregatedresult functionality to group campaign names by the related campaignmember.owner. Apex coding is the only way  I can achieve the intended results, using dependant upicklist fields in the UI will not meet my business requirements.

 

In trying to incorporate the aggregate / group by functionality, I am recieving the following error:

 

 

Compile Error: Invalid field campaignid for SObject AggregateResult 

 

 

Here is my code:

 

 

public with sharing class CampaignListOwner2{

    public String campaignstatus { get; set; }

    public transient string campaignlists;
    Id campaignid;
    public string s;
    
 
   /**
    *Refresh campaign list
    *@return page reference
    */
    
   
    public PageReference campaignRefresh(){
        
        return null;
    }
    

    public String getString() {
        return s;
    }
            
    public void setString(String s) {
        this.s = s;
    }

    
    


public List<SelectOption> getselectedOwner(){
        List<SelectOption> selectedOwnerList = new List<SelectOption>();
        selectedOwnerList.add(new SelectOption( '1', 'SELECT' ));
        for(User u:[select id,name from user where id in (select ownername__c from campaignmember) order by name]) {
        selectedOwnerList.add(new SelectOption(u.id, u.name));
        System.debug('************* selectedOwner id : ' + u.id);
    }
        system.debug('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^' + selectedOwnerList);
        return selectedOwnerList;
    }

public List <SelectOption> getcampaignlists(){
    system.debug('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' + s);
    
    AggregateResult[]groupedResults = [select
       campaignid from campaignmember where ownername__c=:s group by campaignid];
    
    List <SelectOption> campaignLists = new list<SelectOption>();
    campaignLists.add(new SelectOption( '1', 'SELECT' ));
    
    for(Aggregateresult ar :groupedResults) {
        campaignlists.add(new SelectOption(ar.campaignid, ar.name));

    }
    return campaignlists;
            
    }
}

 

 

How do I solve this error by adding the required fields to the aggregateresult sobject? If i have hit a dead end on this code. What is another way to achieve the same objective of tabulating a grouped list of campaign names driven by the campaignmember owner?

 

Thank you

Hi,

I have 2 objects E__c, Company__c.

I created a lookup on E__c which is related to Company__c.

E__c contains the fields Name(Standard), CompanyName__c (Lookup & custom field).

When i try to print the field names of E__c, it gives field names like,

Name,ownerid,createdbyid,modifiedid,CompanyName__c.

Actually i have 2 fields name, Companyname__c in E__c object.

But here it shows 5 field names including ownerid,createdbyid,modifiedbyid.

Is ownerid,createdbyid,modifiedbyid are belongs to either E__c (or) Company__c object.

please reply your answer.

Regards:

Ramya

 

Hello,

We can add a datasource onto the attribute in the design resource, like this:
<design:attribute name="Name" datasource="value1,value2,value3" />

How can I use a dynamic datasource instead of hardcoding the values.

Thanks,

Devendra 

Hello,

 

We have a search page where we are displaying account and contact records. We do have search box and some filter criterias on this page as well. When I click on search button ( using actionFunction to call the controller method), It gives me the following error. 

 

Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.

 

Note - This org has been updated to summer 2013 yesterday. The search functionality was working fine till yesterday. 

Please let me know if any one else is having the same issue as well or its related to summer 13. 

 

Thanks,

I am having following error in apex class while reading a word document which is uploaded in Document object .

 

"BLOB is not a valid UTF-8 string".

 

Thanks,

Devendra Natani

Hi All,

 

I have created a utility to merge records of any standard object (except user) and custom objects. User can select upto three records of any object to merge. User can select a Master record and also select the fields of child records. All the related objects can also be merged using that utility.

 

Thanks,
Devendra Natani (Salesforce Certified Developer)

Blog

 

 

I have created custom fields in Salesforce CRM Content Object. Now i want to include those fields in the package. I dont see any of the custom fields of Salesforce CRM Content object under Custom Fields option. Is there any specific setting which we need to do for that?

 

Thanks

Devendra Natani

I have a contact which has a partner user. I am disabling the partner user from contact detail page by selecting "Disable partner user" option from "Work with Portal Button" dropdown.

 

I have a trigger on User object which fires on after update event.

 

trigger TR_User on User (after update) {
system.debug('########'+trigger.new[0].IsActive + '-' + trigger.old[0].IsActive);
}

 

In this trigger I am checking the IsActive field value of user object. But both Trigger.New[0].IsActive and Trigger.Old[0].IsActive returns same value i.e true. While I was expecting it to become false as User is disassociated from the contact in this process.

 

I am not sure whether it is a bug in the Salesforce or I am missing something...

 

Please Suggest.

 

Thanks,

Devendra Natani

Blog

 

 

I have created custom fields in Salesforce CRM Content Object. Now i want to include those fields in the package. I dont see any of the custom fields of Salesforce CRM Content object under Custom Fields option. Is there any specific setting which we need to do for that?

 

Thanks

 

 

 

Hello,

We can add a datasource onto the attribute in the design resource, like this:
<design:attribute name="Name" datasource="value1,value2,value3" />

How can I use a dynamic datasource instead of hardcoding the values.

Thanks,

Devendra 

trigger accountnameuppercase on account (before insert,before Update) {
    List<account> acclist = trigger.new;
    nameupper.makeuppercase(acclist);
}

apex class:::

public class accnameuppercase{
    public static void makeuppercase(List<account> acclist){
        for(account a : acclist){
       String rep_name =a.name;
List<String> elems = rep_name.split('');
rep_name = '';
for (String x : elems)
{
    rep_name += x.substring(0,1).toUpperCase()+x.substring(1,x.length() ) + ' ';
}  

   a.name=rep_name;
   
        }
        }
        }
I have installed apptus from Appexchange .. As per my requirment i need to change controller .. but controller code not visiable.. plz help me on this if any one ave idea.
  • April 22, 2015
  • Like
  • 0

Hello,

 

We have a search page where we are displaying account and contact records. We do have search box and some filter criterias on this page as well. When I click on search button ( using actionFunction to call the controller method), It gives me the following error. 

 

Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.

 

Note - This org has been updated to summer 2013 yesterday. The search functionality was working fine till yesterday. 

Please let me know if any one else is having the same issue as well or its related to summer 13. 

 

Thanks,

So I am kind of new to field sets. I have put them in my visualforce page but I have a question. 

 

I have some Long Text Area fields in my field set and when I render them on the page inside of <apex:inputField> tag they are really small. I was wondering is there a way to resize these fields? I ask because I have multiple fields with different field types in the field set and I don't think changing the style of the <apex:inputField> tag will help me much.

Hi,

 

Currently i am displaying help text on VF Page instead of field label names because field names are having many characters in it.

I need to display poup help text on dat VF page where i am displaying  help text instead field label.

 

  • Help text pop-up are having more than 255 characters in it.
  • Every field is having different description in it.

 

  • MY Question:Is there anyway i can display  pop up help text on VF Page?

 

  • Thanks in Advance.Plz help me out 
  • December 12, 2011
  • Like
  • 0

I am having Account object. the field name is  Account_secondary_result__c,help text=secondary.Currently i am displaying the help text "seconday" on VF page.

 

when i moves cursor on to the field name i.e help text on VF page ......I need to display the pop up help on the particular field.I am having like mote than 5 fields with different pop up help description exceeding 255 characters.

 

 

Urgent: IS there anyway i can  display  pop up help on   VF Pagefield i.e. help text

  • December 12, 2011
  • Like
  • 0

Hi , am writing an apex trigger in which I need to validate the account name if already exist before insertion... so this trigger event will be "before insert" on "Account" object... my question is there is a way from the trigger to stop the insertion process and rase an error or warning to the user that this account name already exist?

 

  • November 28, 2011
  • Like
  • 0

can some one please tell me what exactly is bulkification of trigger

Hi All,

 

I need to use controller class variable in javascript onClick event. For this I used below code.

I am getting NULL value instead of  "samplevariable" which hardcoded in class variable while click Javascript function and m

VFP:

 

<apex:page id="pageForm" controller="formController">
    <apex:form id="form">
         <apex:inputHidden value="{!myObject.textdata}" id="hidBusiness"/>
        <apex:commandButton id="btnSave" onclick="javascript&colon;if(!confirmation()) return false;" value="save"/>
    <script>
       function confirmation()
        {
          var hidBusiness= document.getElementById("{!$Component.hidBusiness}");
          alert('Hi'+hidBusiness);
        }
    </script>
    </apex:form>
</apex:page>

 

Controller class:

public class formController {

  public class MyObject {
     public String textdata = 'samplevariable';

    public String getTextData() { return textdata; }
    public void setTextData(String data) { textdata = data; }

  }

  • November 25, 2011
  • Like
  • 0

hey Ragjesh your code helped me a lot but am getting null value in my controller can you suggest me the exact solution of this problem

 

 

here is my code:

Apex Code:

<apex:actionFunction name="sendTimeStamp" action="{!sendTimeStamp}">
    <apex:param name="x" value="x" assignTo="{!timeStampValue}" />
    </apex:actionFunction>

javascript code:

timeStamp = Number(new Date());
          sendTimeStamp(timeStamp);

controller code:


public string sendTimeStamp() 
    {
        return timeStampValue;
    }
    public string timeStampValue{
    get
    {
        timeStampValue = timeStamp;
        return timeStampValue;
    }
    set;}

 please Help me i am newbie in salesforce

 

i dont know where i am making mistakes?

I have an issue where the validation rule error message on a custom object doesn't appear at the top or field level but instead on a separate page with a DML exception error.  I know I could use a catch statment but not sure where to put it.

 

 

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, The Alternative Delivery date must be after the Delivery Date. Please adjust the Alternative Delivery date.: [] 

Class.NewRenterOpportunity.Save: line 12, column 1

 

Class:

public class NewRenterOpportunity {

    public Opportunity opp{get;set;}
    public Renter__c rentr{get;set;}
    public NewRenterOpportunity(ApexPages.StandardController controller)
    {
        rentr = (Renter__c)controller.getRecord();
        Id id = ApexPages.currentPage().getParameters().get('id');
     
    }
    public PageReference Save(){
     insert rentr;
        opp = new Opportunity();
        opp.Name =  rentr.Renter_s_First_Name__c + ' ' + rentr.Name;
        opp.Renters_Email__c = rentr.Renters_Email__c;
        opp.Renters_Phone__c = rentr.Renters_Phone__c;
        opp.StageName = 'Proposal/Price Quote';
        opp.CloseDate = System.today()+2;
        opp.Classification__c = rentr.Classification__c;
        opp.Lease_Term__c = rentr.Lease_Terms__c;
        opp.Residential_Opportunity_Source__c = rentr.Source__c;
        opp.Renter_s_Price_Range__c = rentr.Budget__c;
        opp.Need_Office_Furniture__c = rentr.Need_Office_Furniture__c;
        opp.Need_Housewares__c = rentr.Need_Housewares__c;
        opp.Need_Finishing_Touches__c = rentr.Need_Finishing_Touches__c;
        opp.Need_Electronics_Appliances__c = rentr.Need_Electronics_Appliances__c;
        opp.Description_of_Items__c = rentr.Details_of_what_they_need__c;
        opp.Other_Potential_Renters__c = rentr.Other_that_need_to_rent__c;
        opp.Pertainent_Notes__c = rentr.Why_the_need_to_rent_furniture__c; 
        opp.Potential_Renters__c = rentr.Other_Potential_Renters__c;
        opp.Delivery_Date__c = rentr.Delivery_Date__c;
        opp.Alternate_Delivery_Date__c = rentr.Alternate_Delivery_Date__c;
        opp.Delivery_Street__c = rentr.Delivery_Street__c;
        opp.Delivery_City__c = rentr.Delivery_City__c;
        opp.Delivery_State__c = rentr.Delivery_State__c;
        opp.Delivery_Zip__c = rentr.Delivery_Zip__c;
        opp.Showroom__c = rentr.Showroom__c;
 
        String AccountId;
        opp.Corporation__c = rentr.Company__c; 
        
  
             
        insert opp;
        
        PageReference ref = new PageReference('/'+opp.id);
        return ref;
    }
    public PageReference NewRenters(){
        return null;
    }
    public PageReference Cancel(){
        return null;
    }
  
}

 

 

  • November 03, 2011
  • Like
  • 0

Hii Right now I am writing test class, I want to know exact use of unit testing ?

Since as I know, It is used to check all syntax & DML operation of the application to avoid bugs or exception.

But I have one case like right now,  In account, there is two type of account named Business account & person account.

Every time we prefer Person Account & I already disable Business account while creating new account so it creates Person account by deafult.

But while writing test class I am writing like this...

acc = new Account(Firstname='manoj', Lastname='gahlot', RecordTypeId='PersonAccountRecordTypeID');

 

So please tell me am I writing correct test for the type Person account ?

hi lets say we have trigger that is triggered when object__c is update. then what does for (Object__c c: Trigger.New) mean. Is it a for each loop that goes through every record that has just been updated for the object__c

I want the test class code. Can anyone suggest me with the test class code for the apex code.

 

 

public with sharing class TextMessage {

List<text__c> appTextMessage = [select text_message__c FROM text__c ];
Map<ID, Contact> contactMap = new Map<ID, Contact>([select id, firstname from contact]);
List<String> displayMessage = new List<String>();

public List<String> messageTemplate()
{  
  
  for (text__c textMessage : appTextMessage)
     {
    String text = textMessage.text_message__c;
  if(text !=null  ){
    Set<ID> keyId = contactMap.keySet();
    for(ID c :keyId){
      displayMessage.add(contactMap.get(c).firstname + ' ' + text + '\n');
      System.debug(displayMessage);
    }
  }
      }
    
  return displayMessage;
}

}

 Thanks in advance.

Hi champs..

 

I am very new to salesforce and apex programming.

 

I am trying to stop an email notification (when case status is set to completed) sent from an apex trigger. I tried setting the EmailHeader.triggerUserEmail = false but it does not seem to work.

 

is there any other way i can stop this notification.

 

Thanks in advance.........


Regards,

Din

  • August 03, 2011
  • Like
  • 0

 

Hi,

 

I have created one object called Job which has lookup relationship with Schedule Template object.

I have another object Schedule Template Item which has master-detail relationship with Schedule Template object.


Job (Master) and Schedule Template (Child) : Lookup Relationship

Schedule Template (Master) and  Schedule Template Item (Child) : Master-Detail Relationship

I want to retrive Schedule Template Items.

How to do it?

Using visualforce,apex code how can i display related Schedule Template Items of particular Schedule Template?

 

Cheers,

Devendra S