• billgreenhaw
  • NEWBIE
  • 50 Points
  • Member since 2006

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

I have a scenario right now where we have had to change many products on Opportunities based on Opportunity Type. I have the SOQL, etc...all working to find the correct products I need to change and the correct PriceBookEntryId to update for the line items.

 

But looks like I cannot update the PriceBookEntryId field on OpportunityLineItem object. Is this correct? Is the only way to do what I need to do really to insert new line items and delete the old line items?  This is a ton of rows that I would need to do it and much easier/straight forward to simply update the pricebookentryid field.

 

Thanks for any thoughts or suggestions.

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_opportunitylineitem.htm

 

Can I write to when inserting or edit this field?  I need to actually change the sorting this way (not a workaround using  another field and displaying...data is part of integration).

 

I have two issues.

 

One is the Sorting only shows one field. I would like to create a VisualForce page that has additional fields in the grid, change the order, and write back.

 

Other is create some large opportunities using APEX and would like to write the SortOrder when these are created. I believe it does not write by my sort, and resorts when inserted (is this correct?)

 

 

Currently I have built a process to give product discounts by quantity.  Basically on the product object I have custom fields. FieldA would be for the 1st level qty discount, FieldB would be for the 2nd level, etc... Then the end user can type in all the prices for each level of discount (based on quantity).  Then I have an Apex trigger than runs on the Opportunity Line item and reads the appropriate field to get the price.  Works well.

 

But I have come up with an issue where we now want to give discounts per pricebook. But I cannot add custom fields to the pricebook and I cannot create a lookup to the pricebook. If I could do a lookup I could simply create another object with lookups to product and pricebook objects. And then have the trigger read the pricebook and get the appropriate discounts.

 

Anyone have any other thoughts on how to handle this? 

Thanks for any help and feel free to rip my code apart, as I am sure I not done it correctly so far.

When an Opportunity is updated I need to first create a record in License_Overview__c. object This will also be a single record. I am sure I am doing way too much code at this level to get the Opportunity values.

 

After License_Overview__c record is created I need to create record(s) into the License_Detail__c object.  Values are based on the OpportunityLineItem object for the Opportunity.  One or many records can be returned.  I need to insert the LicenceOverview__c ID into this object, since they are Parent-Child relationship (Overview is the parent to Detail).

 

The 2nd part is where I am failing.  I cannot see how to get the inserted ID so I can use it.  Probably really simple and I am just missing it.

 

Trigger OpportunityCloseWon_Products on Opportunity (after insert, after update) {
	List<License_Overview__c> LicenseOverview = new List<License_Overview__c>();
	List<License_Detail__c> LicenseDetail = new List<License_Detail__c>();
   	for ( Opportunity o : trigger.New )
   	{
   		if ( o.isWon ) {
   			License_Overview__c[] lic1 = [Select l.Id  from License_Overview__c l where l.Opportunity__c = :o.Id and IsDeleted != TRUE];
   			if (lic1.size() < 1 ) {
		   		{
					Opportunity[] o3 = [Select o.Licensee__c, o.Id, o.AccountId,
												o.End_Date__c from Opportunity o 
												where Id = :o.Id and IsDeleted != TRUE limit 1];
						if (o3.size() > 0) {
							//if ( Trigger.isUpdate )
							//Remember to set Status = Active
							License_Overview__c lo = new License_Overview__c (
								Licensee__c = o3[0].Licensee__c,
								Opportunity__c = o3[0].Id,
								Status__c = 'Active',
								Account__c = o3[0].AccountId,
								End_Date__c = o3[0].End_Date__c
								);
							LicenseOverview.add(lo);
						}
					insert LicenseOverview;
		   		}
		   		{
		   			OpportunityLineItem[] o4 = [Select o.Description, o.OpportunityId, o.Opportunity.AccountId, 
									   			o.OS_del__c, o.PricebookEntryId, o.PricebookEntry.Name, o.Quantity, o.Version_del__c 
									   			from OpportunityLineItem o where o.OpportunityId = :o.Id and o.IsDeleted != TRUE];
		   				if ( o4.size() > 0 ) {
							for (Integer i = 0; i < o4.size(); i++) {
								License_Detail__c ld = new License_Detail__c (
									Description__c = o4[i].Description,
									License_Overview__c = LicenseOverview.get(0).id,
									Status__c = 'Active',
									Account__c = o4[i].Opportunity.AccountId,
									Product__c = o4[i].PricebookEntry.Name,
									Users__c = o4[i].Quantity,
									System_Code__c = o4[i].OS_del__c,
									Version__c =  o4[i].Version_del__c
									);
								LicenseDetail.add(ld);
		   					}
						}
					insert LicenseDetail;
		   		}
   			}
   		}
   	}
}

 

Hi,

 

First time really diving into APEX from scratch. Before I just took other code and did made changes.

 

I am trying to insert a record using a trigger when Opportunity is Won.  Getting an error on linke 13. Just some advice to get me in the right direction would be greatly appreciated.

 

Trigger OpportunityCloseWon_Products on Opportunity (after update) {
	//
	List<License_Overview__c> LicenseOverview = new List<License_Overview__c>();
   	for ( Opportunity o : trigger.New )
   	{
   		if ( o.isWon )
   		{
			OpportunityLineItem[] o3 = [Select o.Licensee__c, o.OpportunityId, o.Opportunity.AccountId from OpportunityLineItem o where OpportunityId = :o.Id and IsDeleted != TRUE limit 1];
				if (o3.size() > 0) {
					//if ( Trigger.isUpdate )
					//Remember to set Status = Active
					License_Overview__c lo = new License_Overview__c (
						Licensee__c = o3.Licensee__c,
						Opportunity__c = o3.OpportunityId,
						Status__c = 'Active',
						Account__c = o3.AccountId
						);
					LicenseOverview.add(lo);
				}
			insert LicenseOverview;
   		}
   	}
}

 

Hi,

 

I need to take a date field and update another date field to be the original date + 1 year.  And also take the day from the original date and make it the last day of the month.

 

Can I do this by workflow? Or do I need to write some APEX for it?

 

Thanks.

Trying to login through Force.com IDE.  Creating a new project yet I get invalid login no matter what I do.

 

Used security token and get "Unable to connect o hostname 'www.salesforce.com' with given login credentials'.


Didn't use security token and get the same.

 

But able to log into salesforce.com with the same username and password I am trying in the IDE.

 

I look at the login history and it says "Invalid Password" but again..using the same password in the IDE that I use to login.

 

I have tried my regular production account and my developer account.  Same thing.

 

Maybe something in my companies firewall is blocking a port?  Does the IDE use different ports than 80 and 443?  But if it was a Port issue why would the login history say "Invalid Password"?


Thanks for any help.

I have a text box under Opportunities.  I want to default the value of this based on record type.  Default value might be the account name.

 

What would be the ideal approach for this?  Trigger?  Workflow?  etc..  Since the record isn't saved yet and this should default off of what the Record Type was, I am trying to come up with the best solution.  

 

The default values will be values from the account object...90% of the time simply being the account name.  Account name will populated because I am forcing Opportunites to be created from the Account record.

 

Thanks.

Hi.  Somewhat off-topic question.


Does anyone know what software, if any and not homegrown, force.com uses for their HTML documentation?


Thanks.

https://sites.secure.force.com/answers/ideaView?c=09a30000000D9y3AAC&id=087300000007cXPAAY

 

It was suggested I ask this question here.  You can review the link above for the question I asked in Answers.

 


Here is a copy of the question:

 

 Don't know if I need to write a VisualForce page to do this or if possible through formula's (or another way).

I have a custom object that has a master detail relationship to Cases.  Shows up as a related list on the Cases.  I also want the related list on Contacts (and possibly Accounts).  I don't want the user to have to search for the contact in a lookup field, because the contact is already tied to the case.

Any good examples on how to do this or best practice on how to do this?
 
Thanks! 

 

Hi,

I am trying to pass a parameter to sforce.apex.execute.  If I use a static value it works fine.  But I am trying to pass a javascript variable as the parameter. 

In the code below it is named location.  I then use  {address:location} but it does not pass the variable.  When I view the HTML source it has {address:location} not {address:what the location should be}

Any help is greatly appreciated.

Code:
<html>
<head>
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/12.0/connection.js"></script>
<script src="/soap/ajax/12.0/apex.js"></script>
<script>
sforce.debug.trace=true;

function testApex() {
alert("Start");

var location = "{!Account.BillingStreet}, {!Account.BillingCity} {!Account.BillingState}";
alert(location);
var result = sforce.apex.execute("XmlStreamReaderDemo", "XmlStreamReaderD", {address:location});
alert(result);

}

</script>

</head>
<body onload=testApex();> 

 

I am trying to made tabbedCases (like the example tabbedAccounts).  Here is the code:

Code:
<apex:page standardController="Case" showHeader="true" tabStyle="case" >
    <style> 
    .activeTab {background-color: #B7A752; color:white; background-image:none} 
    .inactiveTab { background-color: lightgrey; color:black; background-image:none} 
    </style>
   <apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel"  tabClass="activeTab" inactiveTabClass="inactiveTab">
      <apex:tab label="Detail" name="CaseDetails" id="tabdetails">
         <apex:detail relatedList="true" title="true"/>
      </apex:tab>
      <apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct">
         <apex:relatedList subject="{!case}" list="OpenActivities" />
      </apex:tab>
         <apex:tab label="Activity History" name="ActivityHistory" id="tabActHis">
      <apex:relatedList subject="{!case}" list="ActivityHistories" />
      </apex:tab>
         <apex:tab label="Case Comments" name="CaseComments" id="tabCaseComments">
      <apex:relatedList subject="{!case}" list="CaseComments" />
      </apex:tab>
   </apex:tabPanel>
</apex:page>

 
I get the error: 'CaseComments' is not a valid child relationship name for entity Case.  This looks to be the correct name according to the WSDL.

Any thoughts?


Message Edited by billgreenhaw on 07-14-2008 02:18 PM
Hi.  According to the API documentation there is a CampaignShare object.  I have looked at three different Org's and I do not see this object.  I have changed security to be private and done some sharing..still do not see it.

Does this object exist?  If so how is it enabled?


Thanks!

Hi,

 

First time really diving into APEX from scratch. Before I just took other code and did made changes.

 

I am trying to insert a record using a trigger when Opportunity is Won.  Getting an error on linke 13. Just some advice to get me in the right direction would be greatly appreciated.

 

Trigger OpportunityCloseWon_Products on Opportunity (after update) {
	//
	List<License_Overview__c> LicenseOverview = new List<License_Overview__c>();
   	for ( Opportunity o : trigger.New )
   	{
   		if ( o.isWon )
   		{
			OpportunityLineItem[] o3 = [Select o.Licensee__c, o.OpportunityId, o.Opportunity.AccountId from OpportunityLineItem o where OpportunityId = :o.Id and IsDeleted != TRUE limit 1];
				if (o3.size() > 0) {
					//if ( Trigger.isUpdate )
					//Remember to set Status = Active
					License_Overview__c lo = new License_Overview__c (
						Licensee__c = o3.Licensee__c,
						Opportunity__c = o3.OpportunityId,
						Status__c = 'Active',
						Account__c = o3.AccountId
						);
					LicenseOverview.add(lo);
				}
			insert LicenseOverview;
   		}
   	}
}

 

Trying to login through Force.com IDE.  Creating a new project yet I get invalid login no matter what I do.

 

Used security token and get "Unable to connect o hostname 'www.salesforce.com' with given login credentials'.


Didn't use security token and get the same.

 

But able to log into salesforce.com with the same username and password I am trying in the IDE.

 

I look at the login history and it says "Invalid Password" but again..using the same password in the IDE that I use to login.

 

I have tried my regular production account and my developer account.  Same thing.

 

Maybe something in my companies firewall is blocking a port?  Does the IDE use different ports than 80 and 443?  But if it was a Port issue why would the login history say "Invalid Password"?


Thanks for any help.

I have a text box under Opportunities.  I want to default the value of this based on record type.  Default value might be the account name.

 

What would be the ideal approach for this?  Trigger?  Workflow?  etc..  Since the record isn't saved yet and this should default off of what the Record Type was, I am trying to come up with the best solution.  

 

The default values will be values from the account object...90% of the time simply being the account name.  Account name will populated because I am forcing Opportunites to be created from the Account record.

 

Thanks.

Hi,

I need to add the field history from a custom object to a page, but am running into a lot of problems.  The related list displays with no problem when viewing the custom object through the salesforce custom object tab, but on my custom page it says that Histories is not a valid child relationship name for the entity.  I have checked the child relationships of my custom object and the History object that salesforce generates automatically when "Track Field History" is checked is listed with the name "Histories" as the child relationship name.  I have tried this on multiple custom objects (making them as simple as possible) and a relatedList on Histories just doesn't seem to be possible.  Has anyone been able to make this work?

-David