• geeta
  • NEWBIE
  • 75 Points
  • Member since 2005

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 16
    Replies

I am new to apex code but have written a trigger that updates a custom revenue field on the opportunity and that works as desired until the opportunity being updated has a close date in the past.  This is due to a validation rule that does fires whenever the close date is less than today.  I see that this is a common issue by searching these boards, but I have not found a solution.  Is there way to writer the validation rule so that it does not fire if a particular field is being updated, or if the update is caused by the trigger?

 

With my limited knowledge, I cannot figure out a way around this error and subsequently no update by the trigger.  I'd really appreciate some ideas on how to manage this issue.  Thanks!

 

This is the validation rule:

 

AND(
OR (
ISPICKVAL(StageName ,"Job Dispatched"),
ISPICKVAL(StageName ,"Waiting for Approval"),
ISPICKVAL(StageName ,"Searching for sub"),
ISPICKVAL(StageName ,"Waiting for Approval"),
ISPICKVAL(StageName ,"Approval Received - Need Contractor"),
ISPICKVAL(StageName ,"Priority - Searching for Sub"),
ISPICKVAL(StageName ,"Proposal/Price Quote")),
CloseDate < TODAY(),
IF(OR(ISNEW(), ISNULL(Id)), if(ConnectionReceivedId =null, TRUE, FALSE),NOT(AND(ISCHANGED(ConnectionReceivedId), NOT(ConnectionReceivedId = null)))),



NOT(Contains($User.Alias, "pnet"))
)

 

 

Hello all,

 

I have the scenario where I'd like to have a constant value across all records in an object while being able to update that value frequently.

 

For instance, Let's say I have 3 records in Object A with a field called "value".

 

Record 1) Value:0;

Record 2) Value:5;

Record 3) Value:50;

 

Now, let's say I want a constant that scales all values in, say, a formula field, such that the values are from 0-100. So, constant = 2.0

 

Record 1) Scaled Value:0;

Record 2) Scaled Value:10;

Record 3) Scaled Value:100;

 

Now, imagine i added a fourth record

 

Record 4) Value:100;

 

And now the constant = 1.0;

 

Record 1) Scaled Value:0;

Record 2) Scaled Value:5;

Record 3) Scaled Value:50;

Record 3) Scaled Value:100;

 

What's the smoothest way to accomplish this? I thought I might be able to change a formula definition within an Apex trigger. Thinking that's not likely. Is there a way to define a field with a constant value. Again, I'd have to be able to change via an Apex trigger or scheduled code.

 

The only solution I have so far, is to just have lookup fields to another object (object b) that contains all the constants. Change the values in this second object's records and repeatedly check every record of object A  to ensure that it's always pointing to the right record in Object b. Of course, this seems to be quite awkward.

 

Are there any other possibilities that I'm missing?

 

 

Hello,

I would like to automate the creation of an Account when a Contact is created and the Account Name is left blank.  Do I need Visual Force for this or is an Apex trigger sufficient? Could someone put me in the right direction?

Thanks

Pierre 

Hi,

 

I have a Visualforce page that calls init() function at the page level like below:

<apex:page standardController="Volunteer_Activity__c" action="{!init}" title="Volunteer Activity: {!Volunteer_Activity__c.Name}" extensions="VolActivityMassSignUpControllerExt">

 

In my controller init() function when I try to get an attribute (Total_Number_of_Participants__c) of the Volunteer_Activity object, I get a null. Here is how my controller class looks like:

 

public class VolActivityMassSignUpControllerExt {

   private Volunteer_Activity__c va;

  

   public VolActivityMassSignUpControllerExt(ApexPages.StandardController stdController) {        this.va = (Volunteer_Activity__c) stdController.getRecord();

 

      System.debug(Logginglevel.DEBUG, 'Constructor ' + va.Id);

   }

 

   public void init() {

      id = va.Id;

      name = va.Name;

 

 

      Double totalParticipants = va.Total_Number_of_Participants__c; 

      ---

      ---

   }

 

To resolve this, I am explicitly doing a query to retrieve the object. Did anyone experience this issue? Can you please help?

 

Thanks,
Geeta

  • February 24, 2009
  • Like
  • 0
Hi,
 
I am trying to build a custom related list on the Account detail page which basically merges the data from two relationships and displays in this one related list. However, I have some UI rendering issues.
 
1. The border on the custom related list appears thicker than the standard related list. Can we control this behaviour?
2. Since I am adding the related list below the Account detail section, I see the 'Back to Top' and 'Always show me more records per related list' links between the detail section and the custom related list. Is there a way to hide these links or move them to the bottom of the page?
3. If I set the relatedList attribute on apex:detail to false and selectively add the related lists, then the issue I stated above in #2 is solved, but I lose the Related List hovers on top of the page. Is there a way to add these hovers?
 
Appreciate your help.
 
Code:
<apex:page standardController="Account" extensions="myControllerExtension">      
    <apex:detail relatedList="true" >
    <!--apex:relatedList list="Contacts" subject="{!account}"></apex:relatedList>
    <apex:relatedList list="ActivityHistories" subject="{!account}"></apex:relatedList>
    <apex:relatedList list="NotesAndAttachments" subject="{!account}"></apex:relatedList -->

    <apex:pageBlock title="Related Firms"  helpTitle="Related Firms Help" helpUrl="">
        <apex:pageBlockButtons location="top">
           <apex:form ><apex:commandButton action="{!createNewRelationship}" value="New" /></apex:form>
        </apex:pageBlockButtons>
        <apex:variable var="baseId" value="{!Url}" />       
        
        <apex:pageBlockTable value="{!RelatedFirms}" var="item">
            <apex:column headerValue="Action"> <apex:outputLink value="/{!item.id}/e—retURL=%2F{!baseId}" id="editLink"><b>Edit</b></apex:outputLink> | <apex:outputLink value="/setup/own/deleteredirect.jsp–delID={!item.id}&retURL=%2F{!baseId}" id="delLink"><b>Del</b></apex:outputLink></apex:column>
            <apex:column headerValue="Related Firm"> <apex:outputLink value="/{!item.id}">{!item.name}</apex:outputLink> </apex:column> 
            <apex:column headerValue="Relationship Type"> &nbsp; </apex:column>
        </apex:pageBlockTable> 

    </apex:pageBlock>
    </apex:detail>
</apex:page>

 
  • June 10, 2008
  • Like
  • 0
Hi,
 
Is there an API to access the User's Email Settings and Email2Case Routing Addresses? I am using s-controls and Apex code. Is it possible to retrieve this information from s-controls or Apex?
 
 
  • November 25, 2007
  • Like
  • 0
Hi,
 
As per the Apex documentation, I am trying to use the setDocumentAttachments method in the SingleEmailMessage class. But, I am getting a compilation error "Method does not exist or incorrect signature". Here is the code:
Attachment[] attachment = [Select Id from Attachment where ParentId =:solId]; 
if(attachment.size() > 0) { 
    ID[] attchmentId = new ID[attachment.size()]; 
    //attchmentId.size() = attachment.size(); 
    for(Integer g=0; g<attachment.size(); g++) 
                attchmentId[g] = attachment[g].Id; 
                        
      mail.setDocumentAttachments(attchmentId); 
                             
 }
Can anyone please help?
  • November 14, 2007
  • Like
  • 0
Hi,
 
I am having an issue with s-control. I am developing a custom UI using s-control. This s-control is launched from a custom list button. This s-control doesn't have any code related to the standard salesforce tabs or the side navbar. On click of edit button in the s-control I am calling the standard salesforce edit URL. I used window.location to set the new URL. This opens the edit page with 2 sets of tabs and nav bars. But, when I return back from the edit page the UI is fine. I tried several options but none worked. Appreciate if you can help me resolve this issue.
  • November 12, 2007
  • Like
  • 0
I want to filter Leads/Opportunities that are set as read-only at the user profile level from the select query. Is it possible? I am currently exporting data via salesforce webservice api (ver 8.0)  into a spreadsheet, which the users can later import into salesforce after editing the required values in the spreadsheet.
When I query for Leads/Opportunities, I also get read-only records. However, I do not want users to update the records that are set as read only for them. Please provide a solution for this?
  • June 12, 2007
  • Like
  • 0
I am working on some customizations for a SalesForce.com customer. In this application, the lead owner id is set to a queue id. I want to retrieve the list of users within this queue, so that I can check if the current logged-in user belongs to this queue or not. Is there an API to do this? Please help.
  • August 26, 2005
  • Like
  • 0

Hello,

I've seen many related posts, but nothing that has pushed me over the top for this problem.  Basically, I need a Lead trigger that can cause a Lead record to be run through the Lead Assignment rules if certain criteria are met on update of the Lead record.

 

One of the criteria is whether the current Lead Owner is an active or inactive SFDC user.  I had written the code to capture the owner status field via a SOQL select statement, but unfortunately this logic causes the apparently common mistake of having too many SOQL queries because the select statement was inside the For loop in the trigger code.

 

Based on the other posts for that error, I know that I'll need to use Sets and Maps to get it to work, but has anyone written a similar trigger before?

 

Basically, I need to capture the value of the isActive flag on the user record that corresponds to the Lead owner for each Lead being evaluated by the trigger.

 

Any help is appreciated.

 

Hi,

 

I've a problem with my Batch-Apex.

 

I want to send out Information through a callout. But this Information must send after and after. So I create two Batchjobs (because of two diffrent SOQL and parser-functions) and want to start them in a row.

 

Batch1

- do it´s work

- at finish-functions start Batch2

 

So I started them and ..... Limit Exception. Cannot start a Batch from a Batch.

How can I solve the problem ? I don´t want to write a while-statment and wait till the first job is done to do the next. It is possible to start the second Batch from the first one ? (I don´t want to schedule, or is this the alternative solution for the problem ?)

 

thanks

 

  • June 04, 2010
  • Like
  • 0

The documentation says this could be a dealock or a timeout.

 

Is there any way to get more info and find out which it is, timeout or deadlock?

 

Is there any way to find out what object had the locking problem?

 

I'm inserting into Opportunity and then OpportunityLineItem.  I would like to try and find out what the problem is.  Is a parent record locked?  Is it just timing out?  I would not think that any other process is trying to update the record I just inserted.

 

I am new to apex code but have written a trigger that updates a custom revenue field on the opportunity and that works as desired until the opportunity being updated has a close date in the past.  This is due to a validation rule that does fires whenever the close date is less than today.  I see that this is a common issue by searching these boards, but I have not found a solution.  Is there way to writer the validation rule so that it does not fire if a particular field is being updated, or if the update is caused by the trigger?

 

With my limited knowledge, I cannot figure out a way around this error and subsequently no update by the trigger.  I'd really appreciate some ideas on how to manage this issue.  Thanks!

 

This is the validation rule:

 

AND(
OR (
ISPICKVAL(StageName ,"Job Dispatched"),
ISPICKVAL(StageName ,"Waiting for Approval"),
ISPICKVAL(StageName ,"Searching for sub"),
ISPICKVAL(StageName ,"Waiting for Approval"),
ISPICKVAL(StageName ,"Approval Received - Need Contractor"),
ISPICKVAL(StageName ,"Priority - Searching for Sub"),
ISPICKVAL(StageName ,"Proposal/Price Quote")),
CloseDate < TODAY(),
IF(OR(ISNEW(), ISNULL(Id)), if(ConnectionReceivedId =null, TRUE, FALSE),NOT(AND(ISCHANGED(ConnectionReceivedId), NOT(ConnectionReceivedId = null)))),



NOT(Contains($User.Alias, "pnet"))
)

 

 

Hello all,

 

I have the scenario where I'd like to have a constant value across all records in an object while being able to update that value frequently.

 

For instance, Let's say I have 3 records in Object A with a field called "value".

 

Record 1) Value:0;

Record 2) Value:5;

Record 3) Value:50;

 

Now, let's say I want a constant that scales all values in, say, a formula field, such that the values are from 0-100. So, constant = 2.0

 

Record 1) Scaled Value:0;

Record 2) Scaled Value:10;

Record 3) Scaled Value:100;

 

Now, imagine i added a fourth record

 

Record 4) Value:100;

 

And now the constant = 1.0;

 

Record 1) Scaled Value:0;

Record 2) Scaled Value:5;

Record 3) Scaled Value:50;

Record 3) Scaled Value:100;

 

What's the smoothest way to accomplish this? I thought I might be able to change a formula definition within an Apex trigger. Thinking that's not likely. Is there a way to define a field with a constant value. Again, I'd have to be able to change via an Apex trigger or scheduled code.

 

The only solution I have so far, is to just have lookup fields to another object (object b) that contains all the constants. Change the values in this second object's records and repeatedly check every record of object A  to ensure that it's always pointing to the right record in Object b. Of course, this seems to be quite awkward.

 

Are there any other possibilities that I'm missing?

 

 

will a custom component controller 's constructor get called even if the "Rendered" expression evaluates to "false"? Below is a visual force page that has two components. Only one of them is rendered depending on the user's Profile name:

 

<apex:page showHeader="true" sidebar="false" controller="SiteHeaderController" action="{!init}">
<apex:form >
User Profile:{!userProfile}<br/>
<apex:outputText value="SL Component" rendered="{!userProfile='Leader'}"/><br/>
<apex:outputText value="ZoneDiv Component" rendered="{!OR(userProfile='Division Manager',userProfile='Zone Manager')}"/><br/>
<apex:commandLink value="{!$Label.Earning_Opportunity}" action="{!showEarningOpportunity}" rerender="earningOpportunity" rendered="{!userProfile='Leader'}"/>
<apex:outputPanel id="earningOpportunity">
   	<apex:outputPanel rendered="{!showEarningOppty}">
    	<c:SalesLeaderEarningOpportunity rendered="{!userProfile='Leader'}"/>
    	<c:ZoneDivEarningOpportunity rendered="{!OR(userProfile='Division Manager',userProfile='Avon Zone Manager')}"/>
   	</apex:outputPanel>
</apex:outputPanel>                
</apex:form>

</apex:page>

 

ShowEarningOpportunity method is below:

 

public PageReference showEarningOpportunity(){
	this.showEarningOppty=true;
	return null;
}

 

 

When I executed the page and click on the "command link", both constructors are getting called. Am I missing something?

 

Hello,

I would like to automate the creation of an Account when a Contact is created and the Account Name is left blank.  Do I need Visual Force for this or is an Apex trigger sufficient? Could someone put me in the right direction?

Thanks

Pierre 

Hi,

 

I have a Visualforce page that calls init() function at the page level like below:

<apex:page standardController="Volunteer_Activity__c" action="{!init}" title="Volunteer Activity: {!Volunteer_Activity__c.Name}" extensions="VolActivityMassSignUpControllerExt">

 

In my controller init() function when I try to get an attribute (Total_Number_of_Participants__c) of the Volunteer_Activity object, I get a null. Here is how my controller class looks like:

 

public class VolActivityMassSignUpControllerExt {

   private Volunteer_Activity__c va;

  

   public VolActivityMassSignUpControllerExt(ApexPages.StandardController stdController) {        this.va = (Volunteer_Activity__c) stdController.getRecord();

 

      System.debug(Logginglevel.DEBUG, 'Constructor ' + va.Id);

   }

 

   public void init() {

      id = va.Id;

      name = va.Name;

 

 

      Double totalParticipants = va.Total_Number_of_Participants__c; 

      ---

      ---

   }

 

To resolve this, I am explicitly doing a query to retrieve the object. Did anyone experience this issue? Can you please help?

 

Thanks,
Geeta

  • February 24, 2009
  • Like
  • 0
Hi,
 
I am trying to build a custom related list on the Account detail page which basically merges the data from two relationships and displays in this one related list. However, I have some UI rendering issues.
 
1. The border on the custom related list appears thicker than the standard related list. Can we control this behaviour?
2. Since I am adding the related list below the Account detail section, I see the 'Back to Top' and 'Always show me more records per related list' links between the detail section and the custom related list. Is there a way to hide these links or move them to the bottom of the page?
3. If I set the relatedList attribute on apex:detail to false and selectively add the related lists, then the issue I stated above in #2 is solved, but I lose the Related List hovers on top of the page. Is there a way to add these hovers?
 
Appreciate your help.
 
Code:
<apex:page standardController="Account" extensions="myControllerExtension">      
    <apex:detail relatedList="true" >
    <!--apex:relatedList list="Contacts" subject="{!account}"></apex:relatedList>
    <apex:relatedList list="ActivityHistories" subject="{!account}"></apex:relatedList>
    <apex:relatedList list="NotesAndAttachments" subject="{!account}"></apex:relatedList -->

    <apex:pageBlock title="Related Firms"  helpTitle="Related Firms Help" helpUrl="">
        <apex:pageBlockButtons location="top">
           <apex:form ><apex:commandButton action="{!createNewRelationship}" value="New" /></apex:form>
        </apex:pageBlockButtons>
        <apex:variable var="baseId" value="{!Url}" />       
        
        <apex:pageBlockTable value="{!RelatedFirms}" var="item">
            <apex:column headerValue="Action"> <apex:outputLink value="/{!item.id}/e—retURL=%2F{!baseId}" id="editLink"><b>Edit</b></apex:outputLink> | <apex:outputLink value="/setup/own/deleteredirect.jsp–delID={!item.id}&retURL=%2F{!baseId}" id="delLink"><b>Del</b></apex:outputLink></apex:column>
            <apex:column headerValue="Related Firm"> <apex:outputLink value="/{!item.id}">{!item.name}</apex:outputLink> </apex:column> 
            <apex:column headerValue="Relationship Type"> &nbsp; </apex:column>
        </apex:pageBlockTable> 

    </apex:pageBlock>
    </apex:detail>
</apex:page>

 
  • June 10, 2008
  • Like
  • 0
Hi,
 
As per the Apex documentation, I am trying to use the setDocumentAttachments method in the SingleEmailMessage class. But, I am getting a compilation error "Method does not exist or incorrect signature". Here is the code:
Attachment[] attachment = [Select Id from Attachment where ParentId =:solId]; 
if(attachment.size() > 0) { 
    ID[] attchmentId = new ID[attachment.size()]; 
    //attchmentId.size() = attachment.size(); 
    for(Integer g=0; g<attachment.size(); g++) 
                attchmentId[g] = attachment[g].Id; 
                        
      mail.setDocumentAttachments(attchmentId); 
                             
 }
Can anyone please help?
  • November 14, 2007
  • Like
  • 0
Hi,
 
I am having an issue with s-control. I am developing a custom UI using s-control. This s-control is launched from a custom list button. This s-control doesn't have any code related to the standard salesforce tabs or the side navbar. On click of edit button in the s-control I am calling the standard salesforce edit URL. I used window.location to set the new URL. This opens the edit page with 2 sets of tabs and nav bars. But, when I return back from the edit page the UI is fine. I tried several options but none worked. Appreciate if you can help me resolve this issue.
  • November 12, 2007
  • Like
  • 0
Hi,

I'd like to be able to use Visualforce to create custom related lists on standard objects (particular Account/Contact/Lead).  The use case here is to have related-list-like functionality when no direct relationship exists in the data model - for example, let's say I've got a { Contact : Object } relationship, and I want to aggregate this up into the Account View.  Some sort of materialized view functionality would also satisfy my needs, but no such functionality exists and Apex Triggers cannot be used to maintain materialized views due to trigger execution limits.

Back to my question about using Visualforce - Having read the Visualforce Developer's Guide & the Force.com cookbook, I get the sense this is not in fact possible.  I could use an s-control snippet to get to roughly the same place (create an iframe whose content is sourced from a Visualforce page) but it would be preferable to embed the code within the standard page, rather than using s-controls.

At an even more general level, it appears that Visualforce can't be used to customize standard pages at all. Is that also correct?

Just making sure I'm not missing anything.

thanks,
john

  • September 20, 2007
  • Like
  • 0