• Brabas
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 4
    Replies

Greetings.

I have a custom object with a trigger after insert type, this object is called Policy__c once saved you must create a new custom object, Cetificate__c, the problem is that the trigger executes, but not created Certificate__c.

trigger applyCertificadosTrigger on Policy__c (after insert) {
   Policy__c[] policies = Trigger.new;
   createCert.applyCert(policies);

} 


public class createCert{


public static void applyCert(Policy__c[] policies ) {
 integer  cont=0;
 integer sip=policies.size(); 
 
   for (cont=0; cont<sip; cont++ ){
 
       Certificate__c cert= new Certificate__c(
                                        Comission__c=30.00,
                                        Description__c='123456'

                                             );
    insert cert;

}
 
}

}

 thanks.....

 

I tried the code Imutsav, not throw exceptions, I can' t  just insert the certificate, perform a test with the example http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_qs_trigger.htm
for object Policy__c, this worked, just not inserted.  I wish to attach the certificate in the policy.

 

thanks....

 

  • April 08, 2013
  • Like
  • 0

I have a page that generates a receipt number depending on the type of payment selected.

 

<apex:page  standardcontroller="Policy__c" extensions="policyControllerIntA,RecordPolicy"  ">

<apex:form id="Policy">

        <apex:pageBlock >       
<apex:pageBlockSection>
  
  <div class="wrap3_1"> 
 <div class="wrap3">  
        <apex:pageblockSection columns="3">
            <apex:actionRegion >
                <apex:dynamicComponent componentValue="{!Section_3}"/>    
            </apex:actionRegion>  
                <apex:dynamicComponent componentValue="{!AddFile}"/>        
        </apex:pageblockSection>       
    </div>   

<apex:define name="wrap">
     <div class="wrap5">  
      <apex:actionRegion >  
        <apex:pageblockSection title="Recibos" id="paystubs" >
            <apex:dynamicComponent componentValue="{!Section_5}"/>
        </apex:pageblockSection>  
     </apex:actionRegion>          
    </div>        
 </apex:define>

</apex:pageBlockSection> 
        </apex:pageBlock>
</apex:form> 
 
</apex:page>

 extensions:

 

public with sharing class policyControllerIntA {
    public policyControllerIntA (ApexPages.StandardController con) { }

public Component.Apex.pageBlockSection  getSection_3(){


        Component.Apex.pageBlockSection s_three=new Component.Apex.pageBlockSection ();
        s_three.id='secthree';     
        s_three.collapsible=false;
        s_three.columns=4;

Component.Apex.SelectList fPayments= new Component.Apex.SelectList( multiselect = false, size = 1 );                  
       fPayments.expressions.value='{!fPayment}';
       fPayments.id='fPayments';
       fPayments.title='Forma de pago';
      
       
      Component.Apex.SelectOption so_Type_Payment= new Component.Apex.SelectOption();
      so_Type_Payment.itemLabel = 'Forma de Pago';
      so_Type_Payment.itemValue  = 'Forma de pago';
      
      
      Component.Apex.SelectOption so_Type_Payment1= new Component.Apex.SelectOption();
      so_Type_Payment1.itemLabel = 'Anual';
      so_Type_Payment1.itemValue  = 'Anual';      

      
      Component.Apex.SelectOption so_Type_Payment2= new Component.Apex.SelectOption();
      so_Type_Payment2.itemLabel = 'Semestral';
      so_Type_Payment2.itemValue = 'Semestral'; 
      
      Component.Apex.SelectOption so_Type_Payment3= new Component.Apex.SelectOption();
      so_Type_Payment3.itemLabel = 'Trimestral';
      so_Type_Payment3.itemValue = 'Trimestral';  
      
      Component.Apex.SelectOption so_Type_Payment4= new Component.Apex.SelectOption();
      so_Type_Payment4.itemLabel = 'Mensual';
      so_Type_Payment4.itemValue = 'Mensual';      
      
      
      Component.apex.actionSupport redPaystubs=new Component.apex.actionSupport();
      redPaystubs.event='onchange';
      Set<String> s1 = new Set<String>{'paystubs','fPayments'};
      redPaystubs.rerender=s1;
       
     
       
     if (fPayment=='Anual'||fPayment=='Semestral'||fPayment=='Trimestral'||fPaymentList=='Mensual'){       
       fPayments.childcomponents.add(so_Type_Payment1);       
       fPayments.childcomponents.add(so_Type_Payment2);       
       fPayments.childcomponents.add(so_Type_Payment3);
       fPayments.childcomponents.add(so_Type_Payment4);  
       fPayments.childcomponents.add(redPaystubs);  
    }else{
       fPayments.childcomponents.add(so_Type_Payment);
       fPayments.childcomponents.add(so_Type_Payment1);       
       fPayments.childcomponents.add(so_Type_Payment2);       
       fPayments.childcomponents.add(so_Type_Payment3);
       fPayments.childcomponents.add(so_Type_Payment4);  
       fPayments.childcomponents.add(redPaystubs);
    }

    s_three.childcomponents.add(niCompany);
    s_three.childcomponents.add(PDescription);
    s_three.childcomponents.add(fPayments);
  


return  s_three;

  }


public Component.Apex.pageBlockSection  getSection_5(){
integer asingNums;
integer Months;
        Component.Apex.pageBlockSection s_five=new Component.Apex.pageBlockSection ();
        s_five.id='sectfive';     
        s_five.collapsible=false;
        s_five.columns=12;
        
  
 
if (fPayment=='Anual'){Months=1;}
if (fPayment=='Semestral'){Months=2;}
if (fPayment=='Trimestral'){Months=4;}
if (fPayment=='Mensual'){Months=12;}

for(integer cont=0; cont<Months;cont++){
  Component.Apex.outputLabel nPaystub=new Component.Apex.outputLabel();
 
if(Months==1 || Months==2){
  nPaystub.value=cont + 1;
              if(cont==0){nPaystub.value=1;asingNums=1;}
                if(Months==2){ 
                              if(cont==0){nPaystub.value=1;asingNums=1;}
                              if(cont==1){nPaystub.value=2;asingNums=2;}
                                }

  }
else{
   if(Months==4 ){ 
              if(cont==0){nPaystub.value=1;asingNums=1;}
              if(cont==3){nPaystub.value=4;asingNums=4;}
              if(cont==1){nPaystub.value=3;asingNums=3;}
              if(cont==2){nPaystub.value=2;asingNums=2;}
            }
                else
                {
                   if(Months==12){
                                 if(cont==0){nPaystub.value=1;asingNums=1;}
                                 if(cont==11){nPaystub.value=12;asingNums=12;}
                                 if(cont==1){nPaystub.value=7;asingNums=7;}
                                 if(cont==2){nPaystub.value=2;asingNums=2;}
                                 if(cont==3){nPaystub.value=8;asingNums=8;}
                                 if(cont==4){nPaystub.value=3;asingNums=3;}
                                 if(cont==5){nPaystub.value=9;asingNums=9;}
                                 if(cont==6){nPaystub.value=4;asingNums=4;}
                                 if(cont==7){nPaystub.value=10;asingNums=10;}
                                 if(cont==8){nPaystub.value=5;asingNums=5;}
                                 if(cont==9){nPaystub.value=11;asingNums=11;}
                                 if(cont==10){nPaystub.value=6;asingNums=6;}
                               }                
                   } 
  }

 /*Component.Apex.inputTextarea....
 Component.Apex.inputTextarea....
 Component.Apex.inputTextarea....*/

return  s_five;

  } 

 and 

public with sharing class RecordPolicy{
    public RecordPolicy(ApexPages.StandardController con) { }

/************************* policy****************************/
 /*Public  String namecustomer{get; set;}
.
.
.*/
 Public  String fPayment{get; set;}
/*.
.  
 Public  Decimal pcommission{get; set;} */ 


 public integer  getnumPay(String fPayment){
  if (fPayment=='Forma de Pago'){return numberPay=1;}//----->
  if (fPayment=='Anual'||fPayment=='ANUAL'){return numberPay=1;}
  if (fPayment=='Semestral'||fPayment=='SEMESTRAL'){return numberPay=2;}
  if (fPayment=='Trimestral'||fPayment=='TRIMESTRAL'){return numberPay=4;}
  if (fPayment=='Mensual'||fPayment=='MENSUAL'){return numberPay=12;}
  return numberPay;
 }


Public PageReference save(){ 
/*
Policy__c p =new Policy__c (
*
*
fPayment__c=fPayment,
*
);

insert p;
parserId(p)
 
*
*/
createPaystub();
//
//
}


public void createPaystub() {
//
//

numPay=getnumPay(fPayment)
//
//

}

fPayment is a figure that interests me Policy__c saved, but it is still necessary for the rerender attribute on another extension. I need to access the contents of fPayment from policyControllerIntA.

Thanks

 

  • March 12, 2013
  • Like
  • 0

Greetings

 

I have a problem with Dynamic Components, How I can generate id's for Component.Apex.commandButton contained in Component.Apex.column?

 
 Component.Apex.pageBlockTable tblContacs= new Component.Apex.pageBlockTable();
        tblContacs.value=topContacs;
        tblContacs.var='itemC'; 
        tblContacs.columns=5;
        
        tblContacs.id='tblContact'; 
       
        tblContacs.title='Contacts';
        tblContacs.Style='width:680px'; 

 

public void  getpageColumnBtnUpdate(Component.Apex.pageBlockTable vTable , String tipeTable){


 Component.Apex.column save= new Component.Apex.column();
        
        save.title='update';
        save.width='60px';                    
           
          
Component.Apex.commandButton btnSave= new Component.Apex.commandButton ();
   
                
       string S=btnSave.expressions.value='{!itemC.Id}' ;   
      
       //btnSave.id= ' '; here must be the ID of the contact
        
        btnSave.action="{!quickSave}";
        btnSave.expressions.title=S;       
        btnSave.style='display:none;';
    
 

  save.childComponents.add(btnSave);
  
    
vTable.childComponents.add(save);
 

}

 Thanks,

 

  • November 30, 2012
  • Like
  • 0

Hello,

 

I was wondering if there is any equivalent string function that can used similar to the char(Ascii) function which exists in java? ejp. char(39) = ' in Ascii

 Component.Apex.inputText it_dEPolicy=new Component.Apex.inputText ();

it_dEPolicy.onmouseover='initialiseCalendar(this,'+char(39)+'{!$Component.dEPolicy}'+char(39)+')';

 

Thanks!

  • November 16, 2012
  • Like
  • 0

 

 

Greetings, I have a problem with Dynamic Components, I display a datepicker I have a function in JavaScript, the code works correctly tagged apex, the problem is to want to call the same function from a Dynamic Component.

 

function initialiseCalendar(obj, eleId) 
{
 var element=document.getElementById(eleId);
 var params='close=true' ;
 if (null!=element)
 {
  if (element.value.length>0)
  {
   // date is formatted dd/mm/yyyy - pull out the month and year
   var day=element.value.substr(0,2);
   var month=element.value.substr(3,2);
   var year=element.value.substr(6,4);
   params+=',day='+day;
   params+=',month='+month;
   params+=',year='+year;
  }
 }
 fnInitCalendar(obj, eleId, params);
}

 

 

 <apex:inputText id="dEPolicy" size="10" maxlength="10" value="{!dEPolicy}" onmouseover="initialiseCalendar(this, '{!$Component.dEPolicy}')"/> 

 

 

Component.Apex.inputText it_dSPolicy=new Component.Apex.inputText ();
                               it_dSPolicy.label='Date Start:';
                               it_dSPolicy.value=o.dSPolicy__c;
                               it_dSPolicy.expressions.value='{!dSPolicy}';
                               it_dSPolicy.id='dSPolicy';                             
                               it_dSPolicy.onmouseover='initialiseCalendar(this,"{!$Component.dSPolicy}")';

 

Greetings, I have a problem with Dynamic Components, I display a datepicker I have a function in JavaScript, the code works correctly tagged apex, the problem is to want to call the same function from a Dynamic Component.

Executing code from a controller, but the datepicker is displayed when clicking on nothing happens. The problem is this call, do not check errors here but not executed properly.

 

 it_dSPolicy.onmouseover='initialiseCalendar(this,"{!$Component.dSPolicy}")';

otherwise mark this Error.

 it_dSPolicy.onmouseover='initialiseCalendar(this,'{!$Component.dSPolicy}')';

 

 

thanks.

  • November 15, 2012
  • Like
  • 0

Hi, 

 

 

I have two custom objects, Customer and Policy, with the following relationship:
Master-Detail (Customer), both with their forms, inserting or save the Customer,

the application redirects to the form Policy . I want each insert has a Policy that

Customer identifier. How I can do this?

 

 

public class Record{

Public String Person{get; set;}
Public String lastName{get; set;}
Public String firstName{get; set;}
Public String RFC{get; set;}
Public String Direcction{get; set;}
Public String City{get; set;}
Public String CP{get; set;}
Public String Email{get; set;}
Public String Cell{get; set;}
Public String Phone{get; set;}
Public Date bDay{get; set;}
/*********************************/
Public PageReference save(){ 

Customer__c c =new Customer__c (
Person__c= Person,
firstName__c= firstName,
lastName__c= lastName, 
RFC__c= RFC,
Direcction__c=Direcction,
City__c=City,
CP__c=CP,
Email__c=Email,
Cell__c=Cell,
Phone__c=Phone,
bDay__c=bDay 

);

/***************************/

insert c;
PageReference newPage;
newPage = Page.catchPolicy( );
return newPage.setRedirect(true);

} 

/******************************/
}



/*******************************/

public class RecordPolicy{


Public String npolicy{get; set;}
Public String Certificate{get; set;}
Public String Company{get; set;}
Public String descPolicy{get; set;}
Public Date dSPolicy{get; set;}
Public Date dEPolicy{get; set;}
Public String fPayment{get; set;}

/**********************/
Public PageReference save(){


Policy__c p =new Policy__c (
npolicy__c= npolicy,
Certificate__c= Certificate,
Company__c= Company,
descPolicy__c= descPolicy,
dSPolicy__c=dSPolicy,
dEPolicy__c=dEPolicy,
fPayment__c=fPayment
);

/***********************/

insert p;



PageReference newPage;
newPage = Page.capturaPolizas;
return newPage.setRedirect(false);

}
/******************************/
}

 Thank you!

  • September 26, 2012
  • Like
  • 0

Greetings.

I have a custom object with a trigger after insert type, this object is called Policy__c once saved you must create a new custom object, Cetificate__c, the problem is that the trigger executes, but not created Certificate__c.

trigger applyCertificadosTrigger on Policy__c (after insert) {
   Policy__c[] policies = Trigger.new;
   createCert.applyCert(policies);

} 


public class createCert{


public static void applyCert(Policy__c[] policies ) {
 integer  cont=0;
 integer sip=policies.size(); 
 
   for (cont=0; cont<sip; cont++ ){
 
       Certificate__c cert= new Certificate__c(
                                        Comission__c=30.00,
                                        Description__c='123456'

                                             );
    insert cert;

}
 
}

}

 thanks.....

 

I tried the code Imutsav, not throw exceptions, I can' t  just insert the certificate, perform a test with the example http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_qs_trigger.htm
for object Policy__c, this worked, just not inserted.  I wish to attach the certificate in the policy.

 

thanks....

 

  • April 08, 2013
  • Like
  • 0

Hello,

 

I was wondering if there is any equivalent string function that can used similar to the char(Ascii) function which exists in java? ejp. char(39) = ' in Ascii

 Component.Apex.inputText it_dEPolicy=new Component.Apex.inputText ();

it_dEPolicy.onmouseover='initialiseCalendar(this,'+char(39)+'{!$Component.dEPolicy}'+char(39)+')';

 

Thanks!

  • November 16, 2012
  • Like
  • 0

Hi, 

 

 

I have two custom objects, Customer and Policy, with the following relationship:
Master-Detail (Customer), both with their forms, inserting or save the Customer,

the application redirects to the form Policy . I want each insert has a Policy that

Customer identifier. How I can do this?

 

 

public class Record{

Public String Person{get; set;}
Public String lastName{get; set;}
Public String firstName{get; set;}
Public String RFC{get; set;}
Public String Direcction{get; set;}
Public String City{get; set;}
Public String CP{get; set;}
Public String Email{get; set;}
Public String Cell{get; set;}
Public String Phone{get; set;}
Public Date bDay{get; set;}
/*********************************/
Public PageReference save(){ 

Customer__c c =new Customer__c (
Person__c= Person,
firstName__c= firstName,
lastName__c= lastName, 
RFC__c= RFC,
Direcction__c=Direcction,
City__c=City,
CP__c=CP,
Email__c=Email,
Cell__c=Cell,
Phone__c=Phone,
bDay__c=bDay 

);

/***************************/

insert c;
PageReference newPage;
newPage = Page.catchPolicy( );
return newPage.setRedirect(true);

} 

/******************************/
}



/*******************************/

public class RecordPolicy{


Public String npolicy{get; set;}
Public String Certificate{get; set;}
Public String Company{get; set;}
Public String descPolicy{get; set;}
Public Date dSPolicy{get; set;}
Public Date dEPolicy{get; set;}
Public String fPayment{get; set;}

/**********************/
Public PageReference save(){


Policy__c p =new Policy__c (
npolicy__c= npolicy,
Certificate__c= Certificate,
Company__c= Company,
descPolicy__c= descPolicy,
dSPolicy__c=dSPolicy,
dEPolicy__c=dEPolicy,
fPayment__c=fPayment
);

/***********************/

insert p;



PageReference newPage;
newPage = Page.capturaPolizas;
return newPage.setRedirect(false);

}
/******************************/
}

 Thank you!

  • September 26, 2012
  • Like
  • 0