• Zen Newman 1
  • NEWBIE
  • 20 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hello- I'm trying to create a trigger that uses a SOQL query to find a record on a custom object matching criteria and then populate a lookup on the Opportunity with that record. My code is below, but I keep running into an error: "Illegal assignment from Schema.SObjectField to ID" on line 4.
trigger SalesPerformance on Opportunity (before insert, before update) {
    for (Opportunity o : [SELECT Sales_Performance__c.OwnerId FROM Sales_Performance__c WHERE Sales_Performance__c.OwnerId IN (SELECT Opportunity.OwnerId FROM Opportunity)]) { 
        if (Sales_Performance__c.Performance_Start__c == Opportunity.Client_Services_Launch_Date__c) {
            o.Sales_Performance__c = Sales_Performance__c.Id;
        }
    }
}
Thank you! 
 
Hello, fairly new to Visualforce. I'm trying to create a Visualforce page to replace the default create new opportunity page. The code I used came from a similar new account page which is working. I'm seeing no warrnings in the developer console and the page displays fine, but when I click the save button, no record is created and when I click the cancel button, it flags required fields as needing to be filled out to move forward. Can someone tell me where I'm going wrong? Thank you! 
 
<apex:page standardController="Opportunity" lightningStylesheets="TRUE" showHeader="TRUE" docType="html-5.0">
    <apex:SectionHeader title="New Opportunity"> 
    	<apex:form >
        	<apex:pageBlock title="Add Opportunity"  mode="edit">
          		<apex:pageBlockButtons >
            		<apex:commandButton action="{!save}" value="Save"/>
            		<apex:commandButton action="{!cancel}" value="Cancel" immediate="true"/>
       			</apex:pageBlockButtons> 
                <apex:pageBlockSection >
                    <apex:inputField value="{!Opportunity.Name}" />
                    <apex:inputField value="{!Opportunity.AccountId}" />
                    <apex:inputField value="{!Opportunity.Stagename}" /> 
                    <apex:inputField type="date" showDatePicker="TRUE" value="{!Opportunity.CloseDate}" required="TRUE" /> 
                    <apex:inputField type="date" showDatePicker="TRUE" value="{!Opportunity.Project_Launch_Date__c}" required="TRUE" /> 
                    <apex:inputField value="{!Opportunity.Broker_Account__c}" />
                    <apex:inputField value="{!Opportunity.Broker_Contact__c}" /> 
                </apex:pageBlockSection>
            </apex:pageBlock>
    	</apex:form>
    </apex:SectionHeader>
</apex:page>

Screenshot
Hello- I'm trying to create a trigger that uses a SOQL query to find a record on a custom object matching criteria and then populate a lookup on the Opportunity with that record. My code is below, but I keep running into an error: "Illegal assignment from Schema.SObjectField to ID" on line 4.
trigger SalesPerformance on Opportunity (before insert, before update) {
    for (Opportunity o : [SELECT Sales_Performance__c.OwnerId FROM Sales_Performance__c WHERE Sales_Performance__c.OwnerId IN (SELECT Opportunity.OwnerId FROM Opportunity)]) { 
        if (Sales_Performance__c.Performance_Start__c == Opportunity.Client_Services_Launch_Date__c) {
            o.Sales_Performance__c = Sales_Performance__c.Id;
        }
    }
}
Thank you! 
 
Hello, fairly new to Visualforce. I'm trying to create a Visualforce page to replace the default create new opportunity page. The code I used came from a similar new account page which is working. I'm seeing no warrnings in the developer console and the page displays fine, but when I click the save button, no record is created and when I click the cancel button, it flags required fields as needing to be filled out to move forward. Can someone tell me where I'm going wrong? Thank you! 
 
<apex:page standardController="Opportunity" lightningStylesheets="TRUE" showHeader="TRUE" docType="html-5.0">
    <apex:SectionHeader title="New Opportunity"> 
    	<apex:form >
        	<apex:pageBlock title="Add Opportunity"  mode="edit">
          		<apex:pageBlockButtons >
            		<apex:commandButton action="{!save}" value="Save"/>
            		<apex:commandButton action="{!cancel}" value="Cancel" immediate="true"/>
       			</apex:pageBlockButtons> 
                <apex:pageBlockSection >
                    <apex:inputField value="{!Opportunity.Name}" />
                    <apex:inputField value="{!Opportunity.AccountId}" />
                    <apex:inputField value="{!Opportunity.Stagename}" /> 
                    <apex:inputField type="date" showDatePicker="TRUE" value="{!Opportunity.CloseDate}" required="TRUE" /> 
                    <apex:inputField type="date" showDatePicker="TRUE" value="{!Opportunity.Project_Launch_Date__c}" required="TRUE" /> 
                    <apex:inputField value="{!Opportunity.Broker_Account__c}" />
                    <apex:inputField value="{!Opportunity.Broker_Contact__c}" /> 
                </apex:pageBlockSection>
            </apex:pageBlock>
    	</apex:form>
    </apex:SectionHeader>
</apex:page>

Screenshot