• Sanch
  • NEWBIE
  • 80 Points
  • Member since 2007

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 33
    Questions
  • 38
    Replies

Hi All,

 

I have the following:

 

1. A child object called Review under Opportunity object.

2. I have a custom visualforce page which overwrites the New Button. It's purpose is to prepopulates couple of fields. 

3. One of the fields that I am prepopulating is called ReadOnlyTest__c. It is populated with the text 'Testing ReadOnly'

4. The user has full access to the object

5. On the page layout I have made the field read Only.

 

What I am trying to archieve is prepopulate the field ReadOnlyTest__c with the value 'Testing ReadOnly' and make that field not editable by the user. But the user has to visually see this field. 

 

I do know I can do this with custom visualforce page.  But my goal is to do this with standard page layout. I expected the text to be pre-pulated. But what happens is the page renders fine and it shows the field as read only, but the text 'Testing ReadOnly' is missing. It's just empty. Can someone help me with what I might be doing wrong here?

 

Sanch

  • August 09, 2012
  • Like
  • 0

Hi All,

 

I have a field which is of type Rich Text Area. In this field I am generating an html table where I am displaying some values that are numbers. When I do that the comma in the values are lost and if it's 8000, it just displays 8000 rather than 8,000. What can I do to maintain the comma. Thanks.

 

Sanch

  • August 08, 2012
  • Like
  • 0

Hi All,

 

I have an Approval process and everything works fine. When the user who is the approver access the email through iPad and click the link it opens up the detail page of the record in normal page. But when the user clicks Approve/ Reject button it takes them to the mobile version of the page.  How can I change this so it opens up the page just like how it will if I open it up in a desktop. 

 

Thanks.

 

Sanch.

  • August 06, 2012
  • Like
  • 0

Hi All, 

 

I am trying to render an inputField if the user selects the field 'Other' in a dropdownlist in visualforce page. Everything works fine, but the only thing is it clears the data the user enters.  I know I can archieve this by putting a wrapper component, but I want to know if there is a way to do this without doing that. 

 

I have the following code:

<apex:pageBlock id="pb1">
            <apex:pageblockSection collapsible="false" columns="2" id="pbs1">
                <apex:panelGrid columns="2">
                    <apex:outputLabel value="{!$Label.City}" for="city"/>
                    <apex:inputField id="city" value="{!lead.City__c}" required="true"/>
                    
                    <apex:outputLabel value="{!$Label.Country}" for="country"/>
                    <apex:actionRegion >
                        <apex:inputField id="country" value="{!lead.Country__c}" required="true">
                             <apex:actionSupport event="onchange" rerender="pbs1" />
                        </apex:inputField>
                     </apex:actionRegion>
                    
                    <apex:outputLabel value="{!$Label.PrimaryReason}" for="primaryReason" />
                    <apex:actionRegion>
                        <apex:inputField id="primaryReason" value="{!lead.Primary_Reason__c}">
                            <apex:actionSupport event="onchange" rerender="pbs1" />
                        </apex:inputField>
                    </apex:actionRegion>
                                    
                    <apex:outputLabel value="If Other Reason is selected enter more information here" for="primaryReasonOther"
                                        rendered="{!IF(lead.Primary_Reason__c == 'Other', 'true', 'false')}"/>
                    <apex:inputField id="primaryReasonOther" value="{!lead.Other_Reason__c}"
                             required="true" rendered="{!IF(lead.Primary_Reason__c == 'Other', 'true', 'false')}"/>
                </apex:panelGrid>
            </apex:pageblockSection>
            <apex:pageBlockSection collapsible="false" columns="1" id="pbs3">
                <apex:panelGrid columns="2" rendered="{!IF(lead.Country__c == 'United States', 'true', 'false')}">
                    <apex:outputLabel value="{!$Label.Diversity_Programs}" for="diversityprogramsusonly" />
                    <apex:inputField id="diversityprogramsusonly" value="{!lead.Diversity_Program_US_Only__c}" />
                </apex:panelGrid>
            </apex:pageBlockSection>
        </apex:pageBlock>

 

If you see above, I am doing it both ways, but I am trying to test out if I can archieve it without adding a wrapper around the component. When I do that it works, but it clears all the data. Does anyone know why the data is not being stored to the lead object? Also, if there is a solution for this. I am looking for something other than a wrapper component.  Thanks.

 

Sanch.

  • August 03, 2012
  • Like
  • 0

Hi All,

 

We are trying to implement the best practice for code management with the option to check in the code in a source control tool like SVN. Does anyone have any suggestions? Please share any documents or ideas. Thank You.

 

Sanch

  • July 21, 2011
  • Like
  • 0

Hi there,

 

I have two different batch class. I need the second one to start when the first one finishes. But I cannot call another batch within a batch. Is there any other way to archieve this? Thanks.

 

Sanch

  • May 19, 2011
  • Like
  • 0

Hi All,

 

I have the following code

 

 

for(Contact[] contList : Database.query(queryToExecute + 'limit 10000')) {
	for(Contact cont : contList) { }
}

 

When I do this, how does the Limit keyword affect the result? Let's assume there is 30,000 records that match the query.  I have a limit of 10,000 in the query. Would it pull the 10,000 only and forget the rest? OR would it pull the 10,000 first process them and then pull the next 10,000 and process that and the next 10,000 and process them? How does this work? Thanks.

 

Sanch.

 

  • April 29, 2011
  • Like
  • 0

Hi All,

 

I am wondering how the garbage collection works in salesforce? I am building a batch process and I am expecting the execute method to be called 1000 times with batch size of 50. So each time the execute method is called I am passing a looping through the List of sobjects and casting them to the Account object and assigning them to a List. The List variable defined in the execute method it self. So that mean's I would have creatd 1000 different variables and I am sure this will make use of memory. I dont' know how the garbage collection works and what the best practice is. I was thinking defining the List variable as a local variable within the batchable class and then cleaning up the list and adding the new list of records each time the execute method is called.  Can someone explain how the memory is allocated for these objects? Thanks.

 

Sanch

  • April 28, 2011
  • Like
  • 0

Hi there,

 

I there, I would like to rank an account based on the Total Revenue. But not quite sure how to implement this. Has anyone implemented this before? Please share your ideas. Thank you very much in advance. 

 

Sanch

  • April 06, 2011
  • Like
  • 0

Hi All,

 

I have an object called Notes where it has a look up to the Client(Account) Object. I have a trigger on after insert and update.

 

For update, I am checking the old Client lookup value to the new one and doing some processing for that. But the Trigger.Old[i] only return's the Id, OwnerId and the isDeleted flag when I click "Save and New" Button and it return's the whole object when I click "Save". As a result I am getting an error. This seems like a salesforce bug, but I am just wondering if anyone have come across this before? Thanks.

 

The error message is:

 

 

Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger NotesSharing caused an unexpected exception, contact your administrator: NotesSharing: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.NotesSharing: line 61, column 4". 
The error message occurs when I access Trigger.Old[i].Client__c. This works fine for Save, but it doesn't have the Client__c field value for Save and New. Does anyone know why? Thanks.
Sanch.

 

 

 

  • February 23, 2011
  • Like
  • 0

Hi there,

 

I am using the batch apex and I am trying to see how I can handle errors within the execute() method. I want to be able to find out which batch of records fail, so I could just run those records again in the future. Is there a way to do this? Please help. It's Urgent. Thanks.

 

Sanch

  • January 27, 2011
  • Like
  • 0

Hi there,

 

I was wondering, if it's possible to do the following. I have an object Revenue and a called a field called ProductA_Total__c. Right now I am retrieving the object as follows:

 

Revenue__c rev = [Select ProductA_Total__c From Revenue__c];
rev.ProductA_Total__c;

 

I want the fields to be dynamic, because there could be additional products in the future. So I have these fields in a custom setting. So If I need a field called ProductB_Total__c in the future, all I need to do is add that field to the object and add it to the custom setting. Now I could access the fields from the custom setting. I want to use the fields in the custom setting to retrieve the value. How can I do that. I have tried the following:

String FieldName = 'ProductB_Total__c';
rev.[FieldName];


And I have also tried the following:

rev[FieldName];

 

 

Is this even possible through apex? Please help asap. Thanks.

 

Sanch.

  • January 21, 2011
  • Like
  • 0

Hi there,

 

Is it possible to create a salesforce report that gives me all duplicate contacts? A contact is duplicate if there is more than one contact with the same email address. I only want the report to display the contacts that are duplicate and ignore those. Is this possible? Thanks.

 

Sanch.

  • January 10, 2011
  • Like
  • 0

Hi Guys,

 

I have an issue with New Button Override. I have a custom visualforce page for the Account. When the user clicks the new button to create a contact a method is called. The method does the following:

 

String newContactUrl = '/003/e?retURL=/' + this.acct.Id +'&accid=' + this.acct.Id;
        
return new PageReference( newContactUrl );

 

Also, The Contact's standard New Button is overriden with an s-control. In the s-control, I check the user's group, if they are a certain group I send them to a custom contact edit page otherwise I redirect them to standard salesforce page. Here is the code:

 

<script> 

function load() { 

if (('{!User.Group__c}' == 'TRG') || ('{!User.IsTRG__c}' == 1)){ 
var acctId = '{! Account.Id}'; 
if ( acctId == null || acctId == '' ) 
parent.location.href = '/apex/TRGContactEdit?RecordTypeId={!Contact.RecordTypeId}&cancelURL={!$Request.retURL}&saveURL={!$Request.retURL}&retURL={!$Request.retURL}'; 

else 
parent.location.href = '/apex/TRGContactEdit?con4_lkid={!Account.Id}&con4={! Account.Name}&RecordTypeId={!Contact.RecordTypeId}&retURL={!$Request.retURL}'; 

} 
// if any other user direct to default Contact detail view 
else { 

parent.location.href= '{!URLFOR($Action.Contact.NewContact, null, [con4_lkid=Account.Id,retURL=$Request.retURL], true)}'; 

} 
} 
</script> 

<body onload=load();> 
</body>

 

 

This works for most of the Accounts, but one of the account that I am trying, it doesn't work. It get a blank page with error on page. The error that I got by double clicking the page is:

 

Message: Expected ';'
Line: 13
Char: 84
Code: 0
URI: https://cs3.salesforce.com/servlet/servlet.Integration?lid=01NQ0000000CiDT&ic=1


Message: Object expected
Line: 25
Char: 1
Code: 0
URI: https://cs3.salesforce.com/servlet/servlet.Integration?lid=01NQ0000000CiDT&ic=1

 

For the user that I am using, it should go to the standard salesforce edit page for contact. It works for most of the accounts. But for one account, it's not working. Please help. Thanks.

 

Sanch

  • January 05, 2011
  • Like
  • 0

Hi there,

 

I want to know if it's possible to check if the current user's Role is higher than another user's role through Apex. Is this possible? Thanks.

 

Sanch

  • October 21, 2010
  • Like
  • 0

Hi there,

 

I am sure some of you guys came across this issue already, but here is the issue that I have:

 

1. I have a custom object that has a look up to an Account.

2. I have a custom visualforce page for Account and I have the custom object as a related list.

3. I know that if the user's profile does not have atleast read access on the custom object it will throw an exception. So on the rendered property, I have added to see if the user is able to access the object.

4. I also know that the related list has to be in the page layouts, otherwise it will throw the same exception, so I have added the object as a related list.

5. Now at the user level, each user can customize their page view, but removing the related lists. If the pagelayout has the related list, and if the user customize it to remove it, it will throw an exception. This could cause a nasty error in Production, which it did.

 

I want to know if there is a way to check if the current user's page layout has the object as a related list through code. Is this possible? Thanks.

 

Sanch

  • September 29, 2010
  • Like
  • 0

Hi there,

 

I want to do partial refresh from Prod. I have a Role in Production which I want to copy to my sandbox with the same SFDC ID. Is this possible through some kind of partial Data Refresh or do I have to do a full refresh again? Is there any other way? Thank You.

 

 

  • September 20, 2010
  • Like
  • 0

Hi there,

 

I have two visualforce pages. PageA and PageB.

 

In PageA, I have a pageBlockTable and one of the column is a commandLink:

 

<apex:column headerValue="Name">
     <apex:commandLink value="{!jb.Name}" action="{!jbDetail}" >
          <apex:param name="eJbId" value="{!jb.Id}" />
     </apex:commandLink>
</apex:column>

 

 

When the user clicks the commandLink I am passing a parameter to the action jbDetail and that method takes the user to the PageB.

 

This all works fine and it opens in the same page and that is how I want it to work. But now if a user goes to pageA and right click the commandLink above and select 'Open in New Tab' or 'Open in New Window', it opens PageA again on the tab or the new window instead of opening PageB.  How can I fix this? Did anyone come across this before? Please help. Thank You.

 

Sanch.

  • June 24, 2010
  • Like
  • 0

Hi there,

 

I have a custom object called Job and I created a custom view in visualforce for that object and that is the view that I am using when I go to view a job record.  Now I have another visualforce page where I am listing all the Jobs. When the user clicks a job on that list I am also taking them to the same visualforce page that I created above for the job. I have a back button on the visualforce page. What I want to do is when I click the back button I want to go back to the return URL where it came from. So if I go to the job visual force page from the visualforce page that I created to list all jobs then I should go there. If I go to the job record through a contact(contact is related to job), then I want to go to the contact page or what ever page that I came from. Is there a way to get the return URL in salesforce? How would you approach this? Thanks.

 

Sanch.

  • June 18, 2010
  • Like
  • 0

Hi there,

 

I have a requirement where I have to add a custom image button for the Contact. I want to be able to control the styling of the button with an image of my choice and shape of my choice. How can this be archieved? Please help. Thank you in advance.

 

Sanch.

  • June 11, 2010
  • Like
  • 0

Hi All,

 

I have the following:

 

1. A child object called Review under Opportunity object.

2. I have a custom visualforce page which overwrites the New Button. It's purpose is to prepopulates couple of fields. 

3. One of the fields that I am prepopulating is called ReadOnlyTest__c. It is populated with the text 'Testing ReadOnly'

4. The user has full access to the object

5. On the page layout I have made the field read Only.

 

What I am trying to archieve is prepopulate the field ReadOnlyTest__c with the value 'Testing ReadOnly' and make that field not editable by the user. But the user has to visually see this field. 

 

I do know I can do this with custom visualforce page.  But my goal is to do this with standard page layout. I expected the text to be pre-pulated. But what happens is the page renders fine and it shows the field as read only, but the text 'Testing ReadOnly' is missing. It's just empty. Can someone help me with what I might be doing wrong here?

 

Sanch

  • August 09, 2012
  • Like
  • 0

Hi All,

 

I have a field which is of type Rich Text Area. In this field I am generating an html table where I am displaying some values that are numbers. When I do that the comma in the values are lost and if it's 8000, it just displays 8000 rather than 8,000. What can I do to maintain the comma. Thanks.

 

Sanch

  • August 08, 2012
  • Like
  • 0

All I want to do is record a date onto the Account record when a Task is created of Activity Type "Phone Call", that's it.  Unfortunately my experience level with Trigger programming is very low still and my workload is killing my efforts to go through the video training on our Premier support plan.

Anyone have a simple trigger mechanism that will do this?  I could probably write 80% of it, but the actual opening-and-linking to the Task and Account databases is my issue.  Stamping the date after verifying the Activity Type is a no-brainer.   :-/    I can't seem to find a good resource of Trigger code samples on the web.

Thanks for any help anyone can give...   I've been pretty sidetracked with tasks today, and threw together the below code in text editor which I am sure is not complete/correct yet, just as a reference.  :-/

 

 

trigger PiggybackTriggerTasks on Task (after insert) {

    List<Task> listTask = new List<Task>();
    List<Id> listAccountId = new List<Id>();

    if ( trigger.isInsert ) {

        for(Task thisTask: trigger.new) {

            if ( thisTask.Activity_Type__c == 'Phone Call' ) { listAccountId.add(thisTask.What); }

        }

        Account objAccount = mapIdAccount.get(thisAccountId);

        thisAccount.Last_PhoneCall_Activity__c = thisTask.ActivityDate

    }

}

Hi All I have one class. I wrote a test class for that its save but when run test i m getting error like this 

 

System.QueryException: List has no rows for assignment to SObjectClass.MagnysApprovalController.<init>: line 9, column 10 Class.Test_Pages.testMagnysApprovalController: line 24, column 46 External entry point

My class is 

public with sharing class MagnysApprovalController{
    Private string comment = '';
    public String oppId= ApexPages.currentPage().getParameters().get('OppId');
    public Opportunity o;
    public List<Quote__c> qlist;
    public Quote__c q;
    public List<QuoteLine__c> TempQuoteLine;
    public MagnysApprovalController(){
      o = [select Id, Name, Owner.Name, Owner.Employee_ID__c, AccountId, Account.Name, Scope_of_Work__c, Existing_Services_Replaced__c, Amount from Opportunity
                 where id= :oppId];
       qlist = [Select Id, Total_Quote_Amount__c, Primary__c, Opportunity__c, Name, Contract_Term__c, Contract_Start_Date__c, AverageDiscountPercentage__c From Quote__c 
                where Opportunity__c = :oppId and Primary__c = true limit 1];
      if( qlist.size()>0 ){
        q = qlist.get(0);
          TempQuoteLine = [select id, MasterProduct__c, Total_Sale__c, MagnysServiceCode__c, MagnysRevenue__c, Term__c, Previous_Price__c, MasterProduct__r.Name, MagnysServiceCode__r.Name from QuoteLine__c where Quote__c = :q.Id];
      }  
    } 
    public Opportunity getOpp(){
        return o; 
    }
    public Quote__c getQuote(){
        return q;
    }
    public List<QuoteLine__c> getqlList(){
        return TempQuoteLine;    
    }
    public string getComment()
    {
        return comment;
    }
    public void setComment(string Value){
        comment= Value;
    }
    public PageReference reject() {
        PageReference pr = null;
        try{        
            ProcessInstanceWorkitem piwi = [Select ProcessInstance.Status, ProcessInstance.TargetObjectId, ProcessInstanceId,OriginalActorId,Id,ActorId From ProcessInstanceWorkitem
            where ProcessInstance.TargetObjectId = : oppId and ProcessInstance.Status = 'Pending' and OriginalActorId =: UserInfo.getUserId() order by CreatedDate desc limit 1];    
            Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
            req.setComments(comment);
            req.setAction('Reject');
            req.setWorkitemId(piwi.Id);
            // Submit the request for approval      
            Approval.ProcessResult result =  Approval.process(req);        
            pr = new PageReference('/home/home.jsp');
        }
        catch(Exception ex){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,ex.getMessage()));
        }
        return pr;
    }
  public PageReference reject1() {
        PageReference pr = null;
        try{        
            ProcessInstanceWorkitem piwi = [Select ProcessInstance.Status, ProcessInstance.TargetObjectId, ProcessInstanceId,OriginalActorId,Id,ActorId From ProcessInstanceWorkitem
            where ProcessInstance.TargetObjectId = : oppId and ProcessInstance.Status = 'Pending' and OriginalActorId =: UserInfo.getUserId() order by CreatedDate desc limit 1];
            Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
            req.setComments(comment);
            req.setAction('Reject');
            req.setWorkitemId(piwi.Id);
            // Submit the request for approval      
            Approval.ProcessResult result =  Approval.process(req);        
            //pr = new PageReference('/home/home.jsp');
            pr = new PageReference('/apex/mobileApprovalList?sfdc.tabName=01r40000000LnKP');
        }
        catch(Exception ex){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,ex.getMessage()));
        }
        return pr;
    }
    public PageReference approve(){
        PageReference pr = null;
        try{  
            ProcessInstanceWorkitem piwi = [Select ProcessInstance.Status, ProcessInstance.TargetObjectId, ProcessInstanceId,OriginalActorId,Id,ActorId From ProcessInstanceWorkitem
            where ProcessInstance.TargetObjectId = : oppId and ProcessInstance.Status = 'Pending' and OriginalActorId =: UserInfo.getUserId() order by CreatedDate desc limit 1];
            Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
            req.setComments(comment);
            req.setAction('Approve');
            req.setWorkitemId(piwi.Id);
            // Submit the request for approval      
            Approval.ProcessResult result =  Approval.process(req);
            pr = new PageReference('/home/home.jsp');
        }
        catch(Exception ex){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,ex.getMessage()));
        }
        return pr;
    }
    public PageReference approve1(){
        PageReference pr = null;
        try{  
            ProcessInstanceWorkitem piwi = [Select ProcessInstance.Status, ProcessInstance.TargetObjectId, ProcessInstanceId,OriginalActorId,Id,ActorId From ProcessInstanceWorkitem
            where ProcessInstance.TargetObjectId = : oppId and ProcessInstance.Status = 'Pending' and OriginalActorId =: UserInfo.getUserId() order by CreatedDate desc limit 1];
            Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
            req.setComments(comment);
            req.setAction('Approve');
            req.setWorkitemId(piwi.Id);
            // Submit the request for approval      
            Approval.ProcessResult result =  Approval.process(req);
            //pr = new PageReference('/home/home.jsp');
            pr = new PageReference('/apex/mobileApprovalList?sfdc.tabName=01r40000000LnKP');
        }
        catch(Exception ex){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,ex.getMessage()));
        }
        return pr;
    }     
}

 

And test class is 

 

  public static testMethod void testMagnysApprovalController() 
    {      
        Test.startTest();
        PageReference result = Page.MagnysApproval;
        Test.setCurrentPage(result);
                        
        Account account= new Account(Name='Test Account', Type='Standard Account', Federal_Tax_ID_No__c='01010101', 
        Main_BTN__c='(000)000-7654', ShippingStreet='000 Test St', ShippingCity='Dallas', 
        ShippingState='Tx', ShippingPostalCode='75050');
        insert account; 
       
        Opportunity opp = new Opportunity(Name='Test Opp1', Existing_Services_Replaced__c = 'none', AccountId=account.Id, Scope_of_Work__c='Test', 
        Proposal_Issued_Date__c=Date.Today(), StageName='Closed Won',CloseDate=System.today());
        insert opp;
        
        Quote__c q = new Quote__c(Contract_Term__c = '12',Name='Test',Opportunity__c = opp.id);
        insert q;
        Profile p = [select id from Profile limit 1];
         User u = new User(ProfileId = p.id,LastName = 'Test', FirstName = 'Test', Username = 'testing456@test.com', Alias='test', CommunityNickname='test', Email='test@email.com',TimeZoneSidKey='America/Chicago',EmailEncodingKey='ISO-8859-1', LanguageLocaleKey='en_US', LocaleSidKey='en_US',IsActive=false);
                
        insert u;
         
 
        MagnysApprovalController extension = new MagnysApprovalController();
    
        extension.getComment(); 
        extension.reject();
        extension.reject1();
        extension.approve();
        extension.approve1();              
    }  
    

i wish to execute a single class in Force.com IDE how can i do that. deploying in sandbox takes lot of time so i want to create class and then check its errors also simultaneously how can i do dat.

if the class is related to visual Force pages then what are the steps to execute it in Force.com or any other environment with out deploying is in production

Hi All,

 

I have the following code

 

 

for(Contact[] contList : Database.query(queryToExecute + 'limit 10000')) {
	for(Contact cont : contList) { }
}

 

When I do this, how does the Limit keyword affect the result? Let's assume there is 30,000 records that match the query.  I have a limit of 10,000 in the query. Would it pull the 10,000 only and forget the rest? OR would it pull the 10,000 first process them and then pull the next 10,000 and process that and the next 10,000 and process them? How does this work? Thanks.

 

Sanch.

 

  • April 29, 2011
  • Like
  • 0

Hi,

 

I am unable to get this to work.

I am trying to render a pageblock based on the selection of the picklist value. if the Opportunitystage=='Qualification' i want to then render the close date field.

in the below code i want to display the Closedate only when an Opportunity stage is selected and equals to "Qualification"

I don't know if i am doing any AJAX requests incorrectly.Can any one help me with this.

 

Page:

<apex:page standardController="Opportunity">
  <apex:form >
    <apex:pageBlock title="Edit Opportunity" id="thePageBlock" mode="edit">
   
      <apex:pageBlockButtons location="bottom" >
        <apex:commandButton value="Save" action="{!save}"/>
        <apex:commandButton value="Cancel" action="{!cancel}"/>               
      </apex:pageBlockButtons>

    <apex:pageBlockSection columns="1">
      <apex:inputField value="{!opportunity.name}"/>
      <apex:pageBlockSectionItem >
      <apex:outputLabel value="{!$ObjectType.opportunity.fields.stageName.label}" 
                        for="stage"/>
      <!-- 
           Without the actionregion, selecting a stage from the picklist would cause 
           a validation error if you hadn't already entered data in the required name 
           and close date fields.  It would also update the timestamp.
      -->  
    
      <apex:actionRegion renderRegiononly="{!opportunity.stageName !='Qualification'}" >
        <apex:inputField value="{!opportunity.stageName}" id="stage">
          <apex:actionSupport event="onchange" rerender="ajaxrequest"
                              status="status"/>
          </apex:inputField>
          </apex:actionRegion>
      </apex:pageBlockSectionItem>
        
       
        </apex:pageBlockSection>
        
          <apex:outputPanel id="ajaxrequest" rendered="{!Opportunity.StageName}" > 
              <apex:inputField value="{!Opportunity.CloseDate}"/>
             {!text(now())}
          </apex:outputPanel> 
        
      </apex:pageBlock>
    </apex:form>
</apex:page>

Thanks,

Sales4ce

Hi there,

 

I am using the batch apex and I am trying to see how I can handle errors within the execute() method. I want to be able to find out which batch of records fail, so I could just run those records again in the future. Is there a way to do this? Please help. It's Urgent. Thanks.

 

Sanch

  • January 27, 2011
  • Like
  • 0

Hi Guys,

 

I have an issue with New Button Override. I have a custom visualforce page for the Account. When the user clicks the new button to create a contact a method is called. The method does the following:

 

String newContactUrl = '/003/e?retURL=/' + this.acct.Id +'&accid=' + this.acct.Id;
        
return new PageReference( newContactUrl );

 

Also, The Contact's standard New Button is overriden with an s-control. In the s-control, I check the user's group, if they are a certain group I send them to a custom contact edit page otherwise I redirect them to standard salesforce page. Here is the code:

 

<script> 

function load() { 

if (('{!User.Group__c}' == 'TRG') || ('{!User.IsTRG__c}' == 1)){ 
var acctId = '{! Account.Id}'; 
if ( acctId == null || acctId == '' ) 
parent.location.href = '/apex/TRGContactEdit?RecordTypeId={!Contact.RecordTypeId}&cancelURL={!$Request.retURL}&saveURL={!$Request.retURL}&retURL={!$Request.retURL}'; 

else 
parent.location.href = '/apex/TRGContactEdit?con4_lkid={!Account.Id}&con4={! Account.Name}&RecordTypeId={!Contact.RecordTypeId}&retURL={!$Request.retURL}'; 

} 
// if any other user direct to default Contact detail view 
else { 

parent.location.href= '{!URLFOR($Action.Contact.NewContact, null, [con4_lkid=Account.Id,retURL=$Request.retURL], true)}'; 

} 
} 
</script> 

<body onload=load();> 
</body>

 

 

This works for most of the Accounts, but one of the account that I am trying, it doesn't work. It get a blank page with error on page. The error that I got by double clicking the page is:

 

Message: Expected ';'
Line: 13
Char: 84
Code: 0
URI: https://cs3.salesforce.com/servlet/servlet.Integration?lid=01NQ0000000CiDT&ic=1


Message: Object expected
Line: 25
Char: 1
Code: 0
URI: https://cs3.salesforce.com/servlet/servlet.Integration?lid=01NQ0000000CiDT&ic=1

 

For the user that I am using, it should go to the standard salesforce edit page for contact. It works for most of the accounts. But for one account, it's not working. Please help. Thanks.

 

Sanch

  • January 05, 2011
  • Like
  • 0

Hi,

 

Is there a way to prepopulate and show a read only field on the new/edit form (where the data is entered for the record)

 

Thanx

Hi,

 

We have custom Customers Object, in which we have a record type that stores the customer location. For this we are storing the corresponding  customer ID in a custom lookup field for customer location record.

 

we are showing  the customer location records in the related list of the customer object. we are creating the customer location record using  a custom button in the related list , for this button click we are  passing recordtype=recordtypeid in the url , so that the page navigates to the customerlocation record type by default.

 

The problem , we need to pre-populate the parent customer id for the corresponding customer location record.

In the salesforce documentation it was given that if we pass the html id of the lookup fields in the query string , the values will be populated automatically.

 

e?CF00NA000000248R5=C-1689&CF00NA000000248R5_lkid=a0MA0000000h8UN&RecordType=012A0000000DDSvIAO&retURL=/a0MA0000000h8UN

 

This is working fine with in an Specific Org, but if we move the code into another org, the html id of the lookup wont be the same , and the lookup is not populating. 

 

Any ideas on how to proceed on this ?

 

Thanks,

yvk431

 

Hi there,

 

I have a visualforce page which has a link that will taken in the server URL to an application outside of salesforce.  I am trying to access the Server URL on the visual force page controller. But I can't seem to use the $Api.Partner_Server_URL_180 in the controller. Why is that? How do I access the Server URL from the controller? Please let me know. I would really appreciate everyone's help. Thank you.

  • May 25, 2010
  • Like
  • 0
I'm trying to come up with a realtime customer account ranking formula that can be displayed on the customer record, and in reports.  This will be very helpful from a Support as well as Executive standpoint for us.

For example, customers may purchase anywhere between 2-20,000 widgets each month from our company.  We currently capture this data in salesforce in a field called 'widgets last 30'.

I'd like to compare the 'widgets last 30' value across all customer accounts in our system, and then return a value (rank) in the customer record based on this relative ranking.  We have different customer 'Types' as well (Retail, Wholesale, etc.) so it will be important to return a ranking based upon this customer Type.

I think I can accomplish this by simply creating a new field of type formula, but I'm a little lost on how to craft the formula to capture this 'ranking'.
  • September 29, 2009
  • Like
  • 0

Is it possible to create a field on an account that calculates the ranking of this account compared to other account based on the number field (like for example revenue). Recalculation would happen maybe once a day at most, after the daily mass upsert from the backoffice.

Anyone has ever done something like this? I am not a developer, but I know how to re-use :womanvery-happy:.

 

Thanks in advance!!

Are there any functions that can be used in validation rules or apex triggers/classes that can be used to compare two roles and return whether one is higher in the role hierarchy than the other?

 

 

Thanks.

I noticed that my Visualforce page threw the following error when I tried to add a related list that was perfectly well defined in the object's setup but happened not to be in the Page Layout: 'SubContracts__r' is not a valid child relationship name for entity Licensing Contract

This appears to be an undocumented restriction on the use of <apex:relatedList> not to mention one that could potentially cause some nasty issues in a production environment should an admin update a page layout or create a new one after the orginal page is deployed. Likewise, if they create new recordtypes or recordtype/profile assignments. This restriction is not intuitive; one generally thinks of Visualforce as an alternative to a Page Layout, not as an extension that is bound to it and inherents its content restrictions. Additionally, for developers who have over-ridden all page-layouts for an object with VF pages, it is counter-intuitive to have to edit a Page Layout that is not in use simply to include the list in their VF pages.

Could someone respond back with some clearer details on how this actually works? Does Visualforce simply require that one page layout include the related list or does it require the page layout for the given record type include it. Wouldn't it be more robust to simply define the apex:related list to display based on user permissions rather than throw an error if the list is not found in the related page layout.


Message Edited by lnryan on 12-16-2008 01:12 PM
  • December 16, 2008
  • Like
  • 0