• jmick
  • NEWBIE
  • 0 Points
  • Member since 2011

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

Hi Everyone

 

I have a site where a user can create a new record and the goal is that this user can select their first approver from a lookup field.  I have the first step in the approval process set to "Let the submitter choose the approver manually" and I have already created a trigger that automatically submits a record for approval when created. I am attempting to use the setNextApproverIds method to pass in the approver from the form but I'm not sure how to get the selected users ID. Any help is appreciated.

 

 

trigger requestSubmit on Request__c (after insert) {


for (Request__c r : trigger.new) {

Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(r.id);


app.setNextApproverIds(.profileID);


Approval.ProcessResult result = Approval.process(app);

}

}

  • May 26, 2011
  • Like
  • 0

Hi Everyone,

 

I'm new to working with Apex code and I have looked around for the answer to this but everyone seems to have a slightly different situation. I have the fields for a custom object displayed on a site that I want public users to be able to use to create new records. However, when I submit a new record it takes me to a logon page because it is attempting to take me to the new record. Instead I want it to take users to a page that says they successfully created a record. I have created a controller extension to override the save action but something is wrong with it as it does not even work on the VF page, I get the error "System.NullPointerException: Attempt to de-reference a null object" "Class.MyPageController.save: line 8, column 8 External entry point" , where line 8 is the "Insert request" line. I have been working from information on the two sites below. Any help would be greatly appreciated.

 

http://blog.jeffdouglas.com/2008/11/14/redirecting-users-to-different-visualforce-pages/

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_pages_pagereference.htm

 

Site Code

<apex:page sidebar="false" showHeader="false" standardController="Request__c" extensions="MyPageController">   
<apex:form >
    <apex:pageBlock >
    <apex:pageMessages />
    <apex:pageBlockSection >
    <apex:detail />
        <apex:inputField value="{! Request__c.First_Name__c}" />
        <apex:inputField value="{! Request__c.Last_Name__c}"/>
        <apex:inputField value="{! Request__c.Email_Address__c}"/>
        <apex:inputField value="{! Request__c.Cost_Center__c}"/>
        <apex:inputField value="{! Request__c.Department__c}"/>
        <apex:inputField value="{! Request__c.Director_s_Email__c}"/>
        <apex:inputField value="{! Request__c.Director_s_First_Name__c}"/>
        <apex:inputField value="{! Request__c.Director_s_Last_Name__c}"/>
        <apex:inputField value="{! Request__c.Mailstop__c}"/>
        <apex:inputField value="{! Request__c.Phone_Number__c}"/>

    </apex:pageBlockSection>
    </apex:PageBlock>       
        <apex:commandButton action="{! save}" value="Save"/>
       
    </apex:form>
</apex:page>

 

Controller Extension

public class MyPageController {
Request__c request;
private ApexPages.StandardController controller;
public MyPageController(ApexPages.StandardController controller) {
this.controller = controller;
}
public PageReference save() {
insert request;
PageReference requestPage = Page.Congratulations;
requestPage.setRedirect(true);
return requestPage;

}

  • April 12, 2011
  • Like
  • 0

Hi Everyone,

 

I'm new to working with Apex code and I have looked around for the answer to this but everyone seems to have a slightly different situation. I have the fields for a custom object displayed on a site that I want public users to be able to use to create new records. However, when I submit a new record it takes me to a logon page because it is attempting to take me to the new record. Instead I want it to take users to a page that says they successfully created a record. I have created a controller extension to override the save action but something is wrong with it as it does not even work on the VF page, I get the error "System.NullPointerException: Attempt to de-reference a null object" "Class.MyPageController.save: line 8, column 8 External entry point" , where line 8 is the "Insert request" line. I have been working from information on the two sites below. Any help would be greatly appreciated.

 

http://blog.jeffdouglas.com/2008/11/14/redirecting-users-to-different-visualforce-pages/

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_pages_pagereference.htm

 

Site Code

<apex:page sidebar="false" showHeader="false" standardController="Request__c" extensions="MyPageController">   
<apex:form >
    <apex:pageBlock >
    <apex:pageMessages />
    <apex:pageBlockSection >
    <apex:detail />
        <apex:inputField value="{! Request__c.First_Name__c}" />
        <apex:inputField value="{! Request__c.Last_Name__c}"/>
        <apex:inputField value="{! Request__c.Email_Address__c}"/>
        <apex:inputField value="{! Request__c.Cost_Center__c}"/>
        <apex:inputField value="{! Request__c.Department__c}"/>
        <apex:inputField value="{! Request__c.Director_s_Email__c}"/>
        <apex:inputField value="{! Request__c.Director_s_First_Name__c}"/>
        <apex:inputField value="{! Request__c.Director_s_Last_Name__c}"/>
        <apex:inputField value="{! Request__c.Mailstop__c}"/>
        <apex:inputField value="{! Request__c.Phone_Number__c}"/>

    </apex:pageBlockSection>
    </apex:PageBlock>       
        <apex:commandButton action="{! save}" value="Save"/>
       
    </apex:form>
</apex:page>

 

Controller Extension

public class MyPageController {
Request__c request;
private ApexPages.StandardController controller;
public MyPageController(ApexPages.StandardController controller) {
this.controller = controller;
}
public PageReference save() {
insert request;
PageReference requestPage = Page.Congratulations;
requestPage.setRedirect(true);
return requestPage;

}

  • April 12, 2011
  • Like
  • 0