• Umapen
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 20
    Questions
  • 54
    Replies

I'm sure this is much, much easier than I am ascribing to it...for some reason I am unable to vision my way into a first venture into APEX code.

 

I have read and read and read posts and have found a multitude that seem like they should be close but I can never quite transform them.  At now that I have hit 7 hours of reading and have made no progress I have to concede and ask for help.

 

I need a "fake" roll-up summary (I have created a field called "Trained Contacts" on my Account object that counts related Contacts when custom field "Date_of_Last_Implantation_Training__c" is not equal to null.  It has to recalculate when Contacts are added and that field is filled in, when Contacts are deleted (and therefore the count should go down) or when the contents of that field are deleted (rare, but usually only when there is a data entry error).

 

Anyone out there that can help me through my first Trigger?  I'm sure I can then study the code and then adapt if for other future uses if necessary (although we have made it 2 years without needing any heavy customization yet...).

 

Thank you in advance for your patience and any assistance you may be able to offer...

 

Kelly

  • August 02, 2009
  • Like
  • 0

In my visual force page I have the following line that display date : 1/21/2010 9:37 PM

<apex:outputField value="{!invitation.Account_group__r.Submission_Due_Date__c}"/>

 

 

I want to display date as : Jan 21, 2010 9.37 PM pst

 

Do I have to convert to string in my controller and display parsed data in visual force page?

or

Is there any format that I can give in my style(css) that will display date in the format I want?

 

Thanks

 

  • January 12, 2010
  • Like
  • 0

In my controller the query some time returns 0 rows. I have a try/catch block. I want to redirect to error page int he catch block. this page is going to be displayed on Sites.

How can I do that?

   ** I already set the error page assignment to my custom pages 

   ** I have multiple conditions where I want to display different error messages

 

try{ myacct =[select id, name, customid__c from Account WHERE rating__c =:rate and completed__c !=true LIMIT 1]; }catch(System.Exception e) { System.debug(e); PageReference error = page.noRateError; error.setRedirect(true); }

But this is not working.  I have this call in my custom controller constructor.

 

how can I redirect to error page in catchblock? Or other ways I can acheive this.

 
Message Edited by Umapen on 01-07-2010 09:24 AM
  • January 07, 2010
  • Like
  • 0

I am trying to (1)provide list of records, (2)  ability to add new record and (3) edit record on the same page.

I am able to add but not able to edit. any suggestions.

 

I am able to show the list and add to the list. when click on the edit commandlink I want the output panel inputfields to be populated by selected record for edit.

(cannot see my attached image)

 

 

 

Message Edited by Umapen on 11-29-2009 11:52 PM
  • November 30, 2009
  • Like
  • 0

hello,

How can I use browser back button and get the page refreshed.

I have custom visual force pages, when I click onback button get cached data.

 

I do not want to add commandlink or button to the page.

 

How can I  refresh when I use browser back button?

 

Thanks

  • November 12, 2009
  • Like
  • 0

Is it possible to create picklist value based on query results.

Maximum values returned can be 15.

 

example: providing citylist base on state selected. and only those city name where the shows are being scheduled.

  • October 29, 2009
  • Like
  • 0

I have the following code that works in sandbox not working in production environment. 

I am getting invalid type error message for first line mailDispatch.  I am using this to send mass emails in my VF code.

 

mailDispatch md = new mailDispatch();
md.sendmail(contact.email);

Is this correct way of using? Not sure why working in sandbox? 

 

Message Edited by Umapen on 09-28-2009 08:59 AM
  • September 28, 2009
  • Like
  • 0

 I am have the same problem. Cannot see pagelayout properly on Site pages.

When I login to Sandbox I can see the page properly. I do not see any errors either.

 

Is there any way I can look at the debug logs? How set the user name?

 

 

Can't get VF Page on Layout to Display in Sites page

 

http://community.salesforce.com/sforce/board/message?board.id=sites&thread.id=1209

  • August 18, 2009
  • Like
  • 0

I have a sites pages that has the following line of code that have image.

 

 

<apex:page showHeader="false">
<apex:image id="Holidays" value="{!$Resource.default1}" width="220" height="55" />

 

I want to change the images based on the field value in the ojbect.

My custom object name  holidays__c. Custom page  titled  holidayspecialpage.

with custom field season__c. I have a custom controller and page works fine on sites page.

 

I want to change the image in my apex page based on the value of season__c

 if(season__c = summer) static resouce summer image.

How can I acheive this?

  • August 12, 2009
  • Like
  • 0

Any suggestions on when to use VF component and when to VF Template?

 

I am creating VF sites pages and wanted to use css not sure which one is easy to maintain.

 

Thanks

Uma

 

 

  • August 05, 2009
  • Like
  • 0

 

It was mentioned in the Q & A that copy of demo version will be available in code share.

 

http://wiki.developerforce.com/index.php/Tech_Talk:_Force.com_Sites

Does anyone know where I can find it. code is not in codeshare.

 

Thanks

Uma

I create an apex page with that is also diplayed as sites pages. I see only text but not the contols like checkbox, text field.

I tried installing sample site application to see and the problem is same.

http://developer.force.com/codeshare/apex/ProjectPage?id=a06300000046ehCAAQ

 

when post the page after login to SF I see all the text and input boxes properly. when the same page posted on sites I do not see input boxes. What is that I need to set. I do not know how to solve this problem.

 

Thanks

Uma

I have the following line in my Visual force page.

 

Code:

<apex:sectionHeader title="Custom Account View/Edit" subtitle="{!Account.name}" help="Test Help info"></apex:sectionHeader>


 

 

Section header has "Help for this page" link. When I click on the link
See the error message - Page Help does not exist. How can I make this page work?

Documentation has the following ::::::::::::
The URL for the page's help file.When this value is specified, a String
Help for this Page link automatically appears on the right side of
the colored title bar.

But I cannot see my help text in popup?
Where do I add the help file?
Do I have to write javascript to open my help file?

I have a custom controller, and 2 visual force pages.

My page1 is  Inside account page layout. Page 1 has a button that post page2 

Page 2 posts inside the section of account. How do I post my page 2 to new page.

 

When I test with the following URL it works - page 2 is posted properly

https://cs2.salesforce.com/apex/MytestPage1?id=066Q000000001ZM

 

When I test with following URL after adding to account page layout Page 2 is inside the account section

 https://cs2.salesforce.com/066Q000000001ZM

Here my code:

 

Controller:


public with sharing class MytestController {

  private final Account stdAcct;

 

  public PageReference EditList(){

  //return page.MytestControllerPage2;

    PageReference editList = Page.MytestControllerPage2;

    editList.getParameters().put('id', stdAcct.id);

    editList.setRedirect(true);

    return editList;

  }

 

  public MytestController(ApexPages.StandardController stdcontroller){

    this.stdAcct =  [select id, name, BillingCity from Account   where id = :ApexPages.currentPage().getParameters().get('id')];

          }

}

 

 

 

Page1 - added to account page layout 

 

<apex:page standardcontroller="Account" extensions="MytestController" sidebar="false" showheader="false" standardStylesheets="true">

<apex:pageBlock ><b>Account Name: </b><apex:outputText value="{!account.Name}" rendered="true"/>

<b> City: </b><apex:outputText value="{!account.BillingCity}" rendered="true"/>

<b> Market Name: </b><apex:outputText value="{!account.Market_Name__r.Name}" rendered="true"/>



</apex:pageBlock>

<apex:form > <apex:pageBlock >

<apex:pageBlockButtons location="top">

<apex:commandButton action="{!EditList}" value="Post another page" status="status" />

</apex:pageBlockButtons>

</apex:pageBlock> </apex:form>

</apex:page>

 Page2 - post from with button click on page1

<apex:page standardcontroller="Account" extensions="MytestController" sidebar="true" showHeader="true" standardStylesheets="true">



<!-- Begin Default Content REMOVE THIS -->

<h1>Congratulations</h1>

This is your new Page

<!-- End Default Content REMOVE THIS -->

</apex:page>

 I tried using commandLink instead of Commandbutton and used target="_blank"  But the page does not display header and sidebar. 

NOTE: My page 1 has showHeader="false" Page 2 has showHeader="true"

 

I turned off DevelpmentMode in use setting.

 

Any suggestions?

I am getting the following error when I use target"_blank" with commanButton.

 

Error: Unsupported attribute target in <apex:commandButton> at line 28 

 

Any suggestions on what are the alternatives to this. I do understand from the documentation that 

this option is available for commandlink.

 

I tried navigatetoURL (but do not want to hardcode ID)

 

onclick="navigateToUrl('/apex/myapexpage?id=001T0000008ylRf');" /></td>

function navigateToUrl(url) {
window.location = url;
}

 

I have a custom controller extension for account.  I have two Visual force pages that use this controller. 

Page1  contains a button that post page.

 

 I have included page1 in the account page layout in newsection.

 

when I click the button on page1; Page2 is displayed in the same section.

 

 

My questions is, How can I redirect my custom visual force page2  to display a new page instead of inside Account page Section?

 

Note: when I test  my apex page1 and click on the button I get page2 eventhough URL is not changed.

https://cs2.salesforce.com/apex/page1?id=00130000001rCGn

 

When I test from account page layout 

https://cs2.salesforce.com/00130000001rCGn 

My apex page2 display in section instead of new page.

 

Thanks

Uma

 

 

Hello
I am calling the following class from my trigger after update on Account.  When I update more that 50 records I get the error. I need to update 30000 records.

I am getting the Too many SOQL queries: 101 error.



Can someone help me how I can batch this code.  The trigger and code are working fine.

I updated Upto 45 records without errors. How can I batch this so I can update more records at a time.


Code:
Code:

  public class createMycustomAcc {

   @future
  public static void Acctsetsfor(String[] acIds){
   List<customobject__c> finalLst new List<customobject__c>()
 
     List<Account> ac = [select Id, Name, Market_name__c from Account where market_name__c != null AND Id IN :acIDs];

 for(Account a :ac){
     String RecType = a.RecordTypeId;
     String Rating = a.Rating__c;
     String SameId = a.Id;
     String MarketName = a.market_name__c;


     qrystr= 'select name, Id, Rating__c from Account WHERE RecordTypeId = \'' + RecType + '\' AND Id != \'' + SameId +'\' AND market_name__c = \'' + marketName + '\'  custom_id__c != Null LIMIT 150';
      Htlaccts = Database.query(qrystr);  // this line is causing errors
    
     if(Htlaccts.size() >0{
       for((Integer i = 0; i < Htlaccts.size();i++){
          // more conditions if true
          //build a list of custom object
          // if false i = Htlaccts.size()
          customobject__c cobj = new customobject__c(Account__c = a.id, relatedto__c =Htlaccts[i].id);
          
          finalLst.add(cobj);
       }

     }
     if(finalLst.size() > 0 ) insert finalLst;


  }
Message Edited by Umapen on 04-17-2009 08:06 AM
  • April 16, 2009
  • Like
  • 0

Hello ,

I have a custom object that show as related object on Account page.

Is it possible to override this section with custom visualforce page.

 

I also have case and contacts list as related list, and several page layouts, that I do not want to modify.

 

I want to override only the relatedList section that list my custom objects? How can I do that?

 

Thanks

 

  • March 26, 2009
  • Like
  • 0

I have to create a related list to the contacts.

 Contactid  Related-contacts

       5             7

       5             6

       1             5

       1             7

       7             2

 

should I create a new object with master detail? what will the unique id? Or should I create a junction table? Each contact will have related-contacts listed. Contact owner will have ability to modify related list. 

1. Need to maintain a set of related contact id for every given contact.

2. User has ability to delete add to update related contacts

3.  There is no hierarchy here.

 

How can I do this any suggestions?

  • March 10, 2009
  • Like
  • 0

I have a custom controller and apex page associated with it. I am posting the page with button click in account page layout. When my apex page is displayed I want to display some values from account object like name, city. my customer controller with all the logic in it and works fine.

 

1. My page starts with the line 

  <apex:page Controller="MyCustomSelController">

  Can I add StandardController = "Account" to get the account fields?

2. How do I use standardController and pass the values to my custom controller?

 

Thanks

Uma

 

  • March 03, 2009
  • Like
  • 0

I am getting the following errors

Trigger.FindOrCreateContact_Trigger: line 7, column 13
  caseAssignmentUpdateTest.caseAssignmentTest System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FindOrCreateContact_Trigger: execution of AfterInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.FindOrCreateContact_Trigger: line 7, column 13
  ContractClass.testCaseCreation System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FindOrCreateContact_Trigger: execution of AfterInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

 

My trigger Code:

 


Code:
trigger FindOrCreateContact_Trigger on Case (after insert) {
    Map<ID,Contact> contactMap;
    Map<Id, String> csMap;
    for (Case newCase:System.Trigger.new)
    {
        if(newCase.contactid == null){
            csMap.put(newCase.Id, newCase.Suppliedemail);             
            //Map<ID, Contact> m = new Map<ID, Contact>([Select id, c.email from Contact c WHERE email IN emails]);
        }
    }
    contactMap = new Map<ID, Contact>([select id, email from contact WHERE email IN :csMap.values()LIMIT 1]);
    for(Case updateCase: Trigger.new){
        if(csMap.containsKey(updateCase.id)){
            for(Contact c: contactMap.values()){
                if (updateCase.SuppliedEmail == c.Email) {
                    updateCase.ContactID = c.ID;
                }
            }
        }
    }
}

 

 

 

  • January 28, 2009
  • Like
  • 0

In my visual force page I have the following line that display date : 1/21/2010 9:37 PM

<apex:outputField value="{!invitation.Account_group__r.Submission_Due_Date__c}"/>

 

 

I want to display date as : Jan 21, 2010 9.37 PM pst

 

Do I have to convert to string in my controller and display parsed data in visual force page?

or

Is there any format that I can give in my style(css) that will display date in the format I want?

 

Thanks

 

  • January 12, 2010
  • Like
  • 0

In my controller the query some time returns 0 rows. I have a try/catch block. I want to redirect to error page int he catch block. this page is going to be displayed on Sites.

How can I do that?

   ** I already set the error page assignment to my custom pages 

   ** I have multiple conditions where I want to display different error messages

 

try{ myacct =[select id, name, customid__c from Account WHERE rating__c =:rate and completed__c !=true LIMIT 1]; }catch(System.Exception e) { System.debug(e); PageReference error = page.noRateError; error.setRedirect(true); }

But this is not working.  I have this call in my custom controller constructor.

 

how can I redirect to error page in catchblock? Or other ways I can acheive this.

 
Message Edited by Umapen on 01-07-2010 09:24 AM
  • January 07, 2010
  • Like
  • 0

Hi all,

 

I'm testing a deployment process from a sandbox environment to my dev environment. I'm using Force.com IDE to create a new project from the sandbox to deploy on the dev environment.

 

I don't see any issues when I deploy custom fields created on default objects or custom objects but the tabs I create using these custom objects don't work. The tabs do appear on setup > create > tabs but they don't appear on "customize my tabs" screen.

 

If I try create a new custom object tab, the combobox "object" doesn't list the custom objects.

 

Can you help me find the best way to deploy my changes using Force.com IDE?

 

Thanks in advance. 

Hi,

 

Is there anyway to change the image displayed in the sectionHeader of the Page programmatically?

 

Regards,

OnDem

Can we refer to 2 standard controllers in a single VF page?

Hi,

I would like to ask if any expert know how to develop the Lookup button in the Visualforce Page. Thanks!

Best regards

 

  • February 26, 2009
  • Like
  • 0
I can use the listViews tag to show the list views in a VF page

Is there any way of getting the records similar to GetRecordIds?

How would I link a VF button to these records?



We are creating a PDF document using Visual Force Page and the document has a logo ( a png or gif image file on header). Currently the image file is a static resource and using merge field the VF page is able to display it correctly. When we do the packaging the resource is also packaged and is getting installed without any issues.

 

Now we want to change the logo at the installed org , as the logo was bundled as static resource it cannot be modified so, we are trying to place the image in a document folder and refer it  in VF page but the image is not displaying correctly .  We have tried using  url for the image but it is not working . Your help or a working example  will be appreciated in resolving this issue.

 <apex:image value="{!$Resource.gii__logo}"/>

We are trying to package the application as managed beta. The static resources gets locked in the target org.

So we are not able to change the logo.

Is there any way we can use a logo file from the document folder in

We already tried using the URL <apex:image url="/document/image/logo.jpg"/>.  But it does not work..

Is there any way to get the URL for the documents within the org itself.


**This is very urgent, **  Your help is much appreciated



  • September 05, 2008
  • Like
  • 0
I've got a nice S-Control that lets me see all my time entries for the week on one page. I see a view of the data and if I hit the edit button on an entry, I flip to an edit form.

I want to rebuild this in VisualForce and I'm struggling around how to produce that pattern.

In JS I had a Div with the HTML for displaying the record, and when I hit the edit button, I replaced the complete contents of the DIV with an edit form. On save, I replace the contents again, back to the view HTML.

If I'm displaying a list of entries in VF, I can easily display them as outputText or inputFields. And I know how to rerender elements. But any ideas on the best way to flip between view and edit modes?

Thanks!

Steve
Hi Experts,
 
Though this question has already been asked by other, no definite answer has been made. Please help me.
 
To be straight, I have the following code:
 
Code:
<apex:page showHeader="false" controller="VehicleListControllerClass_2">
 <apex:form>
  <apex:pageBlock title="Vehicle List for {!personname}">
   <apex:pageBlockList value="{!vehicleList}" var="v">
    <apex:column value="{!v.VehicleName}"/>
    <apex:column value="{!v.PersonVehicle.Vehicle__r.Name}"/>
    <apex:column headerValue="Vehicle">
     <apex:outputLink value="/{!v.PersonVehicle.Vehicle__c}" target="_top">{!v.PersonVehicle.Vehicle__r.Name}</apex:outputLink>
    </apex:column>
    <apex:column>
     <apex:commandLink value="Click This Link" action="{!dosomething}" >
      <apex:param name="myparm" value="Link abcd"/>
     </apex:commandLink>
    </apex:column>
    <apex:column>
    <apex:commandButton value="Click This Button" action="{!dosomething}" styleClass="btn">
     <apex:param assignTo="{!MP}" name="myparm1" value="abcd"/>
     <apex:param name="myparm2" value="Button abcd"/>
    </apex:commandButton>
    </apex:column>
   </apex:pageBlockList>
  </apex:pageBlock>
 </apex:form>
</apex:page>


public class VehicleListControllerClass_2{

 public String getPersonName(){
  ID pId = System.currentPageReference().getParameters().get('id');
  String name = [Select Name from Person__c where id=:pId].Name;
  return name;
 }

 public class Vehicles{
  Person_Vehicle__c pv;
  //Constructor
  public Vehicles(Person_Vehicle__c pvin) {pv = pvin;}

  public Person_Vehicle__c getPersonVehicle() {return pv;}

  public String getVehicleName(){

   if(pv.Vehicle__r.Name == 'Maruti 800') return 'It is Maruti 800 yar';
   else return pv.Vehicle__r.Name;
  }

  Integer curYear = system.now().year();
  return (curYear - (Integer)pv.Purchase_Year__c);
  }
 }

 List<Vehicles> pvlist = new List<Vehicles>();

 public List<Vehicles> getVehicleList(){
  ID pId = System.currentPageReference().getParameters().get('id');

  pvlist.clear();
  for(Person_Vehicle__c pvv : [Select p.Person__r.Name, p.Vehicle__c,
  p.Vehicle__r.Name, p.Purchase_Year__c from Person_Vehicle__c p where p.Person__c=:pId]){
   pvlist.add(new Vehicles(pvv));
  }

  return pvlist;
 }

 String p;
 public String getMP(){
  return p;
 }

 public void setMP(String s){
  p=s;
 }
 
 public PageReference dosomething(){
  String s = System.CurrentPageReference().getParameters().get('myparm');
  String s1 = System.CurrentPageReference().getParameters().get('myparm1');
  String s2 = System.CurrentPageReference().getParameters().get('myparm2');
  System.debug(s);
  System.debug(s1);
  System.debug(s2);
  return null;
 }

}

When I click on the link 'Click This Link', String 's' returns 'Link abcd' which is correct.
 
But when I click on the link 'Click This Button', both Strings 's1' and 's2' returns null.
 
How could I get the param value in controller in case of 'commandButton'?
Please note that I Must use commandButton and I need to pass more than one parameters.
 
Also, I would like to be able to create a new Case (in another visualforce page) with few default values by clicking a commandButton. The page should open as if user clicked on 'New' button and ready to Save. Please note that the page will not be associated with 'Case' controller.
 
How could I achieve this functionality?
 
Thanks,
-Roshan
Hi,

how do I disable(gray out) a field or two based on a selected value of a picklist. in non-salesforce a javascript would help me in it.

My apologies for the repost, but nobody seemed to have anything to say in "General Development"....


Despite the fact that we have access to the Enterprise WSDL, I've decided to use the Partner WSDL for a new project of mine. 

Basically what I've built is a dynamic form that uses an Object's Fields to populate a form on our webserver with the appropriate controls at runtime, collects the values and submits them back into SF.  I've got everything worked out the way I like: field type interpretation, field creation, list population, and even got field validation working... except that I can't think of a good way for my Salesforce Admins to indicate that a field should be required.

Take our Survey object, for example.  If they add a custom field to Surveys and make it required, then when a salesperson creates a new Survey object INSIDE Salesforce, they must supply a value.  I'm just looking for a way to indicate that it needs to be validated at the end-user.  Right now I'm using the Field's name to determine if the Field should be required by prepending "SFF_" to indicate the Field should be on the form, and not just in SF, and "VAL_" to indicate that the Field should be required. 

I'd really like to use each Field's Description property for keywords, like "Required" and "ShowOnForm" instead.  I don't like the idea of forcing a naming convention on custom Fields, and would much prefer they can modify the field more easily using it's description.  Unfortunately, I can't figure out where Object's Field's Descriptions are stored.   Apparently not as a property of the Field object itself?

Does anyone know where I can find the Description property of a custom Field?

THANKS IN ADVANCE!

PS - You're probably thinking that there are other ways to do some of this, but I've built this little framework in such a way where I can use either Salesforce or a SQL database to describe these dynamic forms and collect data, so there's a little bit of abstraction going on that might seem a little unnecessary on the surface.
  • April 15, 2008
  • Like
  • 0