• Redtag
  • NEWBIE
  • 25 Points
  • Member since 2007

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 22
    Replies
How can I hide the new button on the case tab from certain users, or from a custom tab?  I have users who can create new workorders (custom object) through a custom button on the cases page, but they should not do so directly from the workorders page. 
  • April 03, 2009
  • Like
  • 0

I've modified the Web to Case form on Developerforce Quickstarts Creating Custom Web-To-Case Forms

What I've done is redirect the user to a thankyou page upon pressing the submit button.  But what I really need is for the Casenumber to be shown on the thankyou page. At the moment the casenumber does not show. I have checked the permissions and they are fine. The problem I have is how to pass the value from the first page to the thankyou page. Any help greatly appreciated.

 

Here is my page:

 

<apex:page controller="SubmitCaseController" title="Case thank you page" 
           showHeader="false" standardStylesheets="true">
  <apex:composition template="{!$Site.Template}">
  <apex:insert name="header">
    <c:SiteHeader />
    <hr/>
  </apex:insert>
    <apex:define name="body"> 
        <br/>
        <center>
        <apex:outputText value="Your information is saved.  Thank you for your interest!"/>
        <br/>
        <apex:outputText value="Your Case Reference Number is: {!c.casenumber}"/>
        </center>
        <br/>
        <br/>
    </apex:define>
  </apex:composition>
</apex:page>

 And here is the controller:

 

public class SubmitCaseController {
    
    public Case c { get; set; }
    public SubmitCaseController() {
        c = new Case();
    }
    public string casenum;
       
    
    // This method cancels the wizard, and returns the user to the  
    // Submit case page
    
    public PageReference cancel() {
			PageReference SubmitCasePage = new PageReference('/apex/SubmitCase');
			SubmitCasePage.setRedirect(true);
			return SubmitCasePage; 
    }
    
    public PageReference SubmitCase() {
        List<Contact> cons = [SELECT Id, email, AccountId, CreatedDate FROM Contact WHERE email = :c.SuppliedEmail order by CreatedDate desc];
        if (cons.size() < 1) {
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.WARNING, 'Please enter an email that matches our records');
            ApexPages.addMessage(msg);
            return null;
        } else {
            try {
                c.ContactId = cons.get(0).Id;
                c.AccountId = cons.get(0).AccountId;
                
                            
                // Specify DML options to ensure the assignment rules are executed
                Database.DMLOptions dmlOpts = new Database.DMLOptions();
                dmlOpts.assignmentRuleHeader.useDefaultRule = true;
                c.setOptions(dmlOpts);

                // Insert the case
                INSERT c;
                
                casenum = c.CaseNumber;             
                
                return new PageReference('/casethankyou');
                } catch (Exception e) {
                ApexPages.addMessages(e);
                return null;
            }
        }
    }
}

 

And here is the SubmitCase page:

 

<apex:page controller="SubmitCaseController" title="Submit Case" showHeader="false"
           standardStylesheets="true">
<script>
  function confirmCancel() {
      var isCancel = confirm("Are you sure you wish to cancel?");
      if (isCancel) return true;
  
     return false;
  }  
  </script>
    
    <apex:composition template="{!$Site.Template}">
    <apex:insert name="header">
    <c:SiteHeader />
    <hr/>
    </apex:insert>
    <apex:define name="body">
    <apex:form >
        <apex:messages id="error"
                   styleClass="errorMsg"
                   layout="table"
                   style="margin-top:1em;"/>
      <apex:pageBlock title="" mode="edit">
        <apex:pageBlockButtons >
           <apex:commandButton value="Submit"
                               action="{!SubmitCase}"/>
           <apex:commandButton action="{!cancel}" value="Cancel" onclick="return confirmCancel()" immediate="true"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="New Enquiry"
                               collapsible="false"
                               columns="1">
        <table>
            <tr>
                <th>Customer Name:</th>
                <td>
                <apex:inputText required="true" value="{!c.SuppliedName}"/></td>
            </tr>
            <tr>
                <th>Customer Email:</th>
                <td><apex:inputText required="true" value="{!c.SuppliedEmail}"/></td>
            </tr>
            <tr>
                <th>Business Name:</th>
                <td><apex:inputText required="true" value="{!c.SuppliedCompany}"/></td>
            </tr>
            <tr>
                <th>Subject:</th>
                <td><apex:inputText required="true" value="{!c.Subject}"/></td>
            </tr>
            <tr>
                <th>Your Problem:</th>
                <td><apex:inputTextArea required="true" rows="5" value="{!c.Description}"/></td>
            </tr>
         </table>
        
        </apex:pageBlockSection>
     </apex:pageBlock>
   </apex:form>
  </apex:define> 
 </apex:composition>
</apex:page>

 

 

Hi,

 

I'm looking for an independent programmer to help with a small customisation job. My estimate is for 2-3 days work. The aim is to create an order entry page on the Salesforce contact page. The purpose of this page is to make the data entry easier for the users.

 

What we have at the moment are two custom objects:  Sales Order object (master) and an Order Item object (detail).

 

By clicking on a "New Order" Button the user creates an order header. After filling out the required data, most of which comes pre-filled out from the Contact page the user saves and then clicks on an "Add Item" button and adds items to the order. On each item record the user looks up the product page and returns data from the product page.

 

Certain business rules make the users do more data entry that could be automated. For example, each Order Item record can only have the same Order Type as the Sales Order, so if a user needs to put in different Order Types they have to create multiple Sales Orders and attach items. Likewise, different purchase order numbers must be on different Sales Orders.

 

My client finds this too labour intensive. I'd like someone who knows Apex and Visualforce and is a capable communicator to design and code a page that allows Sales Orders and Items to be added on the one page. 

 

I can send a spec to interested parties. This needs to be done preferably in the next two weeks and I'd need a firm quote after you read the spec. I'm based in Australia which is GMT +11 so please take this into consideration as I'm sure neither you nor I want 3am phone meetings.

 

Reply to this post and I'll contact you if I'm interested.

  • January 28, 2009
  • Like
  • 0
I'm new to Apex and I've looked at the online references but need help for my first code. What I've got is a lookup field, Master_Account_Name__c on the Account object that looks up a custom object MasterAccount__c. Each object has an external ID field: Master_Account_ID__c on the Account Object and Account_ID__c on the Master Account Object.
 
What I want to do with a trigger (after insert, after update) is to populate the lookup field, Master_Account_Name__c on the Account Object with the correct id from the Master Account object to create the relationship (where the external ID fields are the same).
 
This will be used in nightly batch updates after upserts occur to each of the objects with master accounts being upserted first. Any help with this greatly appreciated.
 


Message Edited by Redtag on 07-13-2008 05:00 AM

I've modified the Web to Case form on Developerforce Quickstarts Creating Custom Web-To-Case Forms

What I've done is redirect the user to a thankyou page upon pressing the submit button.  But what I really need is for the Casenumber to be shown on the thankyou page. At the moment the casenumber does not show. I have checked the permissions and they are fine. The problem I have is how to pass the value from the first page to the thankyou page. Any help greatly appreciated.

 

Here is my page:

 

<apex:page controller="SubmitCaseController" title="Case thank you page" 
           showHeader="false" standardStylesheets="true">
  <apex:composition template="{!$Site.Template}">
  <apex:insert name="header">
    <c:SiteHeader />
    <hr/>
  </apex:insert>
    <apex:define name="body"> 
        <br/>
        <center>
        <apex:outputText value="Your information is saved.  Thank you for your interest!"/>
        <br/>
        <apex:outputText value="Your Case Reference Number is: {!c.casenumber}"/>
        </center>
        <br/>
        <br/>
    </apex:define>
  </apex:composition>
</apex:page>

 And here is the controller:

 

public class SubmitCaseController {
    
    public Case c { get; set; }
    public SubmitCaseController() {
        c = new Case();
    }
    public string casenum;
       
    
    // This method cancels the wizard, and returns the user to the  
    // Submit case page
    
    public PageReference cancel() {
			PageReference SubmitCasePage = new PageReference('/apex/SubmitCase');
			SubmitCasePage.setRedirect(true);
			return SubmitCasePage; 
    }
    
    public PageReference SubmitCase() {
        List<Contact> cons = [SELECT Id, email, AccountId, CreatedDate FROM Contact WHERE email = :c.SuppliedEmail order by CreatedDate desc];
        if (cons.size() < 1) {
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.WARNING, 'Please enter an email that matches our records');
            ApexPages.addMessage(msg);
            return null;
        } else {
            try {
                c.ContactId = cons.get(0).Id;
                c.AccountId = cons.get(0).AccountId;
                
                            
                // Specify DML options to ensure the assignment rules are executed
                Database.DMLOptions dmlOpts = new Database.DMLOptions();
                dmlOpts.assignmentRuleHeader.useDefaultRule = true;
                c.setOptions(dmlOpts);

                // Insert the case
                INSERT c;
                
                casenum = c.CaseNumber;             
                
                return new PageReference('/casethankyou');
                } catch (Exception e) {
                ApexPages.addMessages(e);
                return null;
            }
        }
    }
}

 

And here is the SubmitCase page:

 

<apex:page controller="SubmitCaseController" title="Submit Case" showHeader="false"
           standardStylesheets="true">
<script>
  function confirmCancel() {
      var isCancel = confirm("Are you sure you wish to cancel?");
      if (isCancel) return true;
  
     return false;
  }  
  </script>
    
    <apex:composition template="{!$Site.Template}">
    <apex:insert name="header">
    <c:SiteHeader />
    <hr/>
    </apex:insert>
    <apex:define name="body">
    <apex:form >
        <apex:messages id="error"
                   styleClass="errorMsg"
                   layout="table"
                   style="margin-top:1em;"/>
      <apex:pageBlock title="" mode="edit">
        <apex:pageBlockButtons >
           <apex:commandButton value="Submit"
                               action="{!SubmitCase}"/>
           <apex:commandButton action="{!cancel}" value="Cancel" onclick="return confirmCancel()" immediate="true"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="New Enquiry"
                               collapsible="false"
                               columns="1">
        <table>
            <tr>
                <th>Customer Name:</th>
                <td>
                <apex:inputText required="true" value="{!c.SuppliedName}"/></td>
            </tr>
            <tr>
                <th>Customer Email:</th>
                <td><apex:inputText required="true" value="{!c.SuppliedEmail}"/></td>
            </tr>
            <tr>
                <th>Business Name:</th>
                <td><apex:inputText required="true" value="{!c.SuppliedCompany}"/></td>
            </tr>
            <tr>
                <th>Subject:</th>
                <td><apex:inputText required="true" value="{!c.Subject}"/></td>
            </tr>
            <tr>
                <th>Your Problem:</th>
                <td><apex:inputTextArea required="true" rows="5" value="{!c.Description}"/></td>
            </tr>
         </table>
        
        </apex:pageBlockSection>
     </apex:pageBlock>
   </apex:form>
  </apex:define> 
 </apex:composition>
</apex:page>

 

 

I've modified the Web to Case form on Developerforce Quickstarts Creating Custom Web-To-Case Forms

What I've done is redirect the user to a thankyou page upon pressing the submit button.  But what I really need is for the Casenumber to be shown on the thankyou page. At the moment the casenumber does not show. I have checked the permissions and they are fine. The problem I have is how to pass the value from the first page to the thankyou page. Any help greatly appreciated.

 

Here is my page:

 

<apex:page controller="SubmitCaseController" title="Case thank you page" 
           showHeader="false" standardStylesheets="true">
  <apex:composition template="{!$Site.Template}">
  <apex:insert name="header">
    <c:SiteHeader />
    <hr/>
  </apex:insert>
    <apex:define name="body"> 
        <br/>
        <center>
        <apex:outputText value="Your information is saved.  Thank you for your interest!"/>
        <br/>
        <apex:outputText value="Your Case Reference Number is: {!c.casenumber}"/>
        </center>
        <br/>
        <br/>
    </apex:define>
  </apex:composition>
</apex:page>

 And here is the controller:

 

public class SubmitCaseController {
    
    public Case c { get; set; }
    public SubmitCaseController() {
        c = new Case();
    }
    public string casenum;
       
    
    // This method cancels the wizard, and returns the user to the  
    // Submit case page
    
    public PageReference cancel() {
			PageReference SubmitCasePage = new PageReference('/apex/SubmitCase');
			SubmitCasePage.setRedirect(true);
			return SubmitCasePage; 
    }
    
    public PageReference SubmitCase() {
        List<Contact> cons = [SELECT Id, email, AccountId, CreatedDate FROM Contact WHERE email = :c.SuppliedEmail order by CreatedDate desc];
        if (cons.size() < 1) {
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.WARNING, 'Please enter an email that matches our records');
            ApexPages.addMessage(msg);
            return null;
        } else {
            try {
                c.ContactId = cons.get(0).Id;
                c.AccountId = cons.get(0).AccountId;
                
                            
                // Specify DML options to ensure the assignment rules are executed
                Database.DMLOptions dmlOpts = new Database.DMLOptions();
                dmlOpts.assignmentRuleHeader.useDefaultRule = true;
                c.setOptions(dmlOpts);

                // Insert the case
                INSERT c;
                
                casenum = c.CaseNumber;             
                
                return new PageReference('/casethankyou');
                } catch (Exception e) {
                ApexPages.addMessages(e);
                return null;
            }
        }
    }
}

 

And here is the SubmitCase page:

 

<apex:page controller="SubmitCaseController" title="Submit Case" showHeader="false"
           standardStylesheets="true">
<script>
  function confirmCancel() {
      var isCancel = confirm("Are you sure you wish to cancel?");
      if (isCancel) return true;
  
     return false;
  }  
  </script>
    
    <apex:composition template="{!$Site.Template}">
    <apex:insert name="header">
    <c:SiteHeader />
    <hr/>
    </apex:insert>
    <apex:define name="body">
    <apex:form >
        <apex:messages id="error"
                   styleClass="errorMsg"
                   layout="table"
                   style="margin-top:1em;"/>
      <apex:pageBlock title="" mode="edit">
        <apex:pageBlockButtons >
           <apex:commandButton value="Submit"
                               action="{!SubmitCase}"/>
           <apex:commandButton action="{!cancel}" value="Cancel" onclick="return confirmCancel()" immediate="true"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="New Enquiry"
                               collapsible="false"
                               columns="1">
        <table>
            <tr>
                <th>Customer Name:</th>
                <td>
                <apex:inputText required="true" value="{!c.SuppliedName}"/></td>
            </tr>
            <tr>
                <th>Customer Email:</th>
                <td><apex:inputText required="true" value="{!c.SuppliedEmail}"/></td>
            </tr>
            <tr>
                <th>Business Name:</th>
                <td><apex:inputText required="true" value="{!c.SuppliedCompany}"/></td>
            </tr>
            <tr>
                <th>Subject:</th>
                <td><apex:inputText required="true" value="{!c.Subject}"/></td>
            </tr>
            <tr>
                <th>Your Problem:</th>
                <td><apex:inputTextArea required="true" rows="5" value="{!c.Description}"/></td>
            </tr>
         </table>
        
        </apex:pageBlockSection>
     </apex:pageBlock>
   </apex:form>
  </apex:define> 
 </apex:composition>
</apex:page>

 

 

How can I hide the new button on the case tab from certain users, or from a custom tab?  I have users who can create new workorders (custom object) through a custom button on the cases page, but they should not do so directly from the workorders page. 
  • April 03, 2009
  • Like
  • 0
Hi

Is it possible to write a formula that essentially breaks the shipping address down into the individual lines?

We have an external system that needs to receive the address fields for a child object to an Account in three separate fields.

I figure if I can identify a new line character, then this should be pretty straight forward, but I can't figure out how to do this.
Any ideas?

thanks
Nick
I'm new to Apex and I've looked at the online references but need help for my first code. What I've got is a lookup field, Master_Account_Name__c on the Account object that looks up a custom object MasterAccount__c. Each object has an external ID field: Master_Account_ID__c on the Account Object and Account_ID__c on the Master Account Object.
 
What I want to do with a trigger (after insert, after update) is to populate the lookup field, Master_Account_Name__c on the Account Object with the correct id from the Master Account object to create the relationship (where the external ID fields are the same).
 
This will be used in nightly batch updates after upserts occur to each of the objects with master accounts being upserted first. Any help with this greatly appreciated.
 


Message Edited by Redtag on 07-13-2008 05:00 AM
I have read through the Apex language guide and this post discussing the upsert feature, but I'm still confused as to whether I can do what I want.

I have a sign-up process that I'm integrating with Salesforce. First in the process a survey is given. I will store this a custom object. Later in the process the Account is created and I want to link it to the Survey, but due to some timing issues, I can't guarantee that the Survey object will actually get created before I try to create the Account. I'm guessing most of the time it will, but I can't be sure.

What I want to do is create the Survey object and give it an ID that I create. This is set as an External ID. Then I have an External ID in the Account object. When I create the Account, I wanted to do it with an upsert command to link together the Survey and the Account by the External ID. I tried this, but I the relationship never gets made.

I set my objects up like this:

Survey
    Text SurveyID (External ID)

Account
    Text SurveyID (External ID)
    Related Field: Survey

As a test I created a Survey and set the SurveyID to '1234' then I did this upsert:

Account a;
// set up the account
a.SurveyID = '1234';
upsert a Survey__c.SurveyID;

I was hoping that would fill in the Survey related field in the Account.

I'm obviously doing something wrong. Is what I'm describing even possible? The blog post seemed to indicate it was.

Thanks for any help you can give.

Peter
Code:
trigger getDiscountsonOpportunities on Opportunity (after insert, after update){
for (opportunity op : [Select Bureau__r.Discount__c From Opportunity where id in : trigger.new ]){

op.Discount__c= op.Bureau__r.Discount__c;
op.Auth_Inv_Bureau__c = 15 ;
update op ;
}
}

Hi,
I'm a newbie on Apex code and I really need some help to make an update after insert/update

I want to make this once I have save the record :
Opportunity.Discount__c  = Opportunity.Bureau__r.discount__c;

I don't have any compile error but I've got this when I try to test it :

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger getDiscountsonOpportunities caused an unexpected exception, contact your administrator: getDiscountsonOpportunities: maximum trigger depth exceeded Opportunity trigger event bulk AfterUpdate for 006S00000025Mar Opportunity trigger event bulk AfterUpdate for 006S00000025Mar Opportunity trigger event bulk AfterUpdate for 006S00000025Mar Opportunity trigger event bulk AfterUpdate for 006S00000025Mar Opportunity trigger event bulk AfterUpdate for 006S00000025Mar Opportunity trigger event bulk AfterUpdate for 006S00000025Mar Opportunity trigger event bulk AfterUpdate .....

Can I have some examples of this quind of functionnality Only to update some fields in the same object ...
Thank you really really very much for your help !!!


Message Edited by Mig on 02-05-2008 08:37 AM
  • February 05, 2008
  • Like
  • 0
Hey,

I've got an address field that I'd like to verify that the length of any *line* is less than 30 characters (so it will integrate with our back-office systems) -- is there any way to do that?  We don't (yet) have Apex code.

I thought trying to find a BR() might work, but that didn't.

Thanks,
Michael
I am a professional Edition user and am struggling with this issue:

I have an inventory of properties that I can assign as properties of interest to an buyer (opportunity).  Once I sell a property to a buyer, I flag it as sold and want to remove it from the picklist as a possible property of interest for future buyers.

Is there a way to do the above?
  • March 25, 2007
  • Like
  • 0
Hello

We are looking for a company to outsource SalesForce integration with.  We have two projects that we'd like help with.

The first is to tie existing customer forms into a SalesForce database AND keep the information live so that we can continue to use it on a site.  Basically, posting one form to two different sites via PHP and/or ASP or JavaScript.  It sounds simple enough, but we've had lots of setbacks with that.

The second is to manage a database of PR contacts and be able to filter and sort them based on campaign, client, if they've been called for a certain campaign, media publication, location and many other items.

If either, or both of these, interest you or your company, please send me a message by going here and then clicking 'Send this user a private message' or post below your info below.  :smileyhappy:

Thanks
Such as template creation and more importantly the self service portal so it looks and feels like our site. Any 3rd parties out there? I googled to no avail so I am crossing my fingers! :smileyhappy:
  • March 06, 2007
  • Like
  • 0
How do you pass values of a multi-select pick list in a basic S-Control?  Here's my S-Contol:

/a0A/e?CF00N60000001Uy6X={!SessionTEST__c.Client__c}&CF00N60000001UxIh={!SessionTEST__c.Opportunity__c}&00N60000001Uxyd="1"&00N60000001UxyY={!SessionTEST__c.Pose__c}

The code in red is refferences a multi-select picklist, and the values are displayed in the resulting URL:

https://na4.salesforce.com/a0A/e?CF00N60000001Uy6X=Blue+Mountain+Middle+School&CF00N60000001UxIh=Blue+Mountain+Middle+School+Test+Fall+Portaits&00N60000001Uxyd=1&00N60000001UxyY=Puzzle%3BFamily

However, the values "Puzzle" and "Family" are not written to the field.

What am I doing wrong?
Contract work available for importing data.  Entails bringing data from ten different .csv file configurations into each SF account.  Custom object integration is a part of this project.  Project estimated at one days work.  Project completion target date is 2/28/07.  Prefer to deal with individuals instead of corporations.