• Glenn at Mvista
  • NEWBIE
  • 115 Points
  • Member since 2008

  • Chatter
    Feed
  • 4
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 30
    Questions
  • 42
    Replies
I want to set up a something like a registration page in our portal (VisualForce page), but given what we "give away" for folks who register, we need to restrict it to certain countries.  Is there anyway to do that in VisualForce?
We are using Service Contracts and Entitlements to manage how our customers get support, and also when they should be allowed to activate a Customer Portal login.  The create/activate works but I am having a problem getting the delete/inactivate part going.  The problem is this, we give access to certain parts of the portal as well as our internal FTP site based on the entitlements to which a Contact is associated.  When that Entitlement expires, I need a mechanism that will check the Contacts related to the entitlement, then check each of those contacts to make sure they do not have an other active entitlements, and if so, deactivate their Customer Portal User Login.

I was really hoping to simply use a Roll-Up Summary field on the Contact, that would count the number of active entitlements to which a contact is associated, and then use that to trigger the update.  However, the many-to-many Entitlement Contacts related list does not show that the entitlement is expired, nor does it allow custom fields (so I cannot create a formula field on the object that pulls the status from the Entitlement).  So I am able to get a Total count, but not an Active-only count.

Has anyone encountered this and solved it?  Any info, direction, encouragement I can get would be appreciated.
I have created a webpage that we use to capture Mutual NDA information from prospects to create a Contract object in Salesforce.  It works fine, but my problem is I have 0% code coverage and do not even know where to begin.  Can someone help me (note I have looked at the VisualForce documents but they are not completely clear).  I am hoping for a pointer, not a full test class (but a full test class would not be unappreciated :).  Here is the page and the Controller.

<apex:page controller="Contract_WebSubmitPageReference" standardStylesheets="true" showHeader="false" sidebar="false">
<apex:form >
    <apex:pageBlock >
        <table cellspacing="2" cellpadding="2">
            <tr><td width="100" align="center" valign="center">
                <apex:image url="{!$Resource.logo}" width="82" height="74"/>
            </td><td>
                <h1><font size="+2">Request a Mutual NDA with MontaVista Software, LLC</font></h1>
            </td></tr>
        </table>
        <apex:pageBlockSection columns="1" > 
      <hr/>
      <p>
      <i><b>NOTE:</b> If you wish to enter anything other than the accepted options in the Contract Details section below, you cannot use this webform to request an NDA and you need to get in touch with your MontaVista contact to initiate a custom version of our Mutual NDA.</i>
        </p>
        <hr/>
          <p>
          Please describe who you are and why you are requesting a Mutual NDA at this time.  Include any names of MontaVista Employees with whom you are in contact.
          </p>
            <apex:inputField value="{!contract.Description}" style="height:100px;width:300px;" label="Explanation of Request"/> 
          <h2>Your Contact Information</h2>
            <apex:inputField value="{!contract.Requestor_First_Name__c}" label="First Name" required="true"/>
            <apex:inputField value="{!contract.Requestor_Last_Name__c}" label="Last Name" required="true"/>
            <apex:inputField value="{!contract.Requestor_Title__c}" label="Title" required="true"/>
            <apex:inputField value="{!contract.Requestor_Email__c}" label="Business Email Address" required="true"/>
            <apex:inputField value="{!contract.Requestor_Phone__c}" label="Phone Number"/>
        <h2>Legal Company Name and Corporate Address</h2>
            <apex:inputField value="{!contract.Customer_Name__c}" label="Full Company Name" required="true"/>
            <apex:inputField value="{!contract.Contract_Street__c}" label="Street Address" required="true"/>
            <apex:inputField value="{!contract.Contract_City__c}" label="City" required="true"/>
            <apex:inputField value="{!contract.Contract_State__c}" label="State/Province" required="true"/>
            <apex:inputField value="{!contract.Contract_Postal_Code__c}" label="Postal Code" required="true"/>
            <apex:inputField value="{!contract.Contract_Country__c}" label="Country" required="true"/>
        <hr/>
        <h2>Contract Details</h2>
            <apex:outputText value="The duration can be between 1 and 5 years for our standard Mutual NDA."/>
            <apex:inputField value="{!contract.Duration__c}" label="Duration" required="true"/>
            <apex:outputText value="This state selected here shall govern this Agreement and any dispute arising under this Agreement. You can select Califoria or Delaware as the jurisdction."/>
            <apex:inputField value="{!contract.Govern_Law__c}" label="Governing Law" required="true"/> 
        <hr/>
        <p align="center">
        &copy; 2012 MontaVista Software, LLC. All Rights Reserved &bull; <a href="http://www.mvista.com/privacy_policy.php" target="blank">Privacy Policy</a>
        </p>
        </apex:pageBlockSection>
        <apex:commandButton action="{!save}" value="Request Contract"/>
    </apex:pageBlock> 
</apex:form>
</apex:page>


Controller:

public class Contract_WebSubmitPageReference {
    Contract contract;

    public Contract getContract() {
        if(contract == null) contract = new Contract();
        return contract;
    }

    public PageReference save() {
        // Add the contract to the database.  

                if (contract.AccountId == null) {

                List<Account> acctId = [select Id from Account where Name =: contract.Customer_Name__c limit 1];
                        string aId;
                        if (acctId.isEmpty() == false) { 
                                aId = acctId[0].Id;
                                contract.AccountId = aId;
                        } else {
                                Account a = new Account();
                                        a.Name = contract.Customer_Name__c;
                                        a.BillingStreet = contract.Contract_Street__c;
                                        a.BillingCity = contract.Contract_City__c;
                                        a.BillingState = contract.Contract_State__c;
                                        a.BillingPostalCode = contract.Contract_Postal_Code__c;
                                        a.BillingCountry = contract.Contract_Country__c;
                                        insert a;
                                aId = a.Id;
                                contract.AccountId = aId;
                        } 
                if (contract.CustomerSignedId == null) {

                List<Contact> conId = [select Id from Contact where Email =: contract.Requestor_Email__c limit 1];
                        string cId;
                        if (conId.isEmpty() == false) { 
                                cId = conId[0].Id;
                                contract.Primary_Contact__c = cId;
                                contract.CustomerSignedId = cId;
                        } else {
                                Contact c2 = new Contact();
                                        c2.FirstName = contract.Requestor_First_Name__c;
                                        c2.LastName = contract.Requestor_Last_Name__c;
                                        c2.Title = contract.Requestor_Title__c;
                                        c2.Email = contract.Requestor_Email__c;
                                        c2.Phone = contract.Requestor_Phone__c;
                                        c2.AccountId = aId;
                                        insert c2;
                                cId = c2.Id;
                                contract.Primary_Contact__c = cId;
                                contract.CustomerSignedId = cId;
                        }
                } 
                contract.Status = 'Draft';
                contract.Source__c = 'Web Form';
                contract.StartDate = date.today();
                contract.Type__c = 'Mutual NDA';
                contract.RecordTypeId = [Select Id From RecordType where sObjectType='Contract' and isActive=true and Name='Mutual NDA'].Id;
        contract.Name = date.today().year() + ' - ' + contract.Customer_Name__c + ' - Mutual NDA';
                }
        insert contract;

        
                // Submit for Approval by Legal.
        Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
                req1.setComments('Submitting request for approval via the Web Form.');
                req1.setObjectId(contract.id);
        Approval.ProcessResult result = Approval.process(req1);


        // Send the user to the detail page for the new account. 
    
        PageReference acctPage = new PageReference('http://www.mvista.com');
        acctPage.setRedirect(true);
        return acctPage;
    }
}


In trying to utilize the Order and OrderItem objects, I want to create an Order record from an Opportunity that is moved to Booked/Ordered Stage.  That is done, no problem.

However, when I try to then replicate the line items from the Opportunity over to the Order record, using the bare minimum, Qty, Price, Product, I get the following UI error:

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Order3_OrderItemCreate caused an unexpected exception, contact your administrator: Order3_OrderItemCreate: 
execution of BeforeUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: 
INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []: 
Trigger.Order3_OrderItemCreate: line 47, column 1
I have narrowed the access  error down to the Product field.  In the trigger, I am using the PriceBookEntryId (same as I have done in the past for ServiceContract/ContractLineItem objects.

Looking at the OrderItem and the ContractLineItem objects, I can see that Product2 is READ ONLY on OrderItem, but not in ContractLineItem.  How can I change this or code around it?

OK, here is what I have gotten correct.  I enabled a portal and checked the box that says "Self-Registration Enabled".  Then I tested the page and got the two options for "Secure Customer Login" and "Don't have an Account?" on the login_portal.jsp page.  I search and found a PPT presentation in the documentation that describes how to replicate the "Secure Customer Login" side of the screen in a VisualForce page with our branding etc.

 

http://wiki.developerforce.com/images/1/12/Customer_Portal_implementation_guide-1-.ppt

 

However, I cannot find how to replicate the right side "Don't have an Account?" function.  Can someone point me to a how-to on that side?

I am trying to find a way to hide the "New" button on the Case related list "Comments".  We are using the AppExchange solution Email2Case Premium, but still need to remove the standard button so users pick the correct option when adding a comment to the case.

 

Salesforce support indicated that there is no way to remove this button, and they are aware that we all want the option to control it, so I am hoping someone here has figured out how to hide this button (and will tell me how :) )

I have created a short list for display on our customer Portal Home Page of the last 5 cases updated by support and I want to include a link to the case detail page from this list.  The Controller queries for the only 5 cases, sorted by last updated and returns the Id field in addition to the others.

 

<apex:page controller="CP_Cases_WOC_Controller" sidebar="false" showHeader="false">
    <apex:pageBlock title="5 Most Recently Updated Cases" mode="list">
      <apex:pageBlockTable value="{!cases}" var="c">
        <apex:column value="{!c.CaseNumber}"/>
        <apex:column value="{!c.Status}"/>
        <apex:column value="{!c.Subject}"/>
      </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 I want to have the CaseNumber be a link to the Case Detail page.  How can I do that?

I am trying to build a publicly accessible web page from a custom object and allow the user to select a subset of data.  For example, one field is a picklist in Salesforce and I want them to be able to show only those items that have a certain value selected.  I have created a page that shows the list of items, but I have no idea where to start to create the search form to filter that data.  Can anyone help me get started?

 

Here is the page I want to move to Visualforce - it is currently a PHP-based page built using the API - http://www.mvista.com/boards.php.

MS Excel has a function where you can write out a number, for example 50 would be fifty. You use SpellNumber(50) I think.

 

Is there an equivalent within Salesforce?  I need to take a currency field and write it out when creating a contract with the Ts and Cs in it.

Can anyone suggest a method to determine the language of an incoming email to On Demand email to case so we can tailor the reply email?  Really we need to only know if they are Japanese or not Japanese, not the each and every language specifically.

I was wondering if anyone had a way to prevent changes to attachments - deleting or adding - when a record is Locked during an Approval Process?

I am trying to create a trigger action based on the type of object as the Attachment.ParentId.  Specifically a custom object, Agreement, that always starts with a0g in the ID.

 

I want to write this type of logic:

 

trigger TRIGGNERNAME on Attachment (after insert) {

    for (Attachment a: trigger.new) {
        
        if(a.ParentId LIKE 'a0g%') {

              TRIGGER ACTION
             }
       }
}

 However, the LIKE option is not support and I cannot figure out what to substitute.   Any ideas?

I create a Visual force page to call an apex controller to create a new object.  Basically creating a Contract from the Account via a button so I can control some of the default values in the Contract, based on the Account.

 

However, there is one piece, the Contact, that I cannot predetermine as there are many contacts on an account typically.  So, what I wanted to do was have the PageReference open in Edit mode.  I was able to do that easily.  So here are the page references and results

 

        return new PageReference('/'+c.Id);

This lands on the new Contract, but is not open for editing.

 

        return new PageReference('/'+c.Id+'/e');
This lands on the new Contract in Edit Mode.  Which is correct, because I then made the Contact Signed By field required and the only editable field on the page - so the requestor can complete it.

 

However, after entering the Contact and saving the record again, the user is brought to the Home Page, not the Contract record.  Is there anyway I can control where the save takes them?  A second PageReference maybe?

I have been scouring the online forums trying to get the data loader to read from MS SQL and then put some data into Salesforce.  I almost have it working (I can read from SF for example).  However, I am getting a error around creating the data access object on the databaseRead command.  I am looking at all the config files and I think what is missing is the table name.  I have the server, the database, the login and password etc.  and that all works.  But the actual query, using a bean, does not have the table in it.  I have tried to place is a variety of places without success.

Can someone please show me the database-conf.xml parameters that I need, with them explained (most of the docs list "example" without breaking down the components so I have no idea which relates to server vs database vs table).

For example, here is what I have and what I think the pieces are show in <>.  As you can see I am stymied on table name.

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    <bean id="dbDataSource" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
        <property name="url" value="jdbc:microsoft:sqlserver://localhost:1433;databaseName=<databasename>"/>
        <property name="username" value="somename"/>
        <property name="password" value="somepassword"/>
    </bean>
    <bean id="tmpProject" class="com.salesforce.dataloader.dao.database.DatabaseConfig" singleton="true">
        <property name="sqlConfig" ref="queryprojects"/>
        <property name="dataSource" ref="dbDataSource"/>
    </bean>
    <bean id="queryprojects" class="com.salesforce.dataloader.dao.database.SqlConfig" singleton="true">
        <property name="sqlString">
            <value> select Project_Code__c, Name, Project_Number__c from tmpProject
        </value>
        </property>
    </bean>
</beans>

Any help is appreciated.

Hi Community,

 

I have a trigger that takes the Contact ID that is created when a lead is converted and moves it back to a customer support Case. Works great using the lead.ConvertedContactId and lead.isConverted = true fields.

 

However, I cannot write a test class for this trigger because I cannot convert a lead via Apex nor can I insert a Contact Id into the ConvertedContactId field manually.

 

Any ideas on how to test this trigger?

Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;

for (Lead l:leads){
l.setOptions(dmo);
}
Update leads;

Hi,

 

I have seen lots of code on reassigning Leads that looks like the above.  Is there an equivalent way for cases.  Here is my problem.  We create a case for all unknown contacts who send an email to our support alias, but we store it in a sales queue and create a lead using an Apex trigger.  When sales converts that lead into a contact at some point, we then insert the new ContactId into the original case and would then like to assign the case from the Sales Queue to the appropriate Support Queue (based on the criteria of the Contact etc).

 

This code would be ideal, except that if I change it over to assign a case, like this:

 

 

QueueSobject qId = [select QueueId from QueueSobject where QueueSobject.Queue.Name = 'Pending Sales'];

List<Case> cases = new List<Case>();

    Database.DMLOptions dmo=new Database.DMLOptions();
    dmo.assignmentRuleHeader.UseDefaultRule=True;

    for(Case c:trigger.new){

        if(c.OwnerId == qId.QueueId && c.ContactId != null){

            c.setOptions(dmo);
            cases.add(c);
        }
    }
   update cases;

 

In my before Update trigger I get this error:

 

 

Error: Apex trigger Case_Lead_Reassign caused an unexpected exception, contact your administrator: Case_Lead_Reassign: execution of AfterUpdate

caused by: System.SObjectException: DML statment cannot operate on trigger.new or trigger.old: Trigger.Case_Lead_Reassign: line 18, column 6

 

Is there something wrong?  Can you not do this on Cases like you can with Leads?  Is there a better way to reassign a Case?

 

I tried an after Update trigger, I replaced "update cases;" with "Database.update(cases);" with no luck.

We have a VisualForce Email Template where we want to display a
related list.  If it was a regular VisualForce page, we would include
an APEX extension and then call the class to populate a dataTable like
this:

 <apex:dataTable value="{!OppLines}" var="opp" border="0"
cellpadding="1" cellspacing="0">
    <apex:column ><apex:outputField
value="{!opp.PriceBookEntry.name}"/></apex:column>
    <apex:column ><apex:outputField value="{!opp.LSP__r.name}"/></apex:column>
    <apex:column ><apex:outputField value="{!opp.Quantity}"/></apex:column>
 </apex:dataTable>

 Which calls an APEX controller with this code:

 public OpportunityLineItem[] getOppLines() {
   OpportunityLineItem[] siItems = [SELECT PriceBookEntry.name,
LSP__r.name, Quantity
        FROM OpportunityLineItem
        Where OpportunityId = :ApexPages.currentPage().getParameters().get('Id')
        Order by PricebookEntry.name];
   return siItems;
 }

However, there is no way that we can see to attach the APEX controller
as an extension.  The only thing we could come up with is using a
component, and then referencing it in the VisualForce Email Template
like this:

<c:Opp_Lines_Component />

Unfortunately, the code in the APEX controller which pulls the ID from
the current VF Page doesn't work in an email template and so the
dataTable is always blank.

Is there any way to do what we are trying to do?

I have a Vforce email template that will correctly pull things like the Opportunity Name and the Closed Date from an Opportunity with typical fields like {!relatedTo.Name} or {!relatedTo.StageName}.

 

I wanted to add any records in Notes and Attachments to the email as well and found out how to do that with a trigger, as shown:

 

 

trigger sendEmailAlert on Opportunity (after update) {

for(opportunity o:Trigger.new){
if(o.Stagename == 'Order Credit Hold'){
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

Attachment[] queryAttachment = [select Name, Body from Attachment where Parentid=:o.Id order by CreatedDate DESC];

Messaging.EmailFileAttachment[] allAttachments = new Messaging.EmailFileAttachment[queryAttachment.size()];
        for(integer i=0;i<queryAttachment.size();i++)
        {
            Messaging.EmailFileAttachment fileAttachment = new Messaging.EmailFileAttachment();
            fileAttachment.setBody(queryAttachment[i].Body);
            fileAttachment.setFileName(queryAttachment[i].Name);
            allAttachments[i] =  fileAttachment;
        } 
        
        mail.setFileAttachments(allAttachments);
        mail.setTemplateID('00XQ0000000Dghe');
        mail.setTargetObjectID('0035000000axiyZ');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });


}
}
}

 

 

Which works to add the attachments to the email and the layout of the template is correct.

 

However, the !relatedTo fields are not getting pulled and used.  Any one know how to put the two things together?

I have been combing the forums and I know that insert is not supported - what are the succesful workaround so far? Any besides java code (which I am not 100% sure of how to implement)?  Workflow would be best ....

I was wondering if anyone has encountered and possibly solved this.  I cannot segregate responsibility for product marketing to ONLY edit and create products.  I do not want them to be able to make them "Active" but removing the Active field from the page layouts is not sufficient.

 

You cannot set the field itself to Read only for a profile and you cannoy get ride of the Activate/Deactivate links on the View layout.

 

Any ideas?

I create a Visual force page to call an apex controller to create a new object.  Basically creating a Contract from the Account via a button so I can control some of the default values in the Contract, based on the Account.

 

However, there is one piece, the Contact, that I cannot predetermine as there are many contacts on an account typically.  So, what I wanted to do was have the PageReference open in Edit mode.  I was able to do that easily.  So here are the page references and results

 

        return new PageReference('/'+c.Id);

This lands on the new Contract, but is not open for editing.

 

        return new PageReference('/'+c.Id+'/e');
This lands on the new Contract in Edit Mode.  Which is correct, because I then made the Contact Signed By field required and the only editable field on the page - so the requestor can complete it.

 

However, after entering the Contact and saving the record again, the user is brought to the Home Page, not the Contract record.  Is there anyway I can control where the save takes them?  A second PageReference maybe?

We are using Service Contracts and Entitlements to manage how our customers get support, and also when they should be allowed to activate a Customer Portal login.  The create/activate works but I am having a problem getting the delete/inactivate part going.  The problem is this, we give access to certain parts of the portal as well as our internal FTP site based on the entitlements to which a Contact is associated.  When that Entitlement expires, I need a mechanism that will check the Contacts related to the entitlement, then check each of those contacts to make sure they do not have an other active entitlements, and if so, deactivate their Customer Portal User Login.

I was really hoping to simply use a Roll-Up Summary field on the Contact, that would count the number of active entitlements to which a contact is associated, and then use that to trigger the update.  However, the many-to-many Entitlement Contacts related list does not show that the entitlement is expired, nor does it allow custom fields (so I cannot create a formula field on the object that pulls the status from the Entitlement).  So I am able to get a Total count, but not an Active-only count.

Has anyone encountered this and solved it?  Any info, direction, encouragement I can get would be appreciated.
I have created a webpage that we use to capture Mutual NDA information from prospects to create a Contract object in Salesforce.  It works fine, but my problem is I have 0% code coverage and do not even know where to begin.  Can someone help me (note I have looked at the VisualForce documents but they are not completely clear).  I am hoping for a pointer, not a full test class (but a full test class would not be unappreciated :).  Here is the page and the Controller.

<apex:page controller="Contract_WebSubmitPageReference" standardStylesheets="true" showHeader="false" sidebar="false">
<apex:form >
    <apex:pageBlock >
        <table cellspacing="2" cellpadding="2">
            <tr><td width="100" align="center" valign="center">
                <apex:image url="{!$Resource.logo}" width="82" height="74"/>
            </td><td>
                <h1><font size="+2">Request a Mutual NDA with MontaVista Software, LLC</font></h1>
            </td></tr>
        </table>
        <apex:pageBlockSection columns="1" > 
      <hr/>
      <p>
      <i><b>NOTE:</b> If you wish to enter anything other than the accepted options in the Contract Details section below, you cannot use this webform to request an NDA and you need to get in touch with your MontaVista contact to initiate a custom version of our Mutual NDA.</i>
        </p>
        <hr/>
          <p>
          Please describe who you are and why you are requesting a Mutual NDA at this time.  Include any names of MontaVista Employees with whom you are in contact.
          </p>
            <apex:inputField value="{!contract.Description}" style="height:100px;width:300px;" label="Explanation of Request"/> 
          <h2>Your Contact Information</h2>
            <apex:inputField value="{!contract.Requestor_First_Name__c}" label="First Name" required="true"/>
            <apex:inputField value="{!contract.Requestor_Last_Name__c}" label="Last Name" required="true"/>
            <apex:inputField value="{!contract.Requestor_Title__c}" label="Title" required="true"/>
            <apex:inputField value="{!contract.Requestor_Email__c}" label="Business Email Address" required="true"/>
            <apex:inputField value="{!contract.Requestor_Phone__c}" label="Phone Number"/>
        <h2>Legal Company Name and Corporate Address</h2>
            <apex:inputField value="{!contract.Customer_Name__c}" label="Full Company Name" required="true"/>
            <apex:inputField value="{!contract.Contract_Street__c}" label="Street Address" required="true"/>
            <apex:inputField value="{!contract.Contract_City__c}" label="City" required="true"/>
            <apex:inputField value="{!contract.Contract_State__c}" label="State/Province" required="true"/>
            <apex:inputField value="{!contract.Contract_Postal_Code__c}" label="Postal Code" required="true"/>
            <apex:inputField value="{!contract.Contract_Country__c}" label="Country" required="true"/>
        <hr/>
        <h2>Contract Details</h2>
            <apex:outputText value="The duration can be between 1 and 5 years for our standard Mutual NDA."/>
            <apex:inputField value="{!contract.Duration__c}" label="Duration" required="true"/>
            <apex:outputText value="This state selected here shall govern this Agreement and any dispute arising under this Agreement. You can select Califoria or Delaware as the jurisdction."/>
            <apex:inputField value="{!contract.Govern_Law__c}" label="Governing Law" required="true"/> 
        <hr/>
        <p align="center">
        &copy; 2012 MontaVista Software, LLC. All Rights Reserved &bull; <a href="http://www.mvista.com/privacy_policy.php" target="blank">Privacy Policy</a>
        </p>
        </apex:pageBlockSection>
        <apex:commandButton action="{!save}" value="Request Contract"/>
    </apex:pageBlock> 
</apex:form>
</apex:page>


Controller:

public class Contract_WebSubmitPageReference {
    Contract contract;

    public Contract getContract() {
        if(contract == null) contract = new Contract();
        return contract;
    }

    public PageReference save() {
        // Add the contract to the database.  

                if (contract.AccountId == null) {

                List<Account> acctId = [select Id from Account where Name =: contract.Customer_Name__c limit 1];
                        string aId;
                        if (acctId.isEmpty() == false) { 
                                aId = acctId[0].Id;
                                contract.AccountId = aId;
                        } else {
                                Account a = new Account();
                                        a.Name = contract.Customer_Name__c;
                                        a.BillingStreet = contract.Contract_Street__c;
                                        a.BillingCity = contract.Contract_City__c;
                                        a.BillingState = contract.Contract_State__c;
                                        a.BillingPostalCode = contract.Contract_Postal_Code__c;
                                        a.BillingCountry = contract.Contract_Country__c;
                                        insert a;
                                aId = a.Id;
                                contract.AccountId = aId;
                        } 
                if (contract.CustomerSignedId == null) {

                List<Contact> conId = [select Id from Contact where Email =: contract.Requestor_Email__c limit 1];
                        string cId;
                        if (conId.isEmpty() == false) { 
                                cId = conId[0].Id;
                                contract.Primary_Contact__c = cId;
                                contract.CustomerSignedId = cId;
                        } else {
                                Contact c2 = new Contact();
                                        c2.FirstName = contract.Requestor_First_Name__c;
                                        c2.LastName = contract.Requestor_Last_Name__c;
                                        c2.Title = contract.Requestor_Title__c;
                                        c2.Email = contract.Requestor_Email__c;
                                        c2.Phone = contract.Requestor_Phone__c;
                                        c2.AccountId = aId;
                                        insert c2;
                                cId = c2.Id;
                                contract.Primary_Contact__c = cId;
                                contract.CustomerSignedId = cId;
                        }
                } 
                contract.Status = 'Draft';
                contract.Source__c = 'Web Form';
                contract.StartDate = date.today();
                contract.Type__c = 'Mutual NDA';
                contract.RecordTypeId = [Select Id From RecordType where sObjectType='Contract' and isActive=true and Name='Mutual NDA'].Id;
        contract.Name = date.today().year() + ' - ' + contract.Customer_Name__c + ' - Mutual NDA';
                }
        insert contract;

        
                // Submit for Approval by Legal.
        Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
                req1.setComments('Submitting request for approval via the Web Form.');
                req1.setObjectId(contract.id);
        Approval.ProcessResult result = Approval.process(req1);


        // Send the user to the detail page for the new account. 
    
        PageReference acctPage = new PageReference('http://www.mvista.com');
        acctPage.setRedirect(true);
        return acctPage;
    }
}


In trying to utilize the Order and OrderItem objects, I want to create an Order record from an Opportunity that is moved to Booked/Ordered Stage.  That is done, no problem.

However, when I try to then replicate the line items from the Opportunity over to the Order record, using the bare minimum, Qty, Price, Product, I get the following UI error:

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Order3_OrderItemCreate caused an unexpected exception, contact your administrator: Order3_OrderItemCreate: 
execution of BeforeUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: 
INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []: 
Trigger.Order3_OrderItemCreate: line 47, column 1
I have narrowed the access  error down to the Product field.  In the trigger, I am using the PriceBookEntryId (same as I have done in the past for ServiceContract/ContractLineItem objects.

Looking at the OrderItem and the ContractLineItem objects, I can see that Product2 is READ ONLY on OrderItem, but not in ContractLineItem.  How can I change this or code around it?

OK, here is what I have gotten correct.  I enabled a portal and checked the box that says "Self-Registration Enabled".  Then I tested the page and got the two options for "Secure Customer Login" and "Don't have an Account?" on the login_portal.jsp page.  I search and found a PPT presentation in the documentation that describes how to replicate the "Secure Customer Login" side of the screen in a VisualForce page with our branding etc.

 

http://wiki.developerforce.com/images/1/12/Customer_Portal_implementation_guide-1-.ppt

 

However, I cannot find how to replicate the right side "Don't have an Account?" function.  Can someone point me to a how-to on that side?

I have created a short list for display on our customer Portal Home Page of the last 5 cases updated by support and I want to include a link to the case detail page from this list.  The Controller queries for the only 5 cases, sorted by last updated and returns the Id field in addition to the others.

 

<apex:page controller="CP_Cases_WOC_Controller" sidebar="false" showHeader="false">
    <apex:pageBlock title="5 Most Recently Updated Cases" mode="list">
      <apex:pageBlockTable value="{!cases}" var="c">
        <apex:column value="{!c.CaseNumber}"/>
        <apex:column value="{!c.Status}"/>
        <apex:column value="{!c.Subject}"/>
      </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 I want to have the CaseNumber be a link to the Case Detail page.  How can I do that?

I am trying to build a publicly accessible web page from a custom object and allow the user to select a subset of data.  For example, one field is a picklist in Salesforce and I want them to be able to show only those items that have a certain value selected.  I have created a page that shows the list of items, but I have no idea where to start to create the search form to filter that data.  Can anyone help me get started?

 

Here is the page I want to move to Visualforce - it is currently a PHP-based page built using the API - http://www.mvista.com/boards.php.

I have a custom object related to the Contact that I need to take the value from the most recent record in the custom object and display it on the contact.

 

The field on the custom object is a picklist. 

 

So when a new record is adding to the custom object, I want the picklist value to be put on the contact in a custom field.

 

Can I do this?

I am trying to create a trigger action based on the type of object as the Attachment.ParentId.  Specifically a custom object, Agreement, that always starts with a0g in the ID.

 

I want to write this type of logic:

 

trigger TRIGGNERNAME on Attachment (after insert) {

    for (Attachment a: trigger.new) {
        
        if(a.ParentId LIKE 'a0g%') {

              TRIGGER ACTION
             }
       }
}

 However, the LIKE option is not support and I cannot figure out what to substitute.   Any ideas?

I create a Visual force page to call an apex controller to create a new object.  Basically creating a Contract from the Account via a button so I can control some of the default values in the Contract, based on the Account.

 

However, there is one piece, the Contact, that I cannot predetermine as there are many contacts on an account typically.  So, what I wanted to do was have the PageReference open in Edit mode.  I was able to do that easily.  So here are the page references and results

 

        return new PageReference('/'+c.Id);

This lands on the new Contract, but is not open for editing.

 

        return new PageReference('/'+c.Id+'/e');
This lands on the new Contract in Edit Mode.  Which is correct, because I then made the Contact Signed By field required and the only editable field on the page - so the requestor can complete it.

 

However, after entering the Contact and saving the record again, the user is brought to the Home Page, not the Contract record.  Is there anyway I can control where the save takes them?  A second PageReference maybe?

Hi Community,

 

I have a trigger that takes the Contact ID that is created when a lead is converted and moves it back to a customer support Case. Works great using the lead.ConvertedContactId and lead.isConverted = true fields.

 

However, I cannot write a test class for this trigger because I cannot convert a lead via Apex nor can I insert a Contact Id into the ConvertedContactId field manually.

 

Any ideas on how to test this trigger?

I am facing some issue in below scenario.

 

 

Whenever opportunity stage is changed to "closed won" message should be displayed on top of the page as “Approval Required”.

 

And Stage should remain same as earlier until supervisor approves it.

 

After approval of supervisor stage should change to closed won.

 

Please help me in resolving this issue.

I am trying to edit the My Profile page on a customer portal.  I know in Winter 11 the page was released so that it could be edited.  After reading the Winter 11 release notes it seems that all I need to do is add the my profile visualforce page to the profile of the portal user.  I have done this but no changes that I make on the my profile visualforce page show up.  It seems like the portal is still using some out of the box page instead of the my profile visualforce page.  Is there anything else that I need to do in order to get the my profile visualforce page to display when I click the my profile link in the customer portal?

 

Thanks in advance!

We are using Google Apps for our enterpise email and any email forwards we create we set via a Google group.  In creating an Email Service (using the basic unsubscribe example), sending an email directly to the email generated by Google, the really long ugly one  works fine.  However, adding that email the Google group (for example, unsub at <some domain> dot com and forwarding it, does not work.

 

Any ideas why this is not working?  I added my own email to the group and the message comes through complete and as expected.