• Claiborne
  • NEWBIE
  • 185 Points
  • Member since 2004
  • Principal
  • The Claiborne Company


  • Chatter
    Feed
  • 4
    Best Answers
  • 7
    Likes Received
  • 0
    Likes Given
  • 92
    Questions
  • 277
    Replies

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!

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.
  • August 14, 2008
  • Like
  • 0
There is a new critical update called Remove Instance Names From URLs for Visualforce, Community Builder, Site.com Studio, and Content Files.

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:
 
This site can’t be reached
<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!
This statement works:
        Account acct = (Account)Account.sObjectType.newSObject(null, true);

This one does not. 
        Quote newQuote = (Quote)Quote.sObjectType.newSObject(null, true);

Any ideas
Just a warning - If you have try to display a Visualforce page that contains a pick list field with global picklist values or "strict" picklist values AND the value assigned to the field is NOT on the strict list, your page will throw an "An internal server error has occurred." Be careful what you type. 

"Forewarned is forearmed."
I had a piece of code that seemed to be working, but at times it would suddenly throw an "Internal Server Error" and shut my page down.

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.
I recently found myself locked out of my sandbox because I was on a new computer. When I tried to log into the sandbox, it was sending an email with the verification code to the email address munged when the sandbox was created, i.e., email=email.com@example.com. This munging was implemented a couple of years ago to prevent automated processes from sending reports, chatter feeds, approval requests, etc. from the sandbox to unsuspecting users.

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 . . .
  1. 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.
  2. Is this a security hole? Why was I able to log in via Workbench without verification? Same questions as above.
And regarding the original problem - losing sandbox access because of the munged email address - what can be done to prevent this?

Should I always use my mobile phone to receive the verification code? I do not think mobile phone numbers are munged.
I have an apex class that executes a for loop based on a query in the initialization class. The code is 
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:
 
line 30, column 50: Didn't understand relationship 'Account' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
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.
 

 
I have been on this forum since it started. I have asked and answered questions. My status used to be "Trusted Contributor". Now I am a newbie, and I can't respond to any questions. 
Something changed. I used to be a trusted contributor, being on this forum since it started. I have spoken with others who had thousands of points. They are now newbies. 

And I can't reply to my own posts.
On August 15, salesforce.com changed its security certificates on all production servers from ones signed with the SHA-1 hash algorithm to new certificates signed with the SHA-256 hash. THIS BREAKS FILE EXPORTER (and maybe some other api connections). You get a message like this:

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.
The latest release of Chrome disables ALL extensions that do not come from the Google Playstore. 

Can someone pay the $5 to register the Workbench extension that I have been using for the past 4 years and get it back.
Here is the problem.

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

function GetClient($login, $password, $token, $sandbox) {
           
             $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?
I have discovered a bug in the Spring 14 release in my sand box.

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.


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 ?

 

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.

 

 

Registration is open. Is there a code like there has been in the past? 

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.

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?

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.

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?

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.

There is a new critical update called Remove Instance Names From URLs for Visualforce, Community Builder, Site.com Studio, and Content Files.

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:
 
This site can’t be reached
<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!
Here is the problem.

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

function GetClient($login, $password, $token, $sandbox) {
           
             $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?
After some discussions with Mike Simonds, I created a quick AppExchange product that produces a SQL script that you can use to replicate your salesforce.com table structure in MySQL or Oracle.
 
Data Schema installs as a custom web link tab, and it works in a similar fashion to the wsdl export.
 
You can get the product from AppExchange at:
 
 
This is a "private" product for now, so it will not show up in searches.
 
Mike has expanded on the script, and, using ADODB.php, he has a php script that will go ahead and create the tables. For a discussion of this and other php and database topics for salesforce.com, go to:
 
 
Comments are always appreciated.

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?

The PHP Toolkit only works with the Partner WSDL. This means two things.
 
When you create a session, you have to make sure that you load the partner wsdl file.
 
But it also means that if you use an existing session Id from salesforce.com (like in a web tab or web link), the location has to be the PARTNER location, not the ENTERPRISE location.
 
Even though you use the partner wsdl, you can still access all the custom objects and custom fields by naming them explicitly.
 
I just spent two days tracking this down, with lots of help from Nick Tran at salesforce.com. I had mistakenly used the enterprise location versus the partner location.
 
Be sure with the PHP Toolkit, you always specify the partner location in any web links or web tabs.

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.

There is a new critical update called Remove Instance Names From URLs for Visualforce, Community Builder, Site.com Studio, and Content Files.

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:
 
This site can’t be reached
<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!
This statement works:
        Account acct = (Account)Account.sObjectType.newSObject(null, true);

This one does not. 
        Quote newQuote = (Quote)Quote.sObjectType.newSObject(null, true);

Any ideas
Just a warning - If you have try to display a Visualforce page that contains a pick list field with global picklist values or "strict" picklist values AND the value assigned to the field is NOT on the strict list, your page will throw an "An internal server error has occurred." Be careful what you type. 

"Forewarned is forearmed."
I have an apex class that executes a for loop based on a query in the initialization class. The code is 
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:
 
line 30, column 50: Didn't understand relationship 'Account' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
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.
 

 
Hi All,

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
I am trying to see if there is simpler way to disable the Create PDF button on a quote without having to create a new VF page and cutom controllers.  Create PDF button should be disabled based on field value in a quote, for example say the quote is in "Accepted" status then the Create PDF should be disabled OR other option is to display error message when the button is clicked indicating that the Create PDF function is not available when the quote is in "Accepted" status.
I have 3 different doFind's on my Pre-Chat form, one to find Accounts by Account Number (Auto Number field), one is to find customers by email field, and one is to find cases by case field.

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:

User-added image

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!
Hi out there,
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
Hey everyone,

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

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.

  • October 29, 2010
  • Like
  • 1
Hi guys,

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

Code: VF PAGE
<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

Code:
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;
        }
   }

 
 

In salesforce.com, several entities (contact, account, lead, etc.) have one or more "address" fields. When you look at the wsdl, you can see that the "address" is actually comprised of several fields - street1, street2, street3, city, state/province, postal code, and country.
 
The problem is that the wsdl does not tell you the maximum field lengths for the various components. During some importing, I have discovered that the city field can only be 40 characters.  Short of running a series of tests, can anyone provide the limits on the various fields that make up an address.
 
It is the sort of thing that should be published somewhere.