• Mike Fitch
  • NEWBIE
  • 60 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 31
    Replies
I'm new to development and wanted to know how I would go about changing what page users are taken to when they click 'ok' on the confirm deletion popup window. I'm using the popup on a custom VF form I created and when 'ok' is clicked it takes users to the list view for the object the VF form was created for. I want users to be taken to the home page instead. If someone could guide me as to how i would begin to make that change i would appreciate it. Thanks.
I have a VF form that i created and I included a delete button with a popup window that asks the user to confirm deletion. The cancel button works properly, but if the user clicks OK, it takes them to a page that has an error message saying URL no longer exists. Here is the code:

<script type="text/javascript">
            function confirmDelete() {
            return confirm('Are you sure you want to delete?');
            }
            </script>
            <apex:commandButton action="{!delete}" value="Delete" onclick="if(!confirmDelete()) return false;" reRender="PrecallForm"/>

Any suggestions?
I have a visualforce form that i use for a custom object. The help text works with all fields except these:

<apex:pageBlockSection title="Precall Planning Questions" columns="1">
            <p><apex:inputField value="{!Precall_Plan_2__c.Question1__c}" label="What is my long range sales target for this account?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question2__c}" label="What is my specific objective for this call?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question3__c}" label="What do I plan to show? (Product, demo, sample, chart, etc.)"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question4__c}" label="Who or What is your competition and what are their disadvantages?  What is their primary advantage?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question5__c}" label="What benefit or solution can you provide to this customer?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question6__c}" label="What is the monetized value of your solution?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question7__c}" label="What is your 'TARGETED BENEFIT STATEMENT'?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question8__c}" label="What needs analysis questions do you intend to ask?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question9__c}" label="What is your sellers leverage?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question10__c}" label="What objections do you anticipate?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question11__c}" label="How do you plan to overcome these objections?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question12__c}" label="What closing techniques/statements will you use?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question13__c}" label="What potential value can you bring to this customer?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question14__c}" label="Who else is on this call and what is their role?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question15__c}" label="In 30 words or less, define the account strategy; include necessary resources to support."/></p>
        </apex:pageBlockSection>

I'm not sure why it doesnt work for these fields only. Can someone help me? Thanks
I created a custom object in my org and created custom lookup fields for account and contact so they would show up in the respective related list. When i create a new record for my custom object via the related list in either account or contact it does not pre populate the lookup field. The users have to click the lookup magnifying glass and select the account or contact themselves. How do I fix this?
I've only been able to get 72% code coverage for my apex class. I'm new to apex development. Can someone help me please?

Here is my class:

public class PcPContactInfo {
    public Precall_Plan_2__c c{get; set;}
   
    public PcPContactInfo(ApexPages.StandardController controller)
        {
             c = (Precall_Plan_2__c)controller.getRecord();
        }
   
    public pagereference logout()
        {  
             pagereference p1=new pagereference('/apex/Precall_Plan_Detail_clone?id='+c.get('Id')+'&clone=1');
             return p1;
        }
   
   
    public PageReference dosave()
        {   
             try
            {
                 if(ApexPages.currentPage().getParameters().get('clone')=='1'||ApexPages.currentPage().getParameters().get('save_new')=='1')
                    {
                        c.id=null;                   
                        insert c;
                    }
               
                 else
                        update c;
            }
       
                 catch(exception e) { ApexPages.addMessages(e); return null;  } 

                 return new Pagereference('/' + c.get('Id'));
        }
    
    public void doSomething()
        {
           contact TEST = [SELECT account.name,MailingCountry,Mailingcity,Title,Phone,MailingStreet,MailingState,MailingPostalCode, accountid FROM contact where id = :c.Contact_name2__c];
           // c.Company_Name__c= TEST.account.name;
           c.Contact_mailing_city__c=TEST.Mailingcity;
           c.Contact_s_Title__c=TEST.Title;
           c.Contact_s_Telephone_Number__c=TEST.Phone;
           c.Contact_Street__c=TEST.MailingStreet;
           c.Contact_State__c=TEST.MailingState;
           c.Contact_Zip__c=TEST.MailingPostalCode;
     
        }
}

And here is my Test Class:

@isTest
private class test_PcPContactInfo
{

    static testMethod void go_PcPContactInfo() 
    {
   
        account a = new account(name='ESAB');
        insert a;
        contact c = new contact (lastname= 'test2',accountid=a.id,email='abc@gmail.com');
        insert c;
       
        Precall_Plan_2__c  cw=new Precall_Plan_2__c(name='test',Contact_name2__c=c.id,Company_Name__c=a.id);
        insert cw;
       
        ApexPages.StandardController controller = new ApexPages.StandardController(cw);
        PcPContactInfo stdController = new PcPContactInfo(controller);
        //account a = [SELECT name,id FROM account limit 1];
       
        //contact TEST = [SELECT id, accountid,email FROM contact where id = :cw.contact__c];
        //cw.Email__c = TEST.email;
        //update cw;
       
        stdController.doSomething();
        stdController.dosave();
       
       
    }
}
Hello everyone,

I created a VF form for my org, which i created a custom object for, and some of my users are getting an error when trying to create a new form from an opportunity related list. If they create it directly from the custom object tab then there isnt any problems. The error is 'Id not specified in an update call'. I have 2 different profiles that use this form and only one of the profiles recieves this error. The other profile has no problem. I will post the code for the form if need be, however it consists of 5 different VF pages, an apex class and the test class to go along with it. I didnt want to post all of the code and confuse anyone if the problem was some salesforce setting or declaritive change that i can make, but i will post the code if necessary. The two profiles have different page layouts for most if not all objects as well as different custom fields, but the custom fields related to the form are identical as are any cross object lookups used by the form. I will post any information or code needed, but like i said earlier, i didnt want to post hundreds of lines of code and confuse anyone. Please advice as soon as possible.

Thanks
How exactly do you comment in VisualForce? // Is for a single line if I'm not mistaken. /* is for more then one line I believe as well. However, I've encountered <-----
also. What does that mean? When it's used, it greys out the code, but the code within still seems to function. Can someone help me with what that means?
I created a validation rule on the opportunity object that limits the Probability % field to certain values. I need to make this rule active for a particular record type. I need help with the syntax in order to do this. Here is the formula:

OR(
AND(
ISPICKVAL(StageName,"Closed Lost"),
Probability <> 0),
AND(
MOD(Probability*100,10)<>0,
!ISPICKVAL(StageName,"Closed Lost"),
!ISPICKVAL(StageName,"Closed Won")
),
AND(
OR(
Probability = 0.5,
Probability = 0,
Probability = 1),
!ISPICKVAL(StageName,"Closed Lost"),
!ISPICKVAL(StageName,"Closed Won")
),
AND(
ISPICKVAL(StageName,"Closed Won"),
Probability <> 1)
)

I created a trigger that works with the Opportunity object, however I need it to only work for a particular record type. I'm pretty new to apex development so I'm a beginner at best. The trigger works and I managed 75% code coverage, but it's effecting the other record types in my org and causing errors. Any help with this issue would be appreciated. Thanks

Here is my trigger:

trigger ClosedLostOtherInactive on Opportunity (before update) {
   
     for (Opportunity closedlost : Trigger.new) {
         if (closedlost.StageName == 'Closed Lost')
         {
         If ( (closedlost.Closed_Lost_Other__c == false && closedlost.Closed_Lost_Inactive__c == false)) {

             closedlost.adderror('Please select either Closed Lost - Other or Closed Lost - Inactive checkbox ');
         }
         if (closedlost.Lost_Detail_Other_or_Inactive__c == null)
         {
             closedlost.adderror('Lost Detail - Other or Inactive text field is required ');
         }
         }
         If (closedlost.Closed_Lost_Inactive__c == True) {
                      
             closedlost.Closed_Lost_Other__c = false ;
         }
     }
}


And here is the test class:

@isTest
public class TestClosedLostOtherInactive{
   
static testmethod void insertOpportunity() {

        Opportunity o = new Opportunity();
  
    o.Name = 'TestOpp';
    o.CloseDate = System.today();
    o.StageName = 'Identifying';
    o.CurrencyIsoCode = 'USD';
    o.Closed_Lost_Inactive__c = False;
    o.Closed_Lost_Other__c = False;
    o.Lost_Detail_Other_or_Inactive__c = null;
  
    insert o;
   
      o.StageName = 'Closed Lost';
        o.Closed_Lost_Inactive__c = True;
        o.Closed_Lost_Other__c = False;
        o.Lost_Detail_Other_or_Inactive__c = 'Test';
        update o;
    }
       
}


I created a validation rule for the standard probability stage in opportunities. What I need the rule to do is limit the users to entering percentages only divisible by 10 with three exceptions. 1) They can never use 50% for any stage. 2) The minimum is 10% unless the stage is 'closed lost' which has a probability of 0%. 3) The maximum is 90% unless the stage is 'closed won' which has a probability of 100%. I can get the error message to come up only when 100% is entered on a stage other then closed won. The system still allows 0% and 50%. Here is my rule:

OR(
AND(
!ISPICKVAL(StageName,"Closed Won"),
Probability<>0.50,
MOD(Probability*100,10)<>0)
,
AND(
!ISPICKVAL(StageName,"Closed Won"),
Probability=1)
)

Can someone help me and show me what I'm doing wrong?
Thanks
I'm new to development and wanted to know how I would go about changing what page users are taken to when they click 'ok' on the confirm deletion popup window. I'm using the popup on a custom VF form I created and when 'ok' is clicked it takes users to the list view for the object the VF form was created for. I want users to be taken to the home page instead. If someone could guide me as to how i would begin to make that change i would appreciate it. Thanks.
I have a VF form that i created and I included a delete button with a popup window that asks the user to confirm deletion. The cancel button works properly, but if the user clicks OK, it takes them to a page that has an error message saying URL no longer exists. Here is the code:

<script type="text/javascript">
            function confirmDelete() {
            return confirm('Are you sure you want to delete?');
            }
            </script>
            <apex:commandButton action="{!delete}" value="Delete" onclick="if(!confirmDelete()) return false;" reRender="PrecallForm"/>

Any suggestions?
I have a visualforce form that i use for a custom object. The help text works with all fields except these:

<apex:pageBlockSection title="Precall Planning Questions" columns="1">
            <p><apex:inputField value="{!Precall_Plan_2__c.Question1__c}" label="What is my long range sales target for this account?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question2__c}" label="What is my specific objective for this call?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question3__c}" label="What do I plan to show? (Product, demo, sample, chart, etc.)"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question4__c}" label="Who or What is your competition and what are their disadvantages?  What is their primary advantage?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question5__c}" label="What benefit or solution can you provide to this customer?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question6__c}" label="What is the monetized value of your solution?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question7__c}" label="What is your 'TARGETED BENEFIT STATEMENT'?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question8__c}" label="What needs analysis questions do you intend to ask?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question9__c}" label="What is your sellers leverage?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question10__c}" label="What objections do you anticipate?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question11__c}" label="How do you plan to overcome these objections?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question12__c}" label="What closing techniques/statements will you use?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question13__c}" label="What potential value can you bring to this customer?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question14__c}" label="Who else is on this call and what is their role?"/></p>
            <p><apex:inputField value="{!Precall_Plan_2__c.Question15__c}" label="In 30 words or less, define the account strategy; include necessary resources to support."/></p>
        </apex:pageBlockSection>

I'm not sure why it doesnt work for these fields only. Can someone help me? Thanks
I've only been able to get 72% code coverage for my apex class. I'm new to apex development. Can someone help me please?

Here is my class:

public class PcPContactInfo {
    public Precall_Plan_2__c c{get; set;}
   
    public PcPContactInfo(ApexPages.StandardController controller)
        {
             c = (Precall_Plan_2__c)controller.getRecord();
        }
   
    public pagereference logout()
        {  
             pagereference p1=new pagereference('/apex/Precall_Plan_Detail_clone?id='+c.get('Id')+'&clone=1');
             return p1;
        }
   
   
    public PageReference dosave()
        {   
             try
            {
                 if(ApexPages.currentPage().getParameters().get('clone')=='1'||ApexPages.currentPage().getParameters().get('save_new')=='1')
                    {
                        c.id=null;                   
                        insert c;
                    }
               
                 else
                        update c;
            }
       
                 catch(exception e) { ApexPages.addMessages(e); return null;  } 

                 return new Pagereference('/' + c.get('Id'));
        }
    
    public void doSomething()
        {
           contact TEST = [SELECT account.name,MailingCountry,Mailingcity,Title,Phone,MailingStreet,MailingState,MailingPostalCode, accountid FROM contact where id = :c.Contact_name2__c];
           // c.Company_Name__c= TEST.account.name;
           c.Contact_mailing_city__c=TEST.Mailingcity;
           c.Contact_s_Title__c=TEST.Title;
           c.Contact_s_Telephone_Number__c=TEST.Phone;
           c.Contact_Street__c=TEST.MailingStreet;
           c.Contact_State__c=TEST.MailingState;
           c.Contact_Zip__c=TEST.MailingPostalCode;
     
        }
}

And here is my Test Class:

@isTest
private class test_PcPContactInfo
{

    static testMethod void go_PcPContactInfo() 
    {
   
        account a = new account(name='ESAB');
        insert a;
        contact c = new contact (lastname= 'test2',accountid=a.id,email='abc@gmail.com');
        insert c;
       
        Precall_Plan_2__c  cw=new Precall_Plan_2__c(name='test',Contact_name2__c=c.id,Company_Name__c=a.id);
        insert cw;
       
        ApexPages.StandardController controller = new ApexPages.StandardController(cw);
        PcPContactInfo stdController = new PcPContactInfo(controller);
        //account a = [SELECT name,id FROM account limit 1];
       
        //contact TEST = [SELECT id, accountid,email FROM contact where id = :cw.contact__c];
        //cw.Email__c = TEST.email;
        //update cw;
       
        stdController.doSomething();
        stdController.dosave();
       
       
    }
}
Hello everyone,

I created a VF form for my org, which i created a custom object for, and some of my users are getting an error when trying to create a new form from an opportunity related list. If they create it directly from the custom object tab then there isnt any problems. The error is 'Id not specified in an update call'. I have 2 different profiles that use this form and only one of the profiles recieves this error. The other profile has no problem. I will post the code for the form if need be, however it consists of 5 different VF pages, an apex class and the test class to go along with it. I didnt want to post all of the code and confuse anyone if the problem was some salesforce setting or declaritive change that i can make, but i will post the code if necessary. The two profiles have different page layouts for most if not all objects as well as different custom fields, but the custom fields related to the form are identical as are any cross object lookups used by the form. I will post any information or code needed, but like i said earlier, i didnt want to post hundreds of lines of code and confuse anyone. Please advice as soon as possible.

Thanks
How exactly do you comment in VisualForce? // Is for a single line if I'm not mistaken. /* is for more then one line I believe as well. However, I've encountered <-----
also. What does that mean? When it's used, it greys out the code, but the code within still seems to function. Can someone help me with what that means?
I created a validation rule on the opportunity object that limits the Probability % field to certain values. I need to make this rule active for a particular record type. I need help with the syntax in order to do this. Here is the formula:

OR(
AND(
ISPICKVAL(StageName,"Closed Lost"),
Probability <> 0),
AND(
MOD(Probability*100,10)<>0,
!ISPICKVAL(StageName,"Closed Lost"),
!ISPICKVAL(StageName,"Closed Won")
),
AND(
OR(
Probability = 0.5,
Probability = 0,
Probability = 1),
!ISPICKVAL(StageName,"Closed Lost"),
!ISPICKVAL(StageName,"Closed Won")
),
AND(
ISPICKVAL(StageName,"Closed Won"),
Probability <> 1)
)