• Discuss with me
  • NEWBIE
  • 25 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 9
    Replies

Hi,

 

I have a date field called Issue Date & another date field Expiry date.

 

 

My req is that expiry date should be more than 1 year of issue date. 

 

I am writing the below validation rule..

 

DAY(Expiry_Date__c ) < 365

 

But i the validation not working correctly.

 

Thanks in advance.

 

 

  • May 07, 2013
  • Like
  • 0

Here is my code:  

 

global class CalculoPanjer implements Database.Batchable < sObject > {


    global final Date fechaal;
    global final string query;




    global Database.QueryLocator start(Database.BatchableContext BC) {


        return Database.getQueryLocator(query);
    }




    global void execute(Database.BatchableContext BC, List < sObject > scope) {
        List < Panjer__c > accns = new List < Panjer__c > ();

        double acom = 0;


        for(sObject s: scope) {

            Panjer__c a = (Panjer__c) s;
            if(a.Fecha_al__c == fechaal && a.n__c > 0) {


                    List < Cartera_por_Banda__c >
                    cpb = [SELECT j__c, vj__c, ej__c, uj__c
                        FROM Cartera_por_Banda__c
                        WHERE Fecha_al__c = : a.Fecha_al__c and j__c <= : a.n__c
                        ORDER BY j__c ];

            

                double acomAn = 0;





                for( Cartera_por_Banda__c c : cpb) {

                  List <Panjer__c>
                        cpb2 = [SELECT An__c
                            FROM Panjer__c
                            WHERE Fecha_al__c = : a.Fecha_al__c and n__c <= : a.n__c - c.vj__c  ];

                    


                    for(  Panjer__c  c2 : cpb2) {

                        acomAn += (c.ej__c / a.n__c) * c2.An__c;
                    }


                }




                a.An__c = acomAn;




                acom += a.An__c;
                a.Acumulado__c = acom;




                accns.add(a);
            }
        }

        update accns;

    }




    global void finish(Database.BatchableContext BC) {

       
    }


}

 

 

I need to make a query per each of the upper level loops. With this code I am passing the governor limits. Maybe with Dynamic queries or Maps, but I have no idea of how to do it.

 

Can anyone help me to improve my code, solving the 200 query limit. I would relly appreciate it.

Hi All,

 

How to get current week records using soql query, I want to display this week records Sunday to Saturday created records. Help me please.

 

Thanks

Gopi

 

 

Hi,

 

I have a custom report which is based on 3 objects. I am not being able to see the DATA in the Portal. I am being able to see the data in the CRM. Obviously, the CRM and the Portal have different users. When I say DATA is not visible, I litreally mean the DATA as I am being able to see the headers and everything.

 

Obj 1 - OWD is Public Read/Write and Profile has Read Settings

Obj 2 - OWD is Public Read - Extended using Permission Sets

Obj 3 - OWD is Public Read - Extended using Permission Sets

 

I tried almost everything. Can anyone help with this?

 

Thanks in advance!

Regards,
Achilles
Certified Developer

I have written following Trigger on Opportunities. My idea is "Trigger has to insert a new record to 'Item' custom object' when the Stage is changed to 'Closed Won'".

 

No error is reporting but nothing is being inserted.

 

 

 

trigger WinningHandle on Opportunity (before update){    
Opportunity[] op=Trigger.new;
    for(Opportunity i:op) {
        if(i.StageName=='Closed Won'){
            String name='';
            String quant='0.00';
            String saleVal='0.00';
            Integer ix;
            List<Id> oppIds = new List<Id>();
            for(Opportunity o : op){
                if(i.id==o.Id){
                    oppIds.add(o.Id);
                    break;
                }                 
            }                             
            List<OpportunityLineItem> oppProds = [SELECT Id, PricebookEntry.Product2.Name, Quantity,UnitPrice  FROM OpportunityLineItem WHERE OpportunityId IN :oppIds];
            for(OpportunityLineItem opx :oppProds) {
            quant=opx.Quantity+'';
            saleVal=opx.UnitPrice+'';
            name=PricebookEntry.Product2.Name+'';
             
                }
            insert new item__c(Item_Name__c = name, Quantity__c = integer.valueof(quant), SaleValue__c = decimal.valueOf(saleVal));
        }                 
        }       
}

 

 

Hi,

 

I have a date field called Issue Date & another date field Expiry date.

 

 

My req is that expiry date should be more than 1 year of issue date. 

 

I am writing the below validation rule..

 

DAY(Expiry_Date__c ) < 365

 

But i the validation not working correctly.

 

Thanks in advance.

 

 

  • May 07, 2013
  • Like
  • 0

Hey Plz chk the Error i want to display the AggregateResult on my Visualforce page but it is generating Error " Invalid field Email for SObject AggregateResult" the code is given below

public with sharing class searchDuplicate {
   public   AggregateResult[] con{get;set;}
   
   public searchDuplicate()
   {
       find();
   }
    public void find(){
      con = [select Email from Contact group by Email having count(Email) > 1];
        System.debug(con);
    }
}

 and Visual Force code is

<apex:page controller="searchDuplicate">
    <apex:pageBlock title="Searching for Duplicate Contacts Record"> 
    </apex:pageBlock>
    <apex:pageBlock title="Contacts">
        <apex:dataTable value="{!con}" var="c" border="2" cellspacing="5" cellpadding="5">
            <apex:column headerValue="Email" value="{!c['Email']}" />
        </apex:dataTable>
    </apex:pageBlock>     
</apex:page>

 

I need to create an event whenever Opportunity field Probability is greater than 50%

 

I have written the code but it keeps firing on every update.I want it to fire on an insert or if there is any change in probability

 

My code is 

 

********************************

 

trigger AutoEventCreate on Opportunity (after insert , after update) {

List <Event> eventList = new List <Event> ();
Set<Id> oppIds = new Set<Id>();
for(Opportunity opp:Trigger.new){
if(opp.Id!=null &&(Trigger.isInsert || (Trigger.newMap.get(opp.id).Probability != Trigger.oldMap.get(opp.Id).Probability))){

oppIds.add(opp.Id);
}

}

for(Opportunity opp:Trigger.new){
if(opp.Probability !=null && opp.Probability>=25.00){

datetime myDate = datetime.now();



eventList.add (new Event(
Subject = 'Other',
WhatId = opp.Id,
OwnerId = opp.OwnerId,
StartDateTime = DateTime.Now(),
ActivityDateTime=null,
EndDateTime = DateTime.Now(),
DurationInMinutes = Integer.valueOf(Math.Floor( (myDate.getTime() - myDate.getTime()) / (1000.0*60.0)))

));

}
if(eventList.size() > 0)

insert eventList;

}

}

 

 

***************************

 

Can you please correct y code and let me know if any scenarios need to be added

 

Thanks in advance