-
ChatterFeed
-
4Best Answers
-
7Likes Received
-
0Likes Given
-
92Questions
-
278Replies
Change a trigger in a managed package
Hello everyone!
I'm going to do my first managed package...But I have a situation!
One of my triggers has a RecordTypeId hard-coded (yes, I know I didn't have to do it, but I did....)
My question is, can I change the trigger once It is installed in the new Org, or It's going to fail forever and ever?!?!?
Thanks in advance!
-
- javierjies
- May 25, 2009
- Like
- 0
- Continue reading or reply
How to pass parameters to system.currentPagereference.getParameters().get() in Test Methods
Hi
I have written the below code in the controller.
public void init()
{
Bid=System.currentPageReference().getParameters().get('BilltoId');
Rid=System.currentPageReference().getParameters().get('ResellerId');
Coid=System.currentPageReference().getParameters().get('CopyId');
}
While writing test methods i am not able to pass the parameters.Its showing code does'nt have test coverage
Any help will be appreciated.
Thanks in advance.
-
- Sadmin
- August 14, 2008
- Like
- 0
- Continue reading or reply
Visualforce Page Links Fail When Critical Update Activated
DANGER! DANGER! DO NOT ACTIVATE!
This changes links for visualforce pages. <domain name>.visualforce.com replaces <domain name>.<instancename>.visual.force.com.
For whatever reason, this does not work with Visualforce tabs or with buttons that link to visualforce pages.
With the critical update deactivated, the link for visualforce tab is https://<domain name>.<instancename>.visual.force.com/apex/TimeEntryCalendar?sfdc.tabName=01r500000003bNn.
When the critical update is activated, the link for the visualforce tab is https://<domain name>.visualforce.com/apex/TimeEntryCalendar?sfdc.tabName=01r500000003bNn.
The problem is that clicking the "activated" link yields this:
<domain name>.visualforce.com’s server IP address could not be found.
In my case, it was a really big problem because the visualforce tab was the default home page. So activating the Critical Update essentially locked all of my users out of salesforce.com.
This also fails with a simple button link to a visual force page.
If you assign a url to a button or type the link in - /apex/TimeEntryCalendar for instance, it works fine when the update is deactivated.
But activate the update, and it fails on just the simple link.
Problem exists in both Classic and Lightning.
MAJOR SNAFU!
-
- Claiborne
- February 16, 2018
- Like
- 2
- Continue reading or reply
sObjectType.newSObject() with Quote Object
Account acct = (Account)Account.sObjectType.newSObject(null, true);
This one does not.
Quote newQuote = (Quote)Quote.sObjectType.newSObject(null, true);
Any ideas
-
- Claiborne
- December 30, 2016
- Like
- 0
- Continue reading or reply
Strict Pick List Values on Visualforce page
"Forewarned is forearmed."
-
- Claiborne
- September 16, 2016
- Like
- 0
- Continue reading or reply
Internal Server Error Problem Solved - Bad Picklist Value
By commenting out sections of the page, I finally narrowed the problem down to the display of a single field on the Visualforce page. The field is picklist that uses a global set of pick list values. In the code, the value of the pick list field was being set with a text string. The problem was that one of the text strings was mistyped (missing space between two words). Because global picklist values are "strict", the "internal server error" was being generated when the Visualforce page tried to render a pick list value that did not match one of the global pick list choices.
Once I corrected the spelling in the code, all is good.
It would help if there was a more meaningful message that "An internal server error has occurred." This was a simple problem that took me 2 hours plus time of the salesforce.com support team. I know that global pick lists are still in beta, but a meaningful message would have really helped.
-
- Claiborne
- September 16, 2016
- Like
- 0
- Continue reading or reply
Lost Access to Sandbox - Workbench Hack or Security Hole?
BTW, munge is a highly techical term defined here.
What I was able to do is log onto Workbench from my computer, edit my email address back to email@email.com. Once I confirmed the email address change, I tried to log in again to the sandbox. This time the verification code was sent to email@email.com. With the new verification code, I was able to log in without problem.
So . . .
- Will this hack work all the time? Or was it because the location of my Workbench was a web site that had previously accessed the sandbox? Or was it because the version of Workbench I used is pretty old, version 29.0.
- Is this a security hole? Why was I able to log in via Workbench without verification? Same questions as above.
Should I always use my mobile phone to receive the verification code? I do not think mobile phone numbers are munged.
-
- Claiborne
- May 11, 2016
- Like
- 0
- Continue reading or reply
Strange Behavior in for loop executing over a query
for (UserTerritory2Association uta : [ select User.AccountId, User.Account.Name, User.Account.Regional_Manager__c, Territory2.Name, Territory2.ParentTerritory2Id, Territory2.ParentTerritory2.Name from UserTerritory2Association where user.usertype = 'PowerPartner' and Territory2.ParentTerritory2Id != null]) { . . . }The code was developed in a full sandbox, and it executes without problem. And the test code works.
But when I deploy, all of the tests fail because of a failure in the class. The error is:
Stack Trace: null
So I shuffled the code to query the list outside of the loop. The new code is:
List<UserTerritory2Association> utaList1 = [ select User.AccountId, User.Account.Name, User.Account.Regional_Manager__c, Territory2.Name, Territory2.ParentTerritory2Id, Territory2.ParentTerritory2.Name from UserTerritory2Association where user.usertype = 'PowerPartner' and Territory2.ParentTerritory2Id != null]; for (UserTerritory2Association uta : utaList1) { . . . }This deploys fine.
Any ideas why the first one does not work.
Also, the query itself works fine in both the full sandbox and production.
-
- Claiborne
- March 09, 2016
- Like
- 0
- Continue reading or reply
Why am I a Newbie now?
-
- Claiborne
- October 23, 2015
- Like
- 0
- Continue reading or reply
Why is my status now a "newbie"?
And I can't reply to my own posts.
-
- Claiborne
- October 23, 2015
- Like
- 0
- Continue reading or reply
File Exporter Not Working -
apex dataloder failed to send requires to https://login.salesforce.com/u/api/17.0
The solution is simple, although somewhat hard to find.
Follow the steps here - https://help.salesforce.com/apex/HTViewSolution?urlname=HTTPS-Security-Certificate-Switch-from-SHA-1-to-SHA-256-hash-algorithms&language=en_US
It takes about 5 minutes.
-
- Claiborne
- September 07, 2015
- Like
- 0
- Continue reading or reply
Workbench Extension Disabled in Chrome
Can someone pay the $5 to register the Workbench extension that I have been using for the past 4 years and get it back.
-
- Claiborne
- June 16, 2014
- Like
- 0
- Continue reading or reply
API Access with Delegated Authorization on Professional Edition
We have AppExchange product that is Aloha-approved, so we have an api access token.
Up until now, we have required users to log-in to salesforce.com from our app. We apply the api token as part of the connection header. Theapi token allows users to use our app with all editions of salesforce.com, especially Professional Edition.
This is the code we use - php
$wsdl = "soapclient/partner.wsdl.xml";
if ($sandbox = "true") {
$wsdl = "soapclient/partnerSandbox.wsdl.xml";
}
// The List api token - required for PE and GE access
$apiToken = '<token provided by salesforce.com>';
// Establish client
$client = new SforcePartnerClient();
$client->createConnection($wsdl);
// Add api token to connection
$callOptionsHeader = new CallOptions($apiToken);
$client->setCallOptions($callOptionsHeader);
// Login to salesforce.com
try {
$loginResult = $client->login($login, $password.$token);
if ($loginResult->passwordExpired) {
$client = null;
}
}
catch (Exception $e) {
echo $e->getMessage();
$client = null;
}
}
And we have a client using our application who has Professional Edition, but also is using Delegated Authorization via PingIdentity.
When the user tries to log in to salesforce.com from our application, they use their SSO user name and password. This gets them a valid salesforce.com token from Ping, but no log-in to salesforce.com. This is, of course, an api-login.
If the system admin uses his salesforce.com account, it works fine.
So the question is, how do you pass an api token when a Professional Edition sso user is trying to log in as an api user?
The api token is in the header of the initial log in request to salesforce.com. What happens to it when salesforce.com forwards the request to a delegated authority? Does it go to the delegated authority? Does it come back? Does it stay with the salesforce.com login request for use the authorization is granted by the delegated authority? Or is it just lost?
-
- Claiborne
- April 18, 2014
- Like
- 1
- Continue reading or reply
Bug in Spring '14 - Will not process immediate="{!NOT(<variable>)}" in Command button tag
In the apex class used as the controller for the VF page I set a public Boolean variable called rightNow.
In the Visualforce page I have a command button <apex:commandButton value="Do It" action="{!doit}" immediate="{!NOT(rightNow)}" />. This has been working for several releases.
Click this button in Spring 14 generates an immediate system error.
If I do not use the "NOT" function it works fine.
This works - <apex:commandButton value="Do It" action="{!doit}" immediate="{!rightNow}" />
Adding another global variable notRightNow works as well
This works - <apex:commandButton value="Do It" action="{!doit}" immediate="{!notRightNow}" />
Please get this fixed.
-
- Claiborne
- February 11, 2014
- Like
- 0
- Continue reading or reply
Limiting Report Folder Access on Installed Packages
We have recently enabled Partner Portal access. We wanted to limit the reports that the Partners can access.
We thought we were doing this by enabling access levels for sharing report and dashboard folders. When I change access on Report folders on folders we have created, the access does change to reflect the changes. Querying the Folder object shows the new access definitions.
But this does not work for report folders created by installed packages. Although the changes can be made, the changes do no impact the access, and the the Access in the Folder records never changes from Public.
There is some mention in the documentation about setting folder access prior to installing the package, but installation occurred years before we implemented partners. There is no way to uninstall/reinstall the packages, because if would involve literally millions of records.
Any ideas ? Anyone ?
-
- Claiborne
- October 09, 2013
- Like
- 0
- Continue reading or reply
Detect a Required Field on an Inactive Tab
I have a VisualForce page with multiple tabs.
Each tab has <apex:inputField> tags were required=true. The fields are not required at the object level, only on the VisualForce page.
When the page invokes any action, the action will not execute unless all required fields on all tabs, even the ones that are inactive and not visible, are completed.
This is OK. I want to user to complete all information.
My problem is that I do not have a way to let the user know that the missing information in on an inactive tab.
Does anyone know how to determine which tabs have uncompleted required fields so that I can provide some indication to the user?
Ideally, I would like a way to change the tab indicator to show that data is complete on the tab or not.
I am guessing I need some sort of Javascript to cycle through the elements in each tab.
Thanks.
-
- Claiborne
- July 22, 2013
- Like
- 0
- Continue reading or reply
Developer Discount Code for Dreamforce '13?
Registration is open. Is there a code like there has been in the past?
-
- Claiborne
- May 23, 2013
- Like
- 0
- Continue reading or reply
<apex:outputfield> versus <apex:outputtext> in Summer '13
In further investigation, I have traced the problem to the following:
I retrieve the information on the opportunity and its current pricebook through this query:
o = [ Select o.Id, o.Name, o.Amount, CurrencyIsoCode, o.Pricebook2Id, o.PriceBook2.Name, (Select Id, OpportunityId, SortOrder, PricebookEntryId, PriceBookEntry.Product2Id, PriceBookEntry.Product2.Name, CurrencyIsoCode, Quantity, TotalPrice, UnitPrice, ListPrice, ServiceDate, HasRevenueSchedule, HasQuantitySchedule, Description, HasSchedule From OpportunityLineItems) From Opportunity o where id = : apexPages.currentPage().getParameters().get('id')];
This works fine.
The problem is that I was displaying the pricebook name on a VisualForce page with an <apex:outputField>.
Apparently there is a change in Summer '13.
In Spring '13, this works:
<apex:outputText label="Current Price Book" value="{!o.Pricebook2.Name}"/>
In Summer '13, the page fails to load with the error:
Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Currency ISO Code: invalid currency code: 000".
If I change the tag to an output text, i.e.:
<apex:outputText label="Current Price Book" value="{!o.Pricebook2.Name}"/>
Now there is no problem, and it works fine.
I just want to know why.
-
- Claiborne
- May 22, 2013
- Like
- 0
- Continue reading or reply
Different Test Class Behavior in Summer '13 Release
I have a custom object that is created to mirror the Product object whenever a new Product record is created. It fires via a trigger on the Product object.
In the Spring '13 release, with seeAllData=true, the mirror object is created without problem. With seeAllData=false, the mirror object is not created, I guess because the trigger is outside of the test space.
In the Summer '13 release, the mirror object is not created. Tests that used to work now fail because the mirror object does not exist.
I have a lot of tests that depend on this behavior.
Is this a bug or a new feature?
-
- Claiborne
- May 16, 2013
- Like
- 0
- Continue reading or reply
Developer Console Problem
I work in a org with FinancialForce and Glovia ERP installed, plus a lot of other code. There are literally hundreds of test classes.
When I select Tests, New Run, the web page typically will time out before all of the test classes are retrieved. Is there any way to limit the retrieved set before I start.
-
- Claiborne
- May 15, 2013
- Like
- 0
- Continue reading or reply
Deployment Problems
I created an apex class and a associated test class in the sandbox. The test class was hitting 96 percent of the code.
I created an outbound deployment set with just the two classes.
I tried to deploy to production. I got this errror - twice.
Failure Message: "Internal Salesforce Error: 1208510542-13565 (966319356) (966319356)", Failure Stack Trace: "null"
Failure Message: "Internal Salesforce Error: 634278088-15180 (966319356) (966319356)", Failure Stack Trace: "null"
At this point, I abandoned Deployment Sets, went back to the IDE, and it deployed without problem.
Why? Does anybody care?
-
- Claiborne
- March 27, 2013
- Like
- 0
- Continue reading or reply
Creating a Trigger on a User
I am trying to create a trigger that notifies an internal group when a Partner Portal user has been created.
The trigger works fine, but the test fails.
When I create a partner portal user, the resulting record has a usertype of "PowerPartner". This is the field I use in the trigger to determine if the user being created is a portal user.
But when I create the portal user in the unit test, the usertype is "PowerCustomerSuccess"
My work-around is to check for both usertype values, but this is wrong.
Can anyone explain this behavior.
-
- Claiborne
- March 15, 2013
- Like
- 0
- Continue reading or reply
Visualforce Page Links Fail When Critical Update Activated
DANGER! DANGER! DO NOT ACTIVATE!
This changes links for visualforce pages. <domain name>.visualforce.com replaces <domain name>.<instancename>.visual.force.com.
For whatever reason, this does not work with Visualforce tabs or with buttons that link to visualforce pages.
With the critical update deactivated, the link for visualforce tab is https://<domain name>.<instancename>.visual.force.com/apex/TimeEntryCalendar?sfdc.tabName=01r500000003bNn.
When the critical update is activated, the link for the visualforce tab is https://<domain name>.visualforce.com/apex/TimeEntryCalendar?sfdc.tabName=01r500000003bNn.
The problem is that clicking the "activated" link yields this:
<domain name>.visualforce.com’s server IP address could not be found.
In my case, it was a really big problem because the visualforce tab was the default home page. So activating the Critical Update essentially locked all of my users out of salesforce.com.
This also fails with a simple button link to a visual force page.
If you assign a url to a button or type the link in - /apex/TimeEntryCalendar for instance, it works fine when the update is deactivated.
But activate the update, and it fails on just the simple link.
Problem exists in both Classic and Lightning.
MAJOR SNAFU!
-
- Claiborne
- February 16, 2018
- Like
- 2
- Continue reading or reply
API Access with Delegated Authorization on Professional Edition
We have AppExchange product that is Aloha-approved, so we have an api access token.
Up until now, we have required users to log-in to salesforce.com from our app. We apply the api token as part of the connection header. Theapi token allows users to use our app with all editions of salesforce.com, especially Professional Edition.
This is the code we use - php
$wsdl = "soapclient/partner.wsdl.xml";
if ($sandbox = "true") {
$wsdl = "soapclient/partnerSandbox.wsdl.xml";
}
// The List api token - required for PE and GE access
$apiToken = '<token provided by salesforce.com>';
// Establish client
$client = new SforcePartnerClient();
$client->createConnection($wsdl);
// Add api token to connection
$callOptionsHeader = new CallOptions($apiToken);
$client->setCallOptions($callOptionsHeader);
// Login to salesforce.com
try {
$loginResult = $client->login($login, $password.$token);
if ($loginResult->passwordExpired) {
$client = null;
}
}
catch (Exception $e) {
echo $e->getMessage();
$client = null;
}
}
And we have a client using our application who has Professional Edition, but also is using Delegated Authorization via PingIdentity.
When the user tries to log in to salesforce.com from our application, they use their SSO user name and password. This gets them a valid salesforce.com token from Ping, but no log-in to salesforce.com. This is, of course, an api-login.
If the system admin uses his salesforce.com account, it works fine.
So the question is, how do you pass an api token when a Professional Edition sso user is trying to log in as an api user?
The api token is in the header of the initial log in request to salesforce.com. What happens to it when salesforce.com forwards the request to a delegated authority? Does it go to the delegated authority? Does it come back? Does it stay with the salesforce.com login request for use the authorization is granted by the delegated authority? Or is it just lost?
-
- Claiborne
- April 18, 2014
- Like
- 1
- Continue reading or reply
Data Schema Export
-
- Claiborne
- July 31, 2007
- Like
- 1
- Continue reading or reply
Different Functions All Firing on the Same Trigger
What if different Apex applications are using the same trigger to do different things? For instance, I "purchase" a de-duping service from company A, and then a lead qualifying service from company B, and then I have my own custom lead assignement tool. All are implemented as Apex code that triggers off the Lead.Save command before insert. I want to be sure that Deduping is done first, then qualifying, and then assignment.
How is order assigned to the different functions with the same trigger?
Is there a contention issue?
-
- Claiborne
- February 14, 2007
- Like
- 1
- Continue reading or reply
Partner Location vs. Enterprise Location and PHP
-
- Claiborne
- October 21, 2006
- Like
- 1
- Continue reading or reply
Salesforce ODBC Connector
Last Jannuary, I talked to OpenAccess, a developer of toolkits for developing ODBC connectors, about using their product to build a connector to Salesforce.com. Although I got a 30-day trial, developing the actual connector was beyond my skills.
Last week OpenAccess contacted me about a beta version of an ODBC connector for Salesforce.com. You can download the beta version at:
http://www.openaccesssoftware.com/support/SalesF-Files-Index.asp
The installlation requires that your computer have the Microsoft.Net framework runtime installed (obtainable from http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&displaylang=en).
Once you install everything (about 10 minutes), you can use the ODBC connector to link any ODBC-compliant app to your Salesforce database.
At present, there is no pricing or licensing cost on the web site. The beta license expires on September 27. Also, the ODBC connector only supports the SELECT statement, so no UPDATE or CREATE at the moment.
I testing it by creating an ODBC connection in Excel using the new salesforce ODBC connector as my source. I could then point/click to select from all the tables in my account, including custom objects.
Lots of possibilities here, but this is all the information I have. If you want more info, contact OpenAccess.
-
- Claiborne
- August 22, 2005
- Like
- 1
- Continue reading or reply
Visualforce Page Links Fail When Critical Update Activated
DANGER! DANGER! DO NOT ACTIVATE!
This changes links for visualforce pages. <domain name>.visualforce.com replaces <domain name>.<instancename>.visual.force.com.
For whatever reason, this does not work with Visualforce tabs or with buttons that link to visualforce pages.
With the critical update deactivated, the link for visualforce tab is https://<domain name>.<instancename>.visual.force.com/apex/TimeEntryCalendar?sfdc.tabName=01r500000003bNn.
When the critical update is activated, the link for the visualforce tab is https://<domain name>.visualforce.com/apex/TimeEntryCalendar?sfdc.tabName=01r500000003bNn.
The problem is that clicking the "activated" link yields this:
<domain name>.visualforce.com’s server IP address could not be found.
In my case, it was a really big problem because the visualforce tab was the default home page. So activating the Critical Update essentially locked all of my users out of salesforce.com.
This also fails with a simple button link to a visual force page.
If you assign a url to a button or type the link in - /apex/TimeEntryCalendar for instance, it works fine when the update is deactivated.
But activate the update, and it fails on just the simple link.
Problem exists in both Classic and Lightning.
MAJOR SNAFU!
- Claiborne
- February 16, 2018
- Like
- 2
- Continue reading or reply
sObjectType.newSObject() with Quote Object
Account acct = (Account)Account.sObjectType.newSObject(null, true);
This one does not.
Quote newQuote = (Quote)Quote.sObjectType.newSObject(null, true);
Any ideas
- Claiborne
- December 30, 2016
- Like
- 0
- Continue reading or reply
Strict Pick List Values on Visualforce page
"Forewarned is forearmed."
- Claiborne
- September 16, 2016
- Like
- 0
- Continue reading or reply
Strange Behavior in for loop executing over a query
for (UserTerritory2Association uta : [ select User.AccountId, User.Account.Name, User.Account.Regional_Manager__c, Territory2.Name, Territory2.ParentTerritory2Id, Territory2.ParentTerritory2.Name from UserTerritory2Association where user.usertype = 'PowerPartner' and Territory2.ParentTerritory2Id != null]) { . . . }The code was developed in a full sandbox, and it executes without problem. And the test code works.
But when I deploy, all of the tests fail because of a failure in the class. The error is:
Stack Trace: null
So I shuffled the code to query the list outside of the loop. The new code is:
List<UserTerritory2Association> utaList1 = [ select User.AccountId, User.Account.Name, User.Account.Regional_Manager__c, Territory2.Name, Territory2.ParentTerritory2Id, Territory2.ParentTerritory2.Name from UserTerritory2Association where user.usertype = 'PowerPartner' and Territory2.ParentTerritory2Id != null]; for (UserTerritory2Association uta : utaList1) { . . . }This deploys fine.
Any ideas why the first one does not work.
Also, the query itself works fine in both the full sandbox and production.
- Claiborne
- March 09, 2016
- Like
- 0
- Continue reading or reply
How to show Full Calendar in salesforce Lightning ?
Am working on salesforce Lightning, I just wanted to show Full Calander in salesforce Lightning Component. Can someone please help in this regard.
Thanks & Regards,
Ruhulla
- Mohammad Ruhulla
- February 09, 2016
- Like
- 0
- Continue reading or reply
Disable "Create PDF" button on a quote
- RAJ PADMANABHAN 8
- November 06, 2015
- Like
- 0
- Continue reading or reply
what is the expected result of having more than one prechat.findOrCreate.map.doFind on a Live Agent Prechat form?
When I had only one doFind in my prechat form for accounts by account number, it would automatically open up a sub-tab within the Service Console and display the correct account when the customer gave us their number in the form. However, when I introduced my 2 additional doFinds (customers by email and cases by case number), I expected it to give me 3 separate sub-tabs, one for each match. One account subtab, one contact subtab, and one case subtab. Instead, I am just receiving one sub-tab called "Search Results" which displays one account that matched, one contact that matched, and one case that matched:
My user has to physically click on each of these 3 search results to open each in its own subtab.
I expected each of my 3 doFinds to open in its own tab since that was the result when my form had only one doFind. They are separate finds for different records so I figured it would work the same way - is this not the case? Is the functionality I am experiencing considered correct, or am I doing something wrong? My ideal solution would be that if the customer fills out all 3 fields, we get 3 subtabs within the Live Agent session in the console, specific to each record that we found that matched.
I hope this makes sense, please let me know if I can clarify any further.
Thanks!
- Morgan Marchese
- November 05, 2015
- Like
- 0
- Continue reading or reply
Automatic Asset Creation on Opportunity or Quote close
I an absolute Apex beginner and would like to solve a problem: Once an opportunity is closed won the products from that opportunity should automatically become assets for that customer. I know I need a trigger, a class and a test class. So in general my idea is as follows:
if opp stage = closed won
and if opp has products
for each product (opp-line item)
create asset
with account ID...
set asset name = product name
etc...
How can I solve this? Where could I find appropriate code samples? Any help is pretty welcome...
So thanks in advance...
best regards Thomas
- Thomas Panni
- February 16, 2015
- Like
- 0
- Continue reading or reply
How to make trigger bypass validation rules?
Let me briefly explain the trigger I wrote (my frist trigger actually). On the opportunity, we have a look-up field to other opportunities called 'Renewed Opportunity'. The idea is that when you create an opp that is a renewal, you use that field to reference the previous opportunity that is being renewed.
The trigger looks at the stage of the new renewal opp and updates a field on the referenced 'Renewed Opporunity' called 'Renewal Status'. The goal is to be able to see if an opp ended up renewing or not.
The issue here is that many of our older opportunities don't meet the validation rules we currently have in place. So if you populate that look-up field with an opp with missing data, you'll get an error message preventing you from updating the new, renewal opp you're creating.
Obviously, one solution would be to go back and update all our older opps, but that's practically impossible. So here is my question:
1) Is there something I can write in either the trigger or the validation rules to set up a bypass? For the validation rules, I tried writing in 'NOT(ISCHANGED(Renewal_Status__c))', but it seems that as long as a record is referenced, the validation rules will be required. The trigger doesn't even have to update the record.
2) If option 1 is not possible, is there a way to write an error message in the trigger that at least explains to the user in a clear manner that they have to update the referenced opp? I'd also like to list in the error the validation rules that must be met, but that would be a bonus.
In case you want to take a look at my trigger, here it is:
trigger RenewalProcess on Opportunity (after insert, after update) {
Set<String> allOpps = new Set<String>();
for(Opportunity renewalOpp : Trigger.new) {
if (renewalOpp.Renewed_Opportunity__c != null) {
allOpps.add(renewalOpp.Renewed_Opportunity__c);
}
}
List<Opportunity> potentialOpps = [SELECT Id FROM Opportunity WHERE Id IN :allOpps];
Map<String,Opportunity> opportunityMap = new Map<String,Opportunity>();
for (Opportunity o : potentialOpps) {
opportunityMap.put(o.id,o);
}
List<Opportunity> oppsToUpdate = new List<Opportunity>();
for (Opportunity renewalOpp : Trigger.new) {
if (renewalOpp.Renewed_Opportunity__c != null && renewalOpp.StageName.equals('Closed Won')) {
Opportunity renewedOpp = opportunityMap.get(renewalOpp.Renewed_Opportunity__c);
renewedOpp.Renewal_Status__c = 'Renewed';
oppsToUpdate.add(renewedOpp);
}
else if(renewalOpp.Renewed_Opportunity__c != null && !renewalOpp.IsClosed) {
Opportunity renewedOpp = opportunityMap.get(renewalOpp.Renewed_Opportunity__c);
renewedOpp.Renewal_Status__c = 'In Negotiations';
oppsToUpdate.add(renewedOpp);
}
else if(renewalOpp.Renewed_Opportunity__c != null && (renewalOpp.StageName.equals('Closed Lost') || renewalOpp.StageName.equals('Closed Stalled'))) {
Opportunity renewedOpp = opportunityMap.get(renewalOpp.Renewed_Opportunity__c);
renewedOpp.Renewal_Status__c = 'Did Not Renew';
oppsToUpdate.add(renewedOpp);
}
}
update oppsToUpdate;
}
Let me know if you need anymore info from me!
-Greg
- ChickenOrBeef
- February 11, 2014
- Like
- 0
- Continue reading or reply
Delete Apex class from production
Can anyone suggest, how ca we delete apex class from production.
please provide step-step process to delete it from prod. through Force.com Eclipse.
- Amul
- October 29, 2010
- Like
- 1
- Continue reading or reply
Moderators / VF experts - A bug with repeat/tabs? (full code to replicate inside)
I'm experiencing some unexpected behavior when trying to use the apex:repeat function to render tabs....
Basically it seems that tabs cannot be created on demand? My controller is definitely returning data... as the second page block in my sample will show... repeat works - just the tabs are not rendered..
I'm sure any of you guys can see where I was going with this - and I guess I can achieve a similar result by dropping down to boring old html - just trying to use the standard components (as per best practice)
Any assistance greatly appreciated - as the purist coder me is seriously disturbed at the moment...
here is my 'simplified' and easily testable page & controller
<apex:page controller="clsRecordType"> <apex:pageBlock > <apex:tabPanel id="theTabPanel"> <apex:tab label="Account Types"/> <apex:repeat value="{!RecordTypes}" var="types"> <apex:tab label="{!types.Name}"/> </apex:repeat> </apex:tabPanel> </apex:pageBlock> <apex:pageBlock > <apex:repeat value="{!RecordTypes}" var="types"> {!types.Name}<br/> </apex:repeat> </apex:pageBlock> </apex:page>
and the controller
public class clsRecordType { list<RecordType> lrecordtypes; public list<RecordType> getRecordTypes() { if(lrecordtypes==null) lrecordtypes = [Select Name, Id, Description From RecordType where SobjectType = 'Account' and IsActive=True]; return lrecordtypes; } }
- London Ben
- July 10, 2008
- Like
- 0
- Continue reading or reply
Default Address Field Lengths?
- Claiborne
- June 07, 2006
- Like
- 0
- Continue reading or reply