• Markey1
  • NEWBIE
  • 0 Points
  • Member since 2010

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

Hi, I'm fairly new to Triggers and am hoping someone can give me a bit of direction.

 

I want a custom field "Record_Mode__c" on Child Object B to be updated to value "Edit" when Parent Object A's custom field "Status__c" is updated to "Open". Basically, any time the parent record's status changes, I want the child record's Record Mode field to be updated accordingly.

 

The Record Mode change will then drive workflow that will flip record types and page layouts. I prefer to use out of the box solutions, but I cannot use cross object workflows as there is no master detail relationship between Parent Object A and Child Object B.

 

Any assistance with code or alternate solutions are much appreciated! 

Sites Explanation:

We have a sites project which is public. The public access settings allow our end-users to login via a guest license and enter their information (no authentication).

 

Sites URL Setup:

Default URL: http://something.force.com/xyzenrollment

Secure URL: https://something.secure.force.com/xyzenrollment

Custom Web Address: http://enroll.something.com

 

The Issue:

The Site is not secure. All information entered via the Site by our end-users needs to be secure (i.e. currently http, needs to be https).

 

Question:

How do I point the users to the Secure URL vs. the Default URL while still keeping the Custom Web Address masking? I changed the Administration Setup > Security Controls > Session Settings > Require secure connections (HTTPS) to checked, but this does not seem to do the trick.

How do you test messages? I'm getting no coverage for the lines highlighted in red. Any help with how to write a test condition for the below code is much appreciated.

 

public PageReference save() {
  try {
    if(skTest.Submission_Type__c == 'New Submission' && (attachment.name == '' || attachment.description == '' || attachment.body == null)) {
    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'All upload fields are required.'));
    return null;
  }

 

Anyone know how to test Catch blocks. I've looked around for creating Catch test conditions but have been unsuccessful so far.

 

Code Snippet:

            insert skEnroll;
        } 
        catch (DMLException e) {            
            ApexPages.addMessages(e);            
            return null;
        }
        return page.aeskenrollconfirm; 
    }        
}

 

This code was created by another developer and I need to achieve higher coverage to deploy an unrelated project. My test class (psuControllerTest) is receiving a test failure. It looks like it does not like the last part of the code where the "Status" is set. Any help with correcting the test code is much appreciated.

 

Method Name:

psuControllerTest.testPsuIdRequest

 

Message:

System.DmlException: Update failed. First exception on row 0 with id a0HP0000001ivPOMAY; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

 

Stack Trace:

Class.psuIdRequestController.setStatus: line 88, column 13 Class.psuIdRequestController.Approve: line 45, column 9 Class.psuControllerTest.testPsuIdRequest: line 176, column 9 External entry point

 

 

Test class snippet:

     static testMethod void hierarchyControllerTest() {
        Id profileid = [Select id from Profile where name = 'Customer Portal Manager Custom'].id;
        Account account = new Account(Name = 'Test Account'); 
        
        insert account; 
        Contact businessContact = new Contact(AccountID = account.id, FirstName = 'Test', LastName = 'BusinessUser', email = 'bustest@test.com' ); 
        Contact technicalContact = new Contact(AccountID = account.id, FirstName = 'Test', LastName = 'TechnicalUser', email = 'tectest@test.com' ); 
        Contact financeContact = new Contact(AccountID = account.id, FirstName = 'Test', LastName = 'FinanceUser', email = 'fintest@test.com' );
        Contact treasuryContact = new Contact(AccountID = account.id, FirstName = 'Test', LastName = 'TreasuryUser', email = 'tretest@test.com' ); 
        Contact[] contacts = new Contact[]{businessContact,technicalContact,financeContact,treasuryContact};
        insert contacts;

        User BusinessUser = new User(email='business@test.com', 
                                     contactid = businessContact.id, 
                                     profileid = profileid, 
                                     UserName='business@test.com', 
                                     alias='bususer', CommunityNickName='bususer',
                                     TimeZoneSidKey='America/New_York', 
                                     LocaleSidKey='en_US', 
                                     EmailEncodingKey='ISO-8859-1',
                                     LanguageLocaleKey='en_US', 
                                     FirstName = 'Test', 
                                     LastName = 'BusinessUser');
        User TechnicalUser = new User(email='technical@test.com', 
                                     contactid = technicalContact.id, 
                                     profileid = profileid, 
                                     UserName='technical@test.com', 
                                     alias='tecuser', CommunityNickName='tecuser',
                                     TimeZoneSidKey='America/New_York', 
                                     LocaleSidKey='en_US', 
                                     EmailEncodingKey='ISO-8859-1',
                                     LanguageLocaleKey='en_US', 
                                     FirstName = 'Test', 
                                     LastName = 'TechnicalUser');
        User FinanceUser = new User(email='finance@test.com', 
                                     contactid = financeContact.id, 
                                     profileid = profileid, 
                                     UserName='finance@test.com', 
                                     alias='finuser', CommunityNickName='finuser',
                                     TimeZoneSidKey='America/New_York', 
                                     LocaleSidKey='en_US', 
                                     EmailEncodingKey='ISO-8859-1',
                                     LanguageLocaleKey='en_US', 
                                     FirstName = 'Test', 
                                     LastName = 'FinanceUser');
        User InvalidUser = new User(email='treasury@test.com', 
                                     contactid = treasuryContact.id, 
                                     profileid = profileid, 
                                     UserName='treasury@test.com', 
                                     alias='treuser', CommunityNickName='treuser',
                                     TimeZoneSidKey='America/New_York', 
                                     LocaleSidKey='en_US', 
                                     EmailEncodingKey='ISO-8859-1',
                                     LanguageLocaleKey='en_US', 
                                     FirstName = 'Test', 
                                     LastName = 'TreasuryUser');
        User[] users = new User[]{businessUser,technicalUser,financeUser,InvalidUser};
        insert users;    
        //Create a Request
        Participant_ID_Request__c request = new Participant_ID_Request__c(
        Name='New Hierarchy Test',
        Business_Approver__c = BusinessUser.ContactId, 
        Techincal_Approver__c  = TechnicalUser.ContactId, 
        Finance_Approver__c = FinanceUser.ContactId,  
        Treasury_Hierarchy_Approver__c = InvalidUser.ContactId
        );
        insert request;
        
        //Create a Hierarchy
        Participant_Hierarchy__c hierarchy = new Participant_Hierarchy__c(
        Name='Hierarchy Test',
        Business_Approver__c = BusinessUser.ContactId, 
        Technical_Approver__c  = TechnicalUser.ContactId,  
        Finance_Approver__c = FinanceUser.ContactId,
        Treasury_Hierarchy_Approver__c = InvalidUser.ContactId,
        Business_Approval__c = 'Pending', 
        Technical_Approval__c = 'Pending', 
        Finance_Approval__c = 'Pending',
        Treasury_Approval__c = 'Pending',
        Treasury_Comments__c = 'Test',
        Business_Comments__c = 'Test', 
        Technical_Comments__c= 'Test', 
        Finance_Comments__c= 'Test',
        New_Participant__c = request.Id
        );
        insert hierarchy;
    
                
        // Test class Complete_Requirements_Status methods 
        ApexPages.standardController hierarchyCntl = new ApexPages.standardController(hierarchy);
        Test.setCurrentPageReference(new PageReference('Page.hierarchyreview')); 
        System.currentPageReference().getParameters().put('requestid', request.Id);
        psuHierarchyController reviewController = new psuHierarchyController(hierarchyCntl);
        Participant_Hierarchy__c objHierarchy = reviewController.gethierarchy();
            
         //Test as Portal User
        String strStatus; 
        
        System.RunAs(BusinessUser)
        {
            String strApprover = reviewController.getApprover();
            String strComment = reviewController.getComment();
            reviewController.setComment(strComment);
            strStatus = reviewController.getStatus();
        } //end RunAs

        System.RunAs(TechnicalUser)
        {
            String strApprover = reviewController.getApprover();
            String strComment = reviewController.getComment();
            reviewController.setComment(strComment);
            strStatus = reviewController.getStatus();
        } //end RunAs
        System.RunAs(FinanceUser)
        {
            String strApprover = reviewController.getApprover();
            String strComment = reviewController.getComment();
            reviewController.setComment(strComment);
            strStatus = reviewController.getStatus();
        } //end RunAs
        System.RunAs(InvalidUser)
        {
            String strApprover = reviewController.getApprover();
            String strComment = reviewController.getComment();
            reviewController.setComment(strComment);
            strStatus = reviewController.getStatus();
        } //end RunAs

        reviewController.approve();
            
        reviewController.reject();

        reviewController.setStatus(strStatus);
        
        String hn = reviewController.getHierarchyName();
        String approver = reviewController.getApprover();
        Attachment attachment = reviewController.attachment;
        Attachment[] attachments = reviewController.attachments;
        
    }

 

Hello,

 

How do I set the Record Type ID (value) based off which Visualforce Page a user is currently viewing?

 

This is a Sites project. When a user is on the "enrollment" page and submits their form, I want the custom controller extension (or ?) to reference the Page ID to set the Record Type to "Enrollment" (i.e. Record Type Name = Enrollment, Record Type ID = 012Q00000004So4).

 

My Code (could be completely off, mashed a few things together from other forums):

 

public rtt() {

if(System.currentPageReference().getParameters().get('id')= "enrollment") {
  RecordType.ID = "012Q00000004So4";
  } 
}

My Error:

 

Error: Compile Error: line 84:60 no viable alternative at character '"' at line 84 column 60

For my Site, I want the user to be able to click, for example, the Enrollment link which will take the user to the Enrollment Page... but, I also want to set the record type based off which link is clicked as well. How do I accomplish this?

 

<apex:component >
  <div id = "menu_container">
    <div id = "menu">
      <ul>
        <li class="menu_header">Some Name
          <ul>
            <li><a href="http://testing.somename.cs3.force.com/enroll">Enrollment</a></li>
            <li><a href="http://testing.somename.cs3.force.com/cert">Certification</a></li>
          </ul>
        </li>                            
      </ul>
    </div>
  </div>
</apex:component>

 

I have two questions that should be pretty simple although I have spent good time trying to find the solution.

 

First: On my site I have a component acting as my sidebar with a set of links. When one of the links is clicked, I want it to dynamically set the record type. For example, if the user clicks the enrollment link, it would take them to the enrollment page, but I also want the record type to be set to "enrollment". Via the UI you can set record type via the URL but I do not know how to accomplish this via Sites.

 

<apex:component >
  <div id = "menu_container">
    <div id = "menu">
      <ul>
        <li class="menu_header">Some Name
          <ul>
            <li><a href="http://testing.somename.cs3.force.com/enroll">Enrollment</a></li>
            <li><a href="http://testing.somename.cs3.force.com/cert">Certification</a></li>
          </ul>
        </li>                            
      </ul>
    </div>
  </div>
</apex:component>

 

Second: I'm sure there is a better way of linking to pages vs. the static example above. I want to avoid scanning through the site if I change the name of a Page. Is there a better way of referencing a Page via a link?

 

Any assistance with code, ideas, and/or examples is much appreciated.

I have a checkbox that when checked, the section which contains a save button should appear using ajax render/rerender. What is wrong with my code? Also, I'm using DIVs to control look and feel... is there a better way to do this using panels etc?

 

Class:

public String test2 {get; set;}

 

Page:

      <div id = "body_row">
        <apex:pageblock id="test">
          <apex:pageBlockSection>
            <apex:pageBlockSectionItem >             
              <apex:inputCheckbox value="{!test2}" />
               <apex:actionsupport event="onclick" rerender="termsandconditions" />
            </apex:pageBlockSectionItem>
          </apex:pageBlockSection>
        </apex:pageblock>
      </div>
      
      <div id = "body_row">
        <apex:pageblock id="termsandconditions">
          <apex:messages />
          <apex:pageblockButtons location="bottom" rendered="{IF({!test2} == true,true,false)}">
            <apex:commandButton action="{!Save}" value="Submit Enrollment" />
          </apex:pageblockButtons>
        </apex:pageblock>
      </div>

 

I am utilizing Sites and my Visualforce pages use a custom object as the standard controller with an extension for additional functionality. 

 

How do I reference fields directly on a Visualforce page? For example, I have two fields that only have id's and no input value.

 

Example:

<apex:pageBlockSectionItem >
  <apex:outputLabel value="US001_VEReq" for="test_us001vereq" />
  <apex:inputTextarea id="test_us001vereq"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
  <apex:outputLabel value="US001_VERes" for="test_us001veres" />
  <apex:inputTextarea id="test_us001veres" />
</apex:pageBlockSectionItem>

 

I want to combine the input from these two Text Area Fields into one field which does have a value, meaning upon save the concatenated (combined) value will be entered (saved) into the database. 

 

Example:

<apex:pageBlockSectionItem >
  <apex:outputLabel value="US001" for="test_us001" />
  <apex:inputTextArea value="{!SK__c.US001__c}" id="test_us001" />
</apex:pageBlockSectionItem>

 

What options do I have to accomplish this task. I have spent 4 days looking at the forums, code examples, etc. and can not figure out how to make this work. Any suggestions, ideas, code examples, and/or links are much appreciated. Please let me know if this is unclear and I will provide more detail.

 

Also, for anyone familiar with MS Access Databases, this would be similar to bound/unbound fields and how to reference those fields within a form via VBA etc.

Hello SF,

 

I am new to building SF Sites and have a few questions on design. I currently have a basic two-column design (header, left menu, body, footer). I am using components to populate the header, footer, and menu so I don't have to re-write the code for each page etc. Rather than creating separate pages, I would like to use components to populate the body as well, which will usually be a form.

 

My question: Using the left menu html links, what is the best way to populate data in the body of the page? I want a user to click a left-nav link and then have the body of the page populate with the correct component (i.e. form) info etc. I have looked everywhere and am unable to locate info on this use-case. I found brief examples of Ajax using "rerender" but I can not figure out how to integrate this with my setup (i.e. which code goes where).

 

My logic/concept may be completely wrong so suggestions, example code, or links to tutorials are much appreciated.