• koen
  • NEWBIE
  • 0 Points
  • Member since 2006

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

I want to insert OpportunityContactRole into an existing Opportunity in a controller extended from opportunity standard controller.

 

Below is my code:

/* Set CampaignId */
opportunity.CampaignId = sCampaignId;

OpportunityContactRole oppContactRole = new OpportunityContactRole(ContactId=sId, OpportunityId=opportunity.Id, IsPrimary=false, Role='Economic Decision Maker');
           
insert oppContactRole;

...

stdController.save();


After I insert oppContactRole, it has ID but I can not access this object and it is not displayed in opportunities contact roles list after the whole action is over. There is no any exception throwed.

BTW: I can update or delete the existing opportunity's OpportunityContactRole.

 

  • March 15, 2011
  • Like
  • 0

 

<apex:page standardController="Opportunity" extensions="OpportunityCampaignController" tabStyle="Opportunity">

	<apex:form >
		<apex:messages />
		
		<apex:pageBlock mode="edit" id="accountSearchBlock" title="Opportunity [{!opportunity.name}] Campaign Selector">
			<apex:pageBlockSection >
				<apex:pageBlockSectionItem >
					<apex:outputLabel for="acountSearchText">Search Account:</apex:outputLabel>
					<apex:panelGroup >
						<apex:inputText id="acountSearchText" value="{!accountSearchText}"/>
						<apex:commandButton value="Go!" action="{!doAccountSearch}" reRender="accountSearchResults, contactSearchResults, campaignSearchResults, campaignDetail" status="accountSearchStatus"/>
					</apex:panelGroup>
				</apex:pageBlockSectionItem>
			</apex:pageBlockSection>
			
			<apex:actionStatus id="accountSearchStatus" startText="Loading accounts..."/>
			<apex:pageBlockSection title="Accounts" id="accountSearchResults" columns="1">
				<apex:pageBlockTable value="{!accountSearchResults}" var="accountCur" rendered="{!NOT(ISNULL(accountSearchResults))}">
					<apex:column >
						<apex:facet name="header">Name</apex:facet>					
						<apex:outputPanel >
							<apex:actionSupport event="onclick" action="{!doSelectAccount}" reRender="contactSearchResults, campaignSearchResults, campaignDetail" status="contactSearchStatus">
								<apex:param name="accountId" value="{!accountCur.id}"/>
							</apex:actionSupport>
							{!accountCur.name}
						</apex:outputPanel>
					</apex:column>
					<apex:column value="{!accountCur.industry}"/>
					<apex:column value="{!accountCur.billingCountry}"/>
				</apex:pageBlockTable>
			</apex:pageBlockSection>
			
			<apex:actionStatus id="contactSearchStatus" startText="Loading contacts..."/>			
			<apex:pageBlockSection title="Contacts" id="contactSearchResults" columns="1">
				<apex:pageBlockTable value="{!contactSearchResults}" var="contactCur" rendered="{!NOT(ISNULL(contactSearchResults))}">
					<apex:column >
						<apex:facet name="header">Name</apex:facet>					
						<apex:outputPanel >
							<apex:actionSupport event="onclick" action="{!doSelectContact}" rerender="campaignSearchResults, campaignDetail" status="campaignSearchStatus">
								<apex:param name="contactId" value="{!contactCur.id}"/>
							</apex:actionSupport>
							{!contactCur.name}
						</apex:outputPanel>
					</apex:column>
					<apex:column value="{!contactCur.email}"/>
					<apex:column value="{!contactCur.phone}"/>
				</apex:pageBlockTable>
			</apex:pageBlockSection>
			
			<apex:actionStatus id="campaignSearchStatus" startText="Loading campaigns..."/>			
			<apex:pageBlockSection title="Campaigns" id="campaignSearchResults" columns="1">
				<apex:pageBlockTable value="{!campaignSearchResults}" var="campaignCur" rendered="{!NOT(ISNULL(campaignSearchResults))}">
					<apex:column >
						<apex:facet name="header">Name</apex:facet>					
						<apex:outputPanel >
							<apex:actionSupport event="onclick" action="{!doSelectCampaign}" rerender="campaignDetail" status="campaignDetailStatus">
								<apex:param name="campaignId" value="{!campaignCur.id}" assignTo="{!campaignId}"/>								
							</apex:actionSupport>
							{!campaignCur.name}
						</apex:outputPanel>
					</apex:column>
					<apex:column value="{!campaignCur.status}"/>
					<apex:column value="{!campaignCur.startDate}"/>
					<apex:column value="{!campaignCur.endDate}"/>
				</apex:pageBlockTable>
			</apex:pageBlockSection>
			
			<apex:pageBlockSection title="Predefined Campaigns" id="predefinedCampaignList" columns="1">
				<apex:pageBlockTable value="{!predefinedCampaignList}" var="campaignCur" rendered="{!NOT(ISNULL(predefinedCampaignList))}">
					<apex:actionSupport event="onRowClick" action="{!doSelectCampaign}" rerender="campaignDetail" status="campaignDetailStatus">
						<apex:param value="{!campaignCur.id}" assignTo="{!campaignId}"/>
					</apex:actionSupport>
					<apex:column value="{!campaignCur.name}"/>
					<apex:column value="{!campaignCur.status}"/>
					<apex:column value="{!campaignCur.startDate}"/>
					<apex:column value="{!campaignCur.endDate}"/>
				</apex:pageBlockTable>
			</apex:pageBlockSection>
		</apex:pageBlock>
			
		<apex:pageBlock title="Selected Campaign">			
			<apex:pageBlockButtons location="top">
				<apex:commandButton value="Select Campaign" action="{!doSaveOpportunityCampaign}"/>
				<apex:commandButton value="Cancel" action="{!cancel}"/>
			</apex:pageBlockButtons>

    		<apex:outputPanel id="campaignDetail">
        		<apex:actionStatus startText="Loading selected campaign detail..." id="campaignDetailStatus">
            		<apex:facet name="stop">
                		<apex:detail subject="{!campaignId}" relatedList="false" title="false" />
            		</apex:facet>
        		</apex:actionStatus>
    		</apex:outputPanel>    
		</apex:pageBlock>
		
	</apex:form>

</apex:page>

 When I add actionSupport within outputPanel in column, it works fine. But when I add actionSupport within pageBlockTable to response onRowClick event, both apex:param and action do not work. Only reRender object is rendered without any changes.

 

I am crazy with this problem :(

 

 

  • March 01, 2011
  • Like
  • 0

I want to insert OpportunityContactRole into an existing Opportunity in a controller extended from opportunity standard controller.

 

Below is my code:

/* Set CampaignId */
opportunity.CampaignId = sCampaignId;

OpportunityContactRole oppContactRole = new OpportunityContactRole(ContactId=sId, OpportunityId=opportunity.Id, IsPrimary=false, Role='Economic Decision Maker');
           
insert oppContactRole;

...

stdController.save();


After I insert oppContactRole, it has ID but I can not access this object and it is not displayed in opportunities contact roles list after the whole action is over. There is no any exception throwed.

BTW: I can update or delete the existing opportunity's OpportunityContactRole.

 

  • March 15, 2011
  • Like
  • 0

 

<apex:page standardController="Opportunity" extensions="OpportunityCampaignController" tabStyle="Opportunity">

	<apex:form >
		<apex:messages />
		
		<apex:pageBlock mode="edit" id="accountSearchBlock" title="Opportunity [{!opportunity.name}] Campaign Selector">
			<apex:pageBlockSection >
				<apex:pageBlockSectionItem >
					<apex:outputLabel for="acountSearchText">Search Account:</apex:outputLabel>
					<apex:panelGroup >
						<apex:inputText id="acountSearchText" value="{!accountSearchText}"/>
						<apex:commandButton value="Go!" action="{!doAccountSearch}" reRender="accountSearchResults, contactSearchResults, campaignSearchResults, campaignDetail" status="accountSearchStatus"/>
					</apex:panelGroup>
				</apex:pageBlockSectionItem>
			</apex:pageBlockSection>
			
			<apex:actionStatus id="accountSearchStatus" startText="Loading accounts..."/>
			<apex:pageBlockSection title="Accounts" id="accountSearchResults" columns="1">
				<apex:pageBlockTable value="{!accountSearchResults}" var="accountCur" rendered="{!NOT(ISNULL(accountSearchResults))}">
					<apex:column >
						<apex:facet name="header">Name</apex:facet>					
						<apex:outputPanel >
							<apex:actionSupport event="onclick" action="{!doSelectAccount}" reRender="contactSearchResults, campaignSearchResults, campaignDetail" status="contactSearchStatus">
								<apex:param name="accountId" value="{!accountCur.id}"/>
							</apex:actionSupport>
							{!accountCur.name}
						</apex:outputPanel>
					</apex:column>
					<apex:column value="{!accountCur.industry}"/>
					<apex:column value="{!accountCur.billingCountry}"/>
				</apex:pageBlockTable>
			</apex:pageBlockSection>
			
			<apex:actionStatus id="contactSearchStatus" startText="Loading contacts..."/>			
			<apex:pageBlockSection title="Contacts" id="contactSearchResults" columns="1">
				<apex:pageBlockTable value="{!contactSearchResults}" var="contactCur" rendered="{!NOT(ISNULL(contactSearchResults))}">
					<apex:column >
						<apex:facet name="header">Name</apex:facet>					
						<apex:outputPanel >
							<apex:actionSupport event="onclick" action="{!doSelectContact}" rerender="campaignSearchResults, campaignDetail" status="campaignSearchStatus">
								<apex:param name="contactId" value="{!contactCur.id}"/>
							</apex:actionSupport>
							{!contactCur.name}
						</apex:outputPanel>
					</apex:column>
					<apex:column value="{!contactCur.email}"/>
					<apex:column value="{!contactCur.phone}"/>
				</apex:pageBlockTable>
			</apex:pageBlockSection>
			
			<apex:actionStatus id="campaignSearchStatus" startText="Loading campaigns..."/>			
			<apex:pageBlockSection title="Campaigns" id="campaignSearchResults" columns="1">
				<apex:pageBlockTable value="{!campaignSearchResults}" var="campaignCur" rendered="{!NOT(ISNULL(campaignSearchResults))}">
					<apex:column >
						<apex:facet name="header">Name</apex:facet>					
						<apex:outputPanel >
							<apex:actionSupport event="onclick" action="{!doSelectCampaign}" rerender="campaignDetail" status="campaignDetailStatus">
								<apex:param name="campaignId" value="{!campaignCur.id}" assignTo="{!campaignId}"/>								
							</apex:actionSupport>
							{!campaignCur.name}
						</apex:outputPanel>
					</apex:column>
					<apex:column value="{!campaignCur.status}"/>
					<apex:column value="{!campaignCur.startDate}"/>
					<apex:column value="{!campaignCur.endDate}"/>
				</apex:pageBlockTable>
			</apex:pageBlockSection>
			
			<apex:pageBlockSection title="Predefined Campaigns" id="predefinedCampaignList" columns="1">
				<apex:pageBlockTable value="{!predefinedCampaignList}" var="campaignCur" rendered="{!NOT(ISNULL(predefinedCampaignList))}">
					<apex:actionSupport event="onRowClick" action="{!doSelectCampaign}" rerender="campaignDetail" status="campaignDetailStatus">
						<apex:param value="{!campaignCur.id}" assignTo="{!campaignId}"/>
					</apex:actionSupport>
					<apex:column value="{!campaignCur.name}"/>
					<apex:column value="{!campaignCur.status}"/>
					<apex:column value="{!campaignCur.startDate}"/>
					<apex:column value="{!campaignCur.endDate}"/>
				</apex:pageBlockTable>
			</apex:pageBlockSection>
		</apex:pageBlock>
			
		<apex:pageBlock title="Selected Campaign">			
			<apex:pageBlockButtons location="top">
				<apex:commandButton value="Select Campaign" action="{!doSaveOpportunityCampaign}"/>
				<apex:commandButton value="Cancel" action="{!cancel}"/>
			</apex:pageBlockButtons>

    		<apex:outputPanel id="campaignDetail">
        		<apex:actionStatus startText="Loading selected campaign detail..." id="campaignDetailStatus">
            		<apex:facet name="stop">
                		<apex:detail subject="{!campaignId}" relatedList="false" title="false" />
            		</apex:facet>
        		</apex:actionStatus>
    		</apex:outputPanel>    
		</apex:pageBlock>
		
	</apex:form>

</apex:page>

 When I add actionSupport within outputPanel in column, it works fine. But when I add actionSupport within pageBlockTable to response onRowClick event, both apex:param and action do not work. Only reRender object is rendered without any changes.

 

I am crazy with this problem :(

 

 

  • March 01, 2011
  • Like
  • 0