• Mikko4
  • NEWBIE
  • 55 Points
  • Member since 2008

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

Hello everyone!!

 

I've donde this Trigger:

 

trigger FacturacionAutomatica on Expediente__c (after update)
{
   
    Factura__c fac=new Factura__c();
    Tarifa__c tar1;
    for(Expediente__c exp:trigger.new)
    {
        tar1=[select Corresponde__c,Restar_Honorario__c,PSobre_Ingresos__c,Importe_Rango_Superior__c,
              Sobre_Ingresos_Superior_al_Rango__c,Abono_sobre_Facturado__c from Tarifa__c
              where Situacion__c=:exp.Situacion__c
              and Tipo_Demanda__c=:exp.Tipo_Demanda__c
              and Expediente_Cerrado__c=:exp.Cerrado__c
              and Cantidad_Hasta__c>=:exp.Reclamada__c
              and CantidadDesde__c<=:exp.Reclamada__c];         
        fac.Honorarios__c=tar1.Corresponde__c;
        fac.Expediente__c=exp.Id;
        fac.RecordTypeId='012300000003peBAAQ'; 
        insert fac;
    }
}

 

 

 

When I update Expediente__c I get this error message:

 

Error:Apex trigger FacturacionAutomatica caused an unexpected exception, contact your administrator: FacturacionAutomatica: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FacturacionAutomatica: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FacturacionAutomatica: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FacturacionAutomatica: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FacturacionAutomatica: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FacturacionAutomatica: execution of AfterUpdate caused by: System.Exception: Too many SOQL queries: 21 Trigger.FacturacionAutomatica: line 8, column 14 Trigger.FacturacionAutomatica: line 18, column 9 Trigger.FacturacionAutomatica: line 18, column 9 Trigger.FacturacionAutomatica: line 18, column 9 Trigger.FacturacionAutomatica: line 18, column 9: Trigger.FacturacionAutomatica: line 18, column 9

 

 

I don't understand why It doesn't work, because I've done similar Triggers and they run perfectly

 

so..any idea??

 

Thanks in advice!!

I used the example on http://wiki.developerforce.com/index.php/Extended_Functionality_of_Visualforce_-_Part_2 to make a VF page that has 2 picklists. one is dependent on the other. I bascally need to render the second picklist (trader) when i make a selection on the first one (acctName). My problem is that the acctNname picklist populates, but when i make a selection the other picklist (trader) does NOT populate aoccrdingly - it stays empty.

 

<apex:page standardController="Case" extensions="CaseExtension" standardStylesheets="true"> 

<apex:sectionHeader title="Request Information" subtitle="{!case.id}"></apex:sectionHeader>

<apex:form >

<apex:pageBlock title="Request Information" mode="edit">

<apex:outputLabel value="Account Name" for="acctName"></apex:outputLabel>

<apex:selectList id="acctName" value="{!acctName}" size="1">

<apex:actionSupport event="onchange" rerender="trader"/>

<apex:selectOptions value="{!Accts}"></apex:selectOptions>

</apex:selectList> 

<apex:pageBlockSectionItem >

<apex:outputLabel value="Trader ID" for="trader"></apex:outputLabel>

<apex:selectList id="trader" value="{!trader}" size="1" title="Trader ID" >

<apex:selectOptions value="{!Tids}"></apex:selectOptions>

</apex:selectList>

  

 

</apex:pageBlock> </apex:form>

</apex:page>

 

apex class:
-----------

public class CaseExtension {

private final Case u;

public CaseExtension(ApexPages.StandardController stdController) { this.u = (Case)stdController.getRecord(); }

String acctName;

String trader;

public String getacctName() { return acctName; }

public void setacctName(String s) {  this.acctname = s; }

public String gettrader() {  return trader; }

public void settrader(String s) {  this.trader = s; }

 

public List<selectOption> getAccts() {

List<selectOption> optionList = new List<selectOption>();

optionList.add(new selectOption('', '- None -'));  

for (Account a : [SELECT name FROM Account order by Name]) {  

optionList.add(new selectOption(a.Id, a.Name));  

}

return optionList;  

}

public List<selectOption> getTids() {

List<selectOption> optionList = new List<selectOption>();   

optionList.add(new selectOption('', '- None -')); 

for (Firm_Trader_ID__c r : [SELECT name FROM Firm_Trader_ID__c r WHERE r.Account__r.Name = :acctName]) { 

optionList.add(new selectOption(r.Id, r.Name));  

}

return optionList;

}

}

------

What am i missign here? help on this matter will be appreciated.

  • April 25, 2009
  • Like
  • 0

Hi!

 

You know that first inputField on the page gets focus on page load? So when the first inputField is a date field then the date picker annoyingly pops up automatically. Does anyone know a way to prevent this?

 

Thanks!

  • August 11, 2011
  • Like
  • 0

Hello,

 

Is it possible to have fixed pre-defined height for a pageBlock? I would like to add a Visualforce page to Home Page. Ideally the pageBlock element would always have same height and since the content of it is a table which can have 0-n rows the scrollbar would appear inside the pageBlock.

 

Thanks!

  • April 07, 2010
  • Like
  • 0

Hi,

 

I have used inputField element but the help text orange ball isn't appearing on the page. The custom field which is binded has help text defined. Could this be due to to that the inputField is in a pageBlockTable? Is there a way to include the helpText?

 

Thanks!

Hello,

 

I'm trying to create a Visualforce page to replace the standard opportunity tab landing page. I'd like to replicate the standard page but not to include the reports and tools sections. I've managed to build the page almost completely but few small details are missing:

 

-'Tell me more' and 'Help for this page' links on section header

-Edit and Create New View links

-Picklist on the right hand side which has options Recently Viewed, Recently Created and Recently Modified

-I have listed the records using pageBlockTable but I can't force the table to use all the possible horizontal space. I've tried to add width="100%" to pageBlockTable attributes

 

Thanks a lot if you can help with one or many of these!

Message Edited by Mikko4 on 04-27-2009 05:24 AM
  • April 27, 2009
  • Like
  • 0

Hello,

 

I'd like to enhance creation of one custom object by adding Visualforce functionality. Is it possible to take advantage of standard create mode layout by adding to the the page so that I wouldn't need to rewrite te whole page with all fields?

 

Or the question vice versa. is it possible to add Visualforce section to the standard create layout? 

 

Thanks!

  • February 04, 2009
  • Like
  • 0
Hi,
 
Does the API provide a service to find out the amount of remaining licenses using Apex?
 
Thanks!
  • December 01, 2008
  • Like
  • 0
Hi,
 
In formulas you can use ISCHANGED function. Is there a similar method in Apex or is there some recommended design pattern for checking if a field value has changed in after update event?
 
How about ISNEW function?
 
Thanks!
  • November 28, 2008
  • Like
  • 0

Hi!

 

You know that first inputField on the page gets focus on page load? So when the first inputField is a date field then the date picker annoyingly pops up automatically. Does anyone know a way to prevent this?

 

Thanks!

  • August 11, 2011
  • Like
  • 0

Hello Community-

 

I'm trying to build a threaded results textbox that auto posts the date and name of the person contributing. I need the results inside of an SFDC form.

 

My idea is to create 2 fields - one for adding a message and one for displaying the thread.  

Field 1 - long text - Type_Here__c

Field 2 - long text - Display_Here__c

 

Jim Smith logs in to the record and wants to comment.  He types "Hello World." in Type_Here__c

After saving the record, Display_Here__c looks like this:

 

7/1/2010 - Jim Smith - Hello World.

 

Next, Stacy Jones needs to add her info and types "Sounds good." in Type_Here__c

After saving the record, Display_Here__c should look like this:

 

7/2/2010 - Stacy Jones - Sounds good.

 

7/1/2010 - Jim Smith - Hello World.

 

For all subsequent messages, they must be typed in the "Type_Here__c" field and the "Display_Here__c" field is locked for editing.  Each new message is a prefix of the old messages with the name and date stamp.

 

I don't know code, so if as much syntactically correct code could be provided, I think I could tweak a little to make it work, but I'm terrible at inventing the new code necessary (I'm hunting for a programmer as we type).

 

Thanks in advance for any help!

 

Aaron

I have tried before insert and after insert triggers but i cannot seem to update the ownerId. During the trigger the ownerId gets set properly, as seen via the debug log, but when I look at the lead in SF it is still the default owner. Specificly these leads are being created via a web-to-lead form.

 

In either version (Before or After insert) I get the list of leads, find the proper ownerId and assign it to the lead. In my After Insert trigger i even printed to the log the owner Id before updating the leads and then again after updating the leads. The ownerId comes our correct in the log but still not in SF. Here is a stripped down version of my After Insert trigger

 

 

trigger Lead on Lead (after insert) { 
    ProtectionRules pr = new ProtectionRules();
    String prResult = 'not found';
 	
 	String countryCode;
 	
	Set<ID> ids = trigger.newmap.keyset();
	list<Lead> leads = [SELECT Id,Status,Downgrade_Date__c,Phone,indexedPhone__c,Email,indexedEmail__c,OwnerId,Owner_Manager_Email__c,Owner_Manager_Name__c,LeadSource,Lead_Score__c FROM Lead WHERE Id in :ids];
		 				
	for(Integer i=0; i<leads.size();i++){
		*Code to find OwnerId*
	    		
                leads[i].OwnerId = [SELECT id FROM User WHERE Team__c=:assignmentRule.TeamName__c AND Team_Member_Number__c=:teamMemberNumber].Id;
	    		

		system.debug('THIS IS LEAD.OWNERID AT THE END: ' + leads[i].OwnerId);
		
			
        }		
    

    system.debug('THIS IS THE LEAD OWNER BEFORE UPDATE: ' + [SELECT Id,OwnerId FROM Lead WHERE Id=:leads[0].Id].OwnerId);    	
	update leads;
	system.debug('THIS IS THE LEAD OWNER AFTER UPDATE: ' + [SELECT Id,OwnerId FROM Lead WHERE Id=:leads[0].Id].OwnerId);
}

 

 

 I realize those debug lines at the end will only show the first lead in the list. I am just testing one at a time.

 

What am I missing? I've been stuck on this for the last day or two and any help would be appreciated.

 

 

I created a custom setting say Department. It consists of a depeartment code and department name. Through manage link i created multiple instances to represent departments in my organization. Now when I retrieve all the values in this Custom setting using getAll.Values() , I would like to have them in a particular sorted order. Is there an efficient or a recommended way to sort values in custom settings? Please advice

Hello everyone!!

 

I have two triggers, the first one;

trigger DisparaHistoricoInmobiliario on Task (before insert, before update) {
 Integer i=0,j=0;
 for(Task T:trigger.new)
    {
        if(T.trigger__c==1)
        {
            for(Activo_Inmobiliario__c AI:[select trigger__c from Activo_Inmobiliario__c where Fecha_de_Venta__c=null or Fecha_de_Venta__c=YESTERDAY])
            {
                AI.trigger__c=1;
                AI.Fecha_Historico__c=SYSTEM.today()-1;
                update AI;
            }
        }
    }

}

 

 

 

and the second one:

trigger Actualizar_Lista_Sharing_ActInm on Activo_Inmobiliario__c (after update)
{
    for (Activo_Inmobiliario__c EmbargoNEW:trigger.new)
    {
        for (Activo_Inmobiliario__c embargoOLD:trigger.old)
        {
            for(Activo_Inmobiliario__Share aShare:[select RowCause,UserOrGroupId,AccessLevel from Activo_Inmobiliario__Share where ParentId=:EmbargoNEW.Id])
            {
                if(aShare.RowCause=='Manual')
                 {
                     aShare.AccessLevel='Read';
                     update aShare;
                 }
            }
            if(EmbargoNEW.Agente_Inmobiliario__c!=NULL)
            {
                Activo_Inmobiliario__Share aShareAI=[select RowCause,UserOrGroupId,AccessLevel from Activo_Inmobiliario__Share where ParentId=:EmbargoNEW.Id and UserOrGroupId=:EmbargoNEW.Agente_Inmobiliario__c];
                aShareAI.AccessLevel='Edit';
                 update aShareAI;
            }
        }
    }
}

 

 

 

 

OK! This is the problem;

 

When both of them are fired, I get this error message:

 

Apex script unhandled trigger exception by user/organization: 00580000001kVyW/00D80000000cPxj

DisparaHistoricoInmobiliario: execution of BeforeUpdate

caused by: System.DmlException: Update failed. First exception on row 0 with id a008000000D0QZmAAN; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Actualizar_Lista_Sharing_ActInm: execution of AfterUpdate

caused by: System.Exception: Too many SOQL queries: 21

Trigger.Actualizar_Lista_Sharing_ActInm: line 7, column 45: []

Trigger.DisparaHistoricoInmobiliario: line 11, column 17

 

 

 

 

 

I think It's because the first trigger should wait before each update, to let the second trigger to do his part!!

 

Is there any way to let them work in parallel?

 

Thanks in advance!!

Hello everyone!!

 

I've donde this Trigger:

 

trigger FacturacionAutomatica on Expediente__c (after update)
{
   
    Factura__c fac=new Factura__c();
    Tarifa__c tar1;
    for(Expediente__c exp:trigger.new)
    {
        tar1=[select Corresponde__c,Restar_Honorario__c,PSobre_Ingresos__c,Importe_Rango_Superior__c,
              Sobre_Ingresos_Superior_al_Rango__c,Abono_sobre_Facturado__c from Tarifa__c
              where Situacion__c=:exp.Situacion__c
              and Tipo_Demanda__c=:exp.Tipo_Demanda__c
              and Expediente_Cerrado__c=:exp.Cerrado__c
              and Cantidad_Hasta__c>=:exp.Reclamada__c
              and CantidadDesde__c<=:exp.Reclamada__c];         
        fac.Honorarios__c=tar1.Corresponde__c;
        fac.Expediente__c=exp.Id;
        fac.RecordTypeId='012300000003peBAAQ'; 
        insert fac;
    }
}

 

 

 

When I update Expediente__c I get this error message:

 

Error:Apex trigger FacturacionAutomatica caused an unexpected exception, contact your administrator: FacturacionAutomatica: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FacturacionAutomatica: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FacturacionAutomatica: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FacturacionAutomatica: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FacturacionAutomatica: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FacturacionAutomatica: execution of AfterUpdate caused by: System.Exception: Too many SOQL queries: 21 Trigger.FacturacionAutomatica: line 8, column 14 Trigger.FacturacionAutomatica: line 18, column 9 Trigger.FacturacionAutomatica: line 18, column 9 Trigger.FacturacionAutomatica: line 18, column 9 Trigger.FacturacionAutomatica: line 18, column 9: Trigger.FacturacionAutomatica: line 18, column 9

 

 

I don't understand why It doesn't work, because I've done similar Triggers and they run perfectly

 

so..any idea??

 

Thanks in advice!!

I'm  trying to display a value (pulled from a salesforce record by apex) on a VF page, and have it linked in the browser to a the standard salesforce edit page for the value.

 

The following does not work; I get to the edit page ok, but when I click save or cancel, I end up at the tab home page for the custom object. But no error.


How are urls with retUrl constructed?

 

 

// In the controller extension:

 

public String getexpenseRatioLink() { return StatisticalDatum.page( dataMap, 'expense ratio' ).getUrl() + '/e' + '?retUrl=' + ApexPages.currentPage().getUrl(); }

 

// In the VF page:

//

// <a href="{!expenseRatioLink}">{!expenseRatio}</a>
 

 

 

 

 

I used the example on http://wiki.developerforce.com/index.php/Extended_Functionality_of_Visualforce_-_Part_2 to make a VF page that has 2 picklists. one is dependent on the other. I bascally need to render the second picklist (trader) when i make a selection on the first one (acctName). My problem is that the acctNname picklist populates, but when i make a selection the other picklist (trader) does NOT populate aoccrdingly - it stays empty.

 

<apex:page standardController="Case" extensions="CaseExtension" standardStylesheets="true"> 

<apex:sectionHeader title="Request Information" subtitle="{!case.id}"></apex:sectionHeader>

<apex:form >

<apex:pageBlock title="Request Information" mode="edit">

<apex:outputLabel value="Account Name" for="acctName"></apex:outputLabel>

<apex:selectList id="acctName" value="{!acctName}" size="1">

<apex:actionSupport event="onchange" rerender="trader"/>

<apex:selectOptions value="{!Accts}"></apex:selectOptions>

</apex:selectList> 

<apex:pageBlockSectionItem >

<apex:outputLabel value="Trader ID" for="trader"></apex:outputLabel>

<apex:selectList id="trader" value="{!trader}" size="1" title="Trader ID" >

<apex:selectOptions value="{!Tids}"></apex:selectOptions>

</apex:selectList>

  

 

</apex:pageBlock> </apex:form>

</apex:page>

 

apex class:
-----------

public class CaseExtension {

private final Case u;

public CaseExtension(ApexPages.StandardController stdController) { this.u = (Case)stdController.getRecord(); }

String acctName;

String trader;

public String getacctName() { return acctName; }

public void setacctName(String s) {  this.acctname = s; }

public String gettrader() {  return trader; }

public void settrader(String s) {  this.trader = s; }

 

public List<selectOption> getAccts() {

List<selectOption> optionList = new List<selectOption>();

optionList.add(new selectOption('', '- None -'));  

for (Account a : [SELECT name FROM Account order by Name]) {  

optionList.add(new selectOption(a.Id, a.Name));  

}

return optionList;  

}

public List<selectOption> getTids() {

List<selectOption> optionList = new List<selectOption>();   

optionList.add(new selectOption('', '- None -')); 

for (Firm_Trader_ID__c r : [SELECT name FROM Firm_Trader_ID__c r WHERE r.Account__r.Name = :acctName]) { 

optionList.add(new selectOption(r.Id, r.Name));  

}

return optionList;

}

}

------

What am i missign here? help on this matter will be appreciated.

  • April 25, 2009
  • Like
  • 0

Hello,

 

I'd like to enhance creation of one custom object by adding Visualforce functionality. Is it possible to take advantage of standard create mode layout by adding to the the page so that I wouldn't need to rewrite te whole page with all fields?

 

Or the question vice versa. is it possible to add Visualforce section to the standard create layout? 

 

Thanks!

  • February 04, 2009
  • Like
  • 0
Hi,
 
In formulas you can use ISCHANGED function. Is there a similar method in Apex or is there some recommended design pattern for checking if a field value has changed in after update event?
 
How about ISNEW function?
 
Thanks!
  • November 28, 2008
  • Like
  • 0