• satyam
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 78
    Questions
  • 107
    Replies

Hi,

 

I am using custom button to select the record for some operation but i am getting below error:

 

A problem with the OnClick JavaScript for this button or link was encountered:

{faultcode:'soapenv:Client', faultstring:'A duplicate value was specified for field 'Ids__c' in object 'Student_Support_Ids__c', duplicate value 'a50E00000008Oxs' prior value 'a50E00000008Oxr'', }

 

Can anyone please help me out .

 

Below is my code:

 

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")};


var records={!GETRECORDIDS($ObjectType.student_Support__c )};

if(records[0]==null) {

alert("Please select atleast one record.");

} else {
var flag = false;


var psrecords=sforce.connection.retrieve("Id,Status__c,SAP_Transfer__c,Support_Type__c,Archieved__c","student_Support__c", [records])



for(var i=0; i<psrecords.length; i++){

var recordId =psrecords [i];
var Arch=recordId.Archieved__c;
if(Arch=='true')
{
flag = true;
alert("You Can not do Mass change for Archived student support!!");
break;
}else if(recordId.Status__c != 'Approved' &&Arch!='true'){
flag = true;
alert("Mass Change can be done only for Approved student Supports");
break;

}else if(recordId.Support_Type__c=='Rebate' && recordId.Status__c == 'Approved' && recordId.SAP_Transfer__c=='Open' &&Arch!='true'){
flag = true;
alert('Support # '+recordId.Support_ID__c+' is currently being transferred, therefore you cannot do a Mass Change now.');
break;
}
}
}

if( flag == false){
var insert_PSIDs = new sforce.SObject("student_Support_Ids__c");
alert(records);
insert_PSIDs.Ids__c = records;
var result = sforce.connection.create([insert_PSIDs]);
alert(result);
window.open("/apex/studentSupportMassChange?selectedRecords="+result[0].id);
}

 

Thanks in Advance :))))

Hi,

 

I am using custom button to select the record for some operation but i am getting below error:

 

A problem with the OnClick JavaScript for this button or link was encountered:

{faultcode:'soapenv:Client', faultstring:'A duplicate value was specified for field 'Ids__c' in object 'Student_Support_Ids__c', duplicate value 'a50E00000008Oxs' prior value 'a50E00000008Oxr'', }

 

Can anyone please help me out .

 

Below is my code:

 

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")};


var records={!GETRECORDIDS($ObjectType.student_Support__c )};

if(records[0]==null) {

alert("Please select atleast one record.");

} else {
var flag = false;


var psrecords=sforce.connection.retrieve("Id,Status__c,SAP_Transfer__c,Support_Type__c,Archieved__c","student_Support__c", [records])



for(var i=0; i<psrecords.length; i++){

var recordId =psrecords [i];
var Arch=recordId.Archieved__c;
if(Arch=='true')
{
flag = true;
alert("You Can not do Mass change for Archived student support!!");
break;
}else if(recordId.Status__c != 'Approved' &&Arch!='true'){
flag = true;
alert("Mass Change can be done only for Approved student Supports");
break;

}else if(recordId.Support_Type__c=='Rebate' && recordId.Status__c == 'Approved' && recordId.SAP_Transfer__c=='Open' &&Arch!='true'){
flag = true;
alert('Support # '+recordId.Support_ID__c+' is currently being transferred, therefore you cannot do a Mass Change now.');
break;
}
}
}

if( flag == false){
var insert_PSIDs = new sforce.SObject("student_Support_Ids__c");
alert(records);
insert_PSIDs.Ids__c = records;
var result = sforce.connection.create([insert_PSIDs]);
alert(result);
window.open("/apex/studentSupportMassChange?selectedRecords="+result[0].id);
}

 

Thanks in Advance :))))

Hi,

 

I want to pass selected record ids from custom list button to controller directly without passing through URL.

 

Because passing through URL giving error because IE URL can contain maxm 2047 characters and i have to use Internet explorer only for my work.

 

Can anyone please suggest any solution for this.I am redirecting to visualforce page and a controller is wriiten for that visualforce page.

 

Below is my custom button code:

 

    {!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")};


var records={!GETRECORDIDS($ObjectType.Area_Support__c )};

if(records[0]==null) {

alert("Please select atleast one record.");

} else {
var flag = false;


var psrecords=sforce.connection.retrieve("Id,Status__c,SAP_Transfer__c,Support_Type__c,Archieved__c","Area_Support__c", [records])



for(var i=0; i<psrecords.length; i++){

var recordId =psrecords [i];
var Arch=recordId.Archieved__c;
if(Arch=='true')
{
flag = true;
alert("You Can not do Mass change for Archived Area support!!");
break;
}else if(recordId.Status__c != 'Approved' &&Arch!='true'){
flag = true;
alert("Mass Change can be done only for Approved Area Supports");
break;

}else if(recordId.Support_Type__c=='Rebate' && recordId.Status__c == 'Approved' && recordId.SAP_Transfer__c=='Open' &&Arch!='true'){
flag = true;
alert('Support # '+recordId.Support_ID__c+' is currently being transferred to SAP, therefore you cannot do a Mass Change now.');
break;
}
}
}

if( flag == false){

//alert('Else');

window.open("/apex/AreaSupportMassChange?selectedRecords="+records);
}

 

Thanks in advance:)))

 

 

Hi,

 

I want to pass selected record ids from custom list button to controller directly without passing through URL.

 

Because passing through URL giving error because IE URL can contain maxm 2047 characters and i have to use Internet explorer only for my work.

 

Can anyone please suggest any solution for this.I am redirecting to visualforce page and a controller is wriiten for that visualforce page.

 

Below is my custom button code:

 

    {!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")};


var records={!GETRECORDIDS($ObjectType.Area_Support__c )};

if(records[0]==null) {

alert("Please select atleast one record.");

} else {
var flag = false;


var psrecords=sforce.connection.retrieve("Id,Status__c,SAP_Transfer__c,Support_Type__c,Archieved__c","Area_Support__c", [records])



for(var i=0; i<psrecords.length; i++){

var recordId =psrecords [i];
var Arch=recordId.Archieved__c;
if(Arch=='true')
{
flag = true;
alert("You Can not do Mass change for Archived Area support!!");
break;
}else if(recordId.Status__c != 'Approved' &&Arch!='true'){
flag = true;
alert("Mass Change can be done only for Approved Area Supports");
break;

}else if(recordId.Support_Type__c=='Rebate' && recordId.Status__c == 'Approved' && recordId.SAP_Transfer__c=='Open' &&Arch!='true'){
flag = true;
alert('Support # '+recordId.Support_ID__c+' is currently being transferred to SAP, therefore you cannot do a Mass Change now.');
break;
}
}
}

if( flag == false){

//alert('Else');

window.open("/apex/AreaSupportMassChange?selectedRecords="+records);
}

 

Thanks in advance:)))

 

 

Hi Everyone,

We have a requirement where we need to compare current Client support record with all the old client support record and that needs to be done before saving the record.

We need to compare near about 12 fields for every record which we are selecting during mass operation (can select 100 record for mass operation),but we are not having any field which can used as a key without saving the record.

We tried using map and list but we are getting exceptions ' Too many code statements: 200001' and as well as its making the process too time taking.

Please help to achieve this requirement .

 

Below is the method where we are getting issue:

 

public static Map<Client_support__c,List<String>> checkDuplicatePriceSupportforMassChangeone(List<Client_support__c> PSList){
                   
    List<String> duplicatesPS= new List<String>();    
    List<Client_support__c> OldPS=new List<Client_support__c>();
    oldPS =[select id,status__c,distributor_PRofile__c,Material_Selling__c,Material_Buying__c where status__c='Approved' or status__c='Awaiting distributor Approval' or status__c='Awaiting Nexeo Approval'];
    List <Client_support__c>l1 = new List<Client_support__c>();
    Map<Client_support__c,List<duplicate>> mapPS = new Map<Client_support__c,List<duplicate>>();
    List <String> l2=new List<String>();   
  for(Client_support__c ps:PSList){

    for(Client_support__c ps1:oldPS){

    if(ps.distributor_PRofile__c!=null){
        if(ps.distributor_PRofile__c == ps1.distributor_PRofile__c){
        l1.add(ps1);
    }
    }

    if(ps.Material_Selling__c!=null){
        for(Client_support__c li : L1){
       
            if(ps.Material_Selling__c == ps1.Material_Selling__c){
            //l1.add(li);
            l2.add(li.aggrement_number__c);
            }

        }
    }

   
    }
   
    mapPS.put(ps1 ,l2);

 }   

 

Thanks in advance:))))
                   
   

  • April 04, 2013
  • Like
  • 0

Hi Everyone,

We have a requirement where we need to compare current Client support record with all the old client support record and that needs to be done before saving the record.

We need to compare near about 12 fields for every record which we are selecting during mass operation (can select 100 record for mass operation),but we are not having any field which can used as a key without saving the record.

We tried using map and list but we are getting exceptions ' Too many code statements: 200001' and as well as its making the process too time taking.

Please help to achieve this requirement .

 

Below is the method where we are getting issue:

 

public static Map<Client_support__c,List<String>> checkDuplicatePriceSupportforMassChangeone(List<Client_support__c> PSList){
                   
    List<String> duplicatesPS= new List<String>();    
    List<Client_support__c> OldPS=new List<Client_support__c>();
    oldPS =[select id,status__c,distributor_PRofile__c,Material_Selling__c,Material_Buying__c where status__c='Approved' or status__c='Awaiting distributor Approval' or status__c='Awaiting Nexeo Approval'];
    List <Client_support__c>l1 = new List<Client_support__c>();
    Map<Client_support__c,List<duplicate>> mapPS = new Map<Client_support__c,List<duplicate>>();
    List <String> l2=new List<String>();   
  for(Client_support__c ps:PSList){

    for(Client_support__c ps1:oldPS){

    if(ps.distributor_PRofile__c!=null){
        if(ps.distributor_PRofile__c == ps1.distributor_PRofile__c){
        l1.add(ps1);
    }
    }

    if(ps.Material_Selling__c!=null){
        for(Client_support__c li : L1){
       
            if(ps.Material_Selling__c == ps1.Material_Selling__c){
            //l1.add(li);
            l2.add(li.aggrement_number__c);
            }

        }
    }

   
    }
   
    mapPS.put(ps1 ,l2);

 }   

 

Thanks in advance:))))
                   
   

  • April 04, 2013
  • Like
  • 0

Hi ,

 

I am getting too many SOQL problem ,can anyone please help to resolve,its very urgent.

 

i,

 

Please find my Custom Save code from where i am calling the method 'checkDuplicatestudentdatamasschange'

 

I am not able to recognize how i can create a Map for this checking purpose and this functionality is important for me.

 

Custom Save Method:

 

public void customSave(){


double actualDiscountOne = 0.0;
double actualDiscountTwo = 0.0;
double actualDiscountOneSelling = 0.0;
double actualDiscountTwoSelling = 0.0;
List<Student_Support__c> clonedStudentSupports =null;
if(!renewFlag){
clonedStudentSupports = StudentSupportUtil.cloneStudentSupports(objectName, selectedStudentSupports,StudentSupportUtil.CHANGE,expirationDate,effectiveDate);
}else{
clonedStudentSupports = StudentSupportUtil.cloneStudentSupports(objectName, selectedStudentSupports,StudentSupportUtil.RENEW,expirationDate,null);
}
List<Student_Support__c> updatedCloneList = new List<Student_Support__c>();
for(Student_Support__c studentObj1 : clonedStudentSupports){
SuppprofileIds.add(studentObj1.Student_Profile_ID__c);
}
System.debug('-----------StudentsupportsuppprofileId-------'+SuppprofileIds);
List<Seeker_Profile__c> SuppprofileeObjList =[select Round_Final_Support_to__c from Student_Profile__c where Id in:SuppprofileIds];

for (Integer k = 0; k < SuppprofileeObjList.size(); k++) {
SuppprofileIdRoundno.put(SuppprofileeObjList[k].id,SuppprofileeObjList[k].Round_Final_Support_to__c);
}
System.debug('-----------StudentsupportsuppprofileIdMap-------'+SuppprofileIdRoundno);


for(Student_Support__c studentObj : clonedStudentSupports){

if(studentObj.Support_Type__c==StudentSupportUtil.DEBATE){

if(studentObj.Flat_or_Purchased__c==StudentSupportUtil.FLAT && studentObj.Debate_Editable__c==true){

System.debug('----------FLAT Student Support------');
studentObj.Requested_Debate_Amount__c = nullCheck(studentObj.Requested_Debate_Amount__c) + nullCheck(increaseDebateAmountBy);

}else{

System.debug('------old Purchase Cost-------'+studentObj.Purchase_Cost__c);

System.debug('------Purchase cost Type-------'+purchaseCostType);

System.debug('-----purchaseCostChange-------'+purchaseCostChange);

if(purchaseCostType.equalsIgnoreCase('$')){
studentObj.Purchase_Cost__c = nullCheck(studentObj.Purchase_Cost__c) + nullCheck(purchaseCostChange);
}else if(purchaseCostType.equalsIgnoreCase('%')){
studentObj.Purchase_Cost__c = nullCheck(studentObj.Purchase_Cost__c)+(nullCheck(studentObj.Purchase_Cost__c)*nullCheck(purchaseCostChange));
}

System.debug('------Modified Purchase Cost-------'+studentObj.Purchase_Cost__c);

System.debug('------old Seeker_Supported_Student__c-------'+studentObj.Seeker_Supported_Student__c);

System.debug('------supportedStudentType-------'+supportedStudentType);

System.debug('-----seekerSupportedStudentChange-------'+seekerSupportedStudentChange);

if(supportedStudentType.equalsIgnoreCase('$')){
studentObj.Seeker_Supported_Student__c = nullCheck(studentObj.Seeker_Supported_Student__c) + nullCheck(seekerSupportedStudentChange);
}else if(supportedStudentType.equalsIgnoreCase('%')){
studentObj.Seeker_Supported_Student__c = nullCheck(studentObj.Seeker_Supported_Student__c)+(nullCheck(studentObj.Seeker_Supported_Student__c)*nullCheck(seekerSupportedStudentChange));
}

System.debug('------Modified supportedStudent-------'+studentObj.Seeker_Supported_Student__c);

if(studentObj.X1st_Discount_Type_Buy__c!=null && studentObj.X1st_Discount_Type_Buy__c.equalsIgnoreCase('%')){
actualDiscountOne=studentObj.Purchase_Cost__c*(nullCheck(studentObj.X1st_Discount_Buy__c)/100);
}else{
actualDiscountOne = studentObj.X1st_Discount_Buy__c;
}

if(studentObj.X2nd_Discount_Type_Buy__c!=null && studentObj.X2nd_Discount_Type_Buy__c.equalsIgnoreCase('%')){
actualDiscountTwo=studentObj.Purchase_Cost__c*(nullCheck(studentObj.X2nd_Discount_Buy__c)/100);
}else{
actualDiscountTwo = studentObj.X2nd_Discount_Buy__c;
}


if(studentObj.X1st_Discount_Type_Sell__c!=null && studentObj.X1st_Discount_Type_Sell__c.equalsIgnoreCase('%')){
actualDiscountOneSelling=studentObj.Seeker_Supported_Student__c*(nullCheck(studentObj.X1st_Discount_Sell__c)/100);
}else{
actualDiscountOneSelling = studentObj.X1st_Discount_Sell__c;
}

if(studentObj.X2nd_Discount_Type_Sell__c!=null && studentObj.X2nd_Discount_Type_Sell__c.equalsIgnoreCase('%')){
actualDiscountTwoSelling=studentObj.Seeker_Supported_Student__c*(nullCheck(studentObj.X2nd_Discount_Sell__c)/100);
}else{
actualDiscountTwoSelling = studentObj.X2nd_Discount_Sell__c;
}

studentObj.Net_Purchase_Cost__c = nullCheck(studentObj.Purchase_Cost__c)-nullCheck(actualDiscountOne)-nullCheck(actualDiscountTwo)+nullCheck(studentObj.Freight_Allowance_Buying__c)+nullCheck(studentObj.Other__c);

String Roundsupport1=nullChecknew(SuppprofileIdRoundno.get(studentObj.Seeker_Profile_ID__c));
Integer Roundsupport2=Integer.valueof(Roundsupport1.trim());
system.debug('--------------Roundsupport2----------'+Roundsupport1);
studentObj.Net_Support_Cost__c = nullCheck(studentObj.Seeker_Supported_Student__c) - (nullCheck(actualDiscountOneSelling)+nullCheck(actualDiscountTwoSelling)) - nullCheck(studentObj.Packaging_Allowance__c) - nullCheck(studentObj.Freight_Allowance_Selling__c) - nullCheck(studentObj.Other_Allowances__c);

System.debug('----------Net purchase Cost------'+studentObj.Net_Purchase_Cost__c);
System.debug('----------Net support Cost------'+studentObj.Net_Support_Cost__c);

studentObj.Requested_Debate_Amount__c = (studentObj.Net_Purchase_Cost__c - studentObj.Net_Support_Cost__c).setscale(Roundsupport2);

System.debug('----------Requested_Debate_Amount__c------'+studentObj.Requested_Debate_Amount__c);
}


}/*else if(studentObj.Support_Type__c==StudentSupportUtil.TOPFRONT){

System.debug('------old Purchase Cost-------'+studentObj.Purchase_Cost__c);

System.debug('------Purchase cost Type-------'+purchaseCostType);

System.debug('-----purchaseCostChange-------'+purchaseCostChange);

if(purchaseCostType.equalsIgnoreCase('$')){
studentObj.Purchase_Cost__c = nullCheck(studentObj.Purchase_Cost__c) + nullCheck(purchaseCostChange);
}else if(purchaseCostType.equalsIgnoreCase('%')){
studentObj.Purchase_Cost__c = nullCheck(studentObj.Purchase_Cost__c)+(nullCheck(studentObj.Purchase_Cost__c)*nullCheck(purchaseCostChange));
}

System.debug('------Modified Purchase Cost-------'+studentObj.Purchase_Cost__c);


}*/
if(comments!=null && !comments.equals('')){
// studentObj.Comments__c = System.now()+' '+comments +'\n' + nullCheck(studentObj.Comments__c);
studentObj.Comments__c = comments +'\n' + nullCheck(studentObj.Comments__c);
}
//Setting the default value of review date to 9999/12/31 as per the request from Business users.
//For Mass changed and Mass renew with student changed records
//Salesforce max limit is 4000 so setting that.
//studentObj.Review_Date__c = date.newInstance(4000, 12, 31);

if(validate(studentObj)){
System.debug('------Agreement Number ---------'+studentObj.Agreement_Number__c);
updatedCloneList.add(studentObj);
}

}
System.debug('------updatedCloneList ---------'+updatedCloneList);
insert updatedCloneList;

List<Checkited_Pricing__c> clonedCheckitedPricing = StudentSupportUtil.cloneCheckitedPricing(updatedCloneList);

//Added as per Charlotte. Purchase Cost for Topfront means all the 'Student' in checkited pricing

List<Checkited_Pricing__c> updatedClonedCheckitedPricing = new List<Checkited_Pricing__c>();

for(Checkited_Pricing__c pricingObj:clonedCheckitedPricing){


if(purchaseCostType.equalsIgnoreCase('$')){
pricingObj.Student__c = nullCheck(pricingObj.Student__c) + nullCheck(purchaseCostChange);
}else if(purchaseCostType.equalsIgnoreCase('%')){
pricingObj.Student__c = nullCheck(pricingObj.Student__c) +(nullCheck(pricingObj.Student__c)*nullCheck(purchaseCostChange));
}

updatedClonedCheckitedPricing.add(pricingObj);
}

List<Checkited_Pricing__c> newUpdatedClonedCheckitedPricing = StudentSupportUtil.doTopfrontCalculation(updatedClonedCheckitedPricing);

if(newUpdatedClonedCheckitedPricing!=null && !newUpdatedClonedCheckitedPricing.isEmpty()){

insert newUpdatedClonedCheckitedPricing;

}
}

private double nullCheck(decimal val){
if(val==null){
return 0.0;
}else{
return val;
}
}
private String nullCheck(String val){
if(val==null){
return '';
}else{
return val;
}
}
private String nullChecknew(String val){
if(val==null){
return '0';
}else{
return val;
}
}



private boolean validate(Student_Support__c studentObj){


boolean status = true;

List <String> duplicates = StudentSupportUtil.checkDuplicateStudentSupportforMassChange(studentObj);(I am getting problem here this queery is getting run again and again)
if(duplicates!=null && !duplicates.isEmpty()){
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.Error, 'Support # ' '+duplicates +' record found.'));
status= false;
}

if(status && studentObj.Support_Type__c=='Debate'){
if(studentObj.Flat_or_Purchased__c==StudentSupportUtil.PURCHASED){
if(studentObj.Net_Support_Cost__c==null||studentObj.Net_Support_Cost__c<=0){
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.Error,’msg.'));
status= false;
}
}else{
if(studentObj.Requested_Debate_Amount__c==null || studentObj.Requested_Debate_Amount__c<=0){
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.Error,'Support # 'msg.'));
status= false;
}
}

}

return status;

}



}

 

 

Method in Utill Class :checkDuplicatestudentdatamasschange(Thsi method is getting called again and again can anyone correct what i can use show that SQL :101 not occur)

 

public static List<String> checkDuplicatestudentdatamasschange(Student__c studobj){

Date effectiveDate = studobj.Effective_Date__c;
Date expirationDate= studobj.Expiration_Date__c;
List<String> duplicatesS= new List<String>();
String studentrecordid= studobj.Parent_Student__c;
List<Student__c> studsupport= null;
String soql = 'select id,Parent_Student__c,name,Agreement_Number__c from Student__c where (status__c=\'Approved\' OR status__c =\'Awaiting Approval\' OR status__c =\'Awaiting Stu Approval\' OR status__c =\'Conditionally Approved\' OR status__c =\'Rejected by Stud\')';

if (studobj.Supplier_Profile_ID__c!=null)
soql += ' and Student_Profile_ID__c = \''+studobj.Student_Profile_ID__c+'\'';
if (studobj.teacher__c!=null)
soql += ' and teacher___c = \''+studobj.teacher__c+'\'';

 if (studObj.Effective_Date__c!=null)
            soql += ' and ((Expiration_Date__c = null  or Expiration_Date__c > :effectiveDate) and (Effective_Date__c < :expirationDate))';
        if (stud.Parent_stud_Support__c != null)
            soql += ' and Id != \''+studj.Parent_Price_Support__c+'\'';
System.debug('----------soql-------------------'+soql);

try {
studsupport= Database.query(soql + ' order by Effective_Date__c asc' );
} catch (Exception e) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
}
if(studsupport!=null && !studsupport.isEmpty()){

for(Student__c support:studsupport){
duplicatesS.add(support.Agreement_Number__c);
}

}
System.debug('----------duplicates-------------------'+duplicatesPS);
return duplicatesS;
}

 

 

Please help.

 

 

Thanks:))

  • February 17, 2013
  • Like
  • 0

Hi,

 

I am doing mass update in a class and while doing mass operation i am checking duplicate record based on some condition for this i am calling a method again and again and getting this error can anyone please help how i can bulkyfy my code.code is below,your help will be really appreciated:

 

public static List<String> checkDuplicatestudentdatamasschange(Student__c studobj){

Date effectiveDate = studobj.Effective_Date__c;
Date expirationDate= studobj.Expiration_Date__c;
List<String> duplicatesS= new List<String>();
String studentrecordid= studobj.Parent_Student__c;
List<Student__c> studsupport= null;
String soql = 'select id,Parent_Student__c,name,Agreement_Number__c from Student__c where (status__c=\'Approved\' OR status__c =\'Awaiting Approval\' OR status__c =\'Awaiting Stu Approval\' OR status__c =\'Conditionally Approved\' OR status__c =\'Rejected by Stud\')';

if (studobj.Supplier_Profile_ID__c!=null)
soql += ' and Student_Profile_ID__c = \''+studobj.Student_Profile_ID__c+'\'';
if (studobj.teacher__c!=null)
soql += ' and teacher___c = \''+studobj.teacher__c+'\'';
System.debug('----------soql-------------------'+soql);

try {
studsupport= Database.query(soql + ' order by Effective_Date__c asc' );
} catch (Exception e) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
}
if(studsupport!=null && !studsupport.isEmpty()){

for(Student__c support:studsupport){
duplicatesS.add(support.Agreement_Number__c);
}

}
System.debug('----------duplicates-------------------'+duplicatesPS);
return duplicatesS;
}

 

 

Thanks:))))

  • February 16, 2013
  • Like
  • 0

Hi,

 

I am doing mass update in a class and while doing mass operation i am checking duplicate record based on some condition for this i am calling a method again and again and getting this error can anyone please help how i can bulkyfy my code.code is below,your help will be really appreciated:

 

public static List<String> checkDuplicatestudentdatamasschange(Student__c studobj){

Date effectiveDate = studobj.Effective_Date__c;
Date expirationDate= studobj.Expiration_Date__c;
List<String> duplicatesS= new List<String>();
String studentrecordid= studobj.Parent_Student__c;
List<Student__c> studsupport= null;
String soql = 'select id,Parent_Student__c,name,Agreement_Number__c from Student__c where (status__c=\'Approved\' OR status__c =\'Awaiting Approval\' OR status__c =\'Awaiting Stu Approval\' OR status__c =\'Conditionally Approved\' OR status__c =\'Rejected by Stud\')';

if (studobj.Supplier_Profile_ID__c!=null)
soql += ' and Student_Profile_ID__c = \''+studobj.Student_Profile_ID__c+'\'';
if (studobj.teacher__c!=null)
soql += ' and teacher___c = \''+studobj.teacher__c+'\'';
System.debug('----------soql-------------------'+soql);

try {
studsupport= Database.query(soql + ' order by Effective_Date__c asc' );
} catch (Exception e) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
}
if(studsupport!=null && !studsupport.isEmpty()){

for(Student__c support:studsupport){
duplicatesS.add(support.Agreement_Number__c);
}

}
System.debug('----------duplicates-------------------'+duplicatesPS);
return duplicatesS;
}

 

 

Thanks:))))

  • February 16, 2013
  • Like
  • 0

Hi All,

 

I am having a custom lookup search page where i am showing the account name after search.So while selecting the account to fill the field its working perfectly for all have not contained appostrophy ,its creating problem with appostrophy account name,

 

My code which showing javascript error is

 

Below is my code where the error is coming.

 

Thanks in advanc for you help :-))))

 

<apex:outputLink value="javascript&colon;top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!JSENCODE(a.name)}', false)" rendered="{!actualCustType!='Patner'}">{!a.Name}</apex:outputLink>

  • January 19, 2013
  • Like
  • 0

Hi ,

 

Need help to resolve my Appostrophy characters problm in customm lookup search page.After searching when i am trying to select something then javascript apostrophy error is coming in below line.I tried by using JSENCODE but still its not working.can anyone help to resolve my issue.

 

<apex:outputLink value="javascript&colon;top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!JSENCODE(a.name)}', false)" rendered="{!actualCustType!='Partner'}">{!a.Name}</apex:outputLink>

 

this is the line where problem is coming.

 

Thanks in Advance:-)))))

  • January 19, 2013
  • Like
  • 0

Hi ,

 

Can anyone please help to resolve my issue.I am using custom lookup to search but soe of the name contianed appostrophy words because of that  i am not able to select them .

 

JSENCODE is also not working for this please find below my code

 

<apex:outputLink value="javascript&colon;top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!JSENCODE(a.name)}', false)" rendered="{!actualCustType!='Partnerr'}">{!a.Name}</apex:outputLink>

 

What is the problem here can anyone please suggest.

 

 

Thanks in advance :-)))))

 

  • January 19, 2013
  • Like
  • 0

Hi,

 

In below trigger while updation of record i am checking the new expiration date and old expiration date and if they are not equal then i am updating the field Record_Support_Expiration_Date_Sub_Text1__c but what is the problem its not  working

 

trigger UpdateoldExpirationdateonChange on Record_Support__c (Before update) {
try {
      List<Record_Support__c updateList = new List<Record_Support__c>();
         for (Integer i = 0; i < Trigger.new.size(); i++)   { 
         
            if (Trigger.new[i].Expiration_Date__c != Trigger.old[i].Expiration_Date__c) { 
                System.debug('-------old[i].Expiration_Date__c------------' +Trigger.old[i].Expiration_Date__c);
                 System.debug('-------new[i].Expiration_Date__c------------' +Trigger.new[i].Expiration_Date__c);
                Trigger.new[i].Record_Support_Expiration_Date_Sub_Text1__c=Trigger.old[i].Expiration_Date__c; //remove credit card entries prior to committing data to Salesforce
                 System.debug('------- Trigger.new[i].Record_Support_Expiration_Date_Sub_Text1__c------------' + Trigger.new[i].Record_Support_Expiration_Date_Sub_Text1__c);
                updateList.add(Trigger.new[i]);
            }
         }
     update updateList;
   } catch(Exception e) {
//      System.Debug('removeCCValue Trigger failed: '+e.getMessage()); //write error to the debug log
   }
}

Thanks in advance:))))

 

 

  • December 10, 2012
  • Like
  • 0

Hi,

 

Please help to resolve the problem if recProfileId is getting null then its showing  List index out of bound :0 problem

 

How can resolve this problem in below code:

 

public static Integer getRoundingNumber(String recProfileId)
{


List<Supplier_record__C> sp = [select Round_Final_recordt_to__c from Supplier_record__C where id =: recProfileId];
if(sp[0].Round_Final_recordt_to__c!= null && sp.size()>0)
{
Integer round = Integer.valueof(sp[0].Round_Final_recordt_to__c);
system.debug('-----------Round169-----------'+round );
return round ;
}
else
{
return 4;
}
}

 

 

Thanks

Chandra

  • December 09, 2012
  • Like
  • 0

Hi,

 

Can anyone please help to resolve the error on below code :

 

 soql ='Select Support_ID__c,Support_Type__c,Customer_Name__c,Supplier_Name__c,Nexeo_Group_Name__c,Supplier_Group_Name__c,'+
          'Effective_Date__c,Expiration_Date__c,Net_Support_Cost__c,Net_Purchase_Cost__c,Requested_Rebate_Amount__c,Status__c,'+
          'Name,Id,Nexeo_Group__c,Submitted_to_Supplier_by__c,Submitted_to_Supplier_Date__c,Supplier_1st_Action_by__c,SAP_Transfer__c,'+
          'Supplier_1st_Action_Date__c,Final_Action_by__c,Final_Action_by_Date__c,Additional_Comments__c,Supplier_Group__c,'+
          'Nexeo_Main_Approver__c,Supplier_Main_Approver__c,Material_Description_Buying__c,Supplier_Supported_Price__c,Packaging_Allowance__c,'+
          'Dis2_Sell__c,Dis1_Sell__c,Freight_Allowance_Selling__c,Other_Allowances__c,New_or_Changed__c,'+
          'Supplier_Sales_Contact__c,Competitor_Name__c,Actual_Annual_Volume__c,Competitor_Manufacturer__c,Application__c,Market_Segment__c,Seller__c '+
          'from Price_Record__c where Status__c=' +'\''+PricerecordUtil.AWAITING_SUPPLIER_APPROVAL +'\' AND (Supplier_Group__c IN '+supplierGroupIds+' OR Supplier_Main_Approver__c='+'\''+UserInfo.getUserId()+'\')';
          if (customerName!=null && !customerName.equals(''))
          soql += 'and CustomerName_Mail__c LIKE \'%'+String.escapeSingleQuotes(customerName)+'%\'';
          
          system.debug(soql);
          supplierApprovalList=Database.query(soql);

 

Error is coming on red line.

 

Thanks in advance:)))

  • December 07, 2012
  • Like
  • 0

Hi,

 

Please help to resolve following error:

 

unexpected token: '.'

 

Error is coming for below code can anyone please suggest to resolve the following:

 

  List<Monthly_Plant_Hour__c> mph= Database.query('SELECT Name,Month__c,Reporting_Month__c,Employee__c,Man_hours__c,'
                                            +'Reporting_Year__c FROM Monthly_Plant_Hour__c '
                                                +'where '+ firstWhereClause + ' ' +secondWhereClause + ' order by Reporting_Month__c ');
                                                
        for(Integer i=0; i<mph.size();i++){


            finalmph.add(mph[i]);
        }
                                                
        return finalmph;
    }

 

 

Thanks in advance:))))

  • November 25, 2012
  • Like
  • 0

Hi,

 

Can anyone please suggest to write test class for my below class,because of that i am not able to deploy my application in Production,its urgent please help.

 

public class planthourExtension {
private final Get_Hour_Report__cplant;
public String year;
public String previousYear;
public Integer intYear = 0;
public Integer intPreviousYear = 0;
public String reporttype;
public String reportperiod;
public String reportCategory;
public String facility;
public String country;
public String plantDivision;
List<Decimal> cumulativemanhr=new List<Decimal>();
List<Decimal> cummanhr1 = new List<Decimal>();
List<Decimal> avgemployee = new List<Decimal>();
Decimal **bleep** = 0;
decimal hr = 0;
List<Monthly_home_Hour__c> incidentrec = new list<Monthly_home_Hour__c>(); 
public string firstWhereClause = '';
public string secondWhereClause = '';
public string secondWhereClause1 = '';
public List<string> mon = new List<String>();

public planthourExtension(ApexPages.StandardController controller) {

this.plant = (Plant_Hours_Report__c)controller.getRecord();
Get_Hour_Report__co = [Select Country__c,Division_div__c,Facility__c, Reporting_Category__c,
Report_Year__c,Report_Type__c,Reporting_Period__c
From Get_Hour_Report__cWhere Id =: plant.Id];

year= o.Report_Year__c;
if(year!= null){
intYear = Integer.valueof(year);
intPreviousYear = intYear - 1;
previousYear = String.valueof(intPreviousYear);
}
reporttype=o.Report_Type__c;
reportperiod=o.Reporting_Period__c;
facility = o.Facility__c;
reportCategory = o.Reporting_Category__c;
plantDivision = o.Division_div__c;
country = o.Country__c;
system.debug('reporttype is '+reporttype);

if(reporttype == 'Facility'){
firstWhereClause = 'Facility__c = \''+facility+'\' and Reporting_Category__c =\''+reportCategory+'\'';
}else if(reporttype == 'Sub'){
firstWhereClause = ' Country__c = \''+country+'\' and Reporting_Category__c =\''+reportCategory+'\'';
}else if(reporttype == 'Division'){
firstWhereClause = ' Country__c = \''+country+'\' and Division__c = \''+plantDivision+'\'';
}else {
firstWhereClause = ' Country__c = \''+country+'\'';
}

Date currentDate = date.today();

Integer currentMonth = currentDate.month();
system.debug('Current Month is'+currentMonth );

String[] monthQuery = new String[]{};
String[] monthQuery1 = new String[]{};

if(reportperiod == 'Calendar'){
system.debug('Entered Calendar');
for(Integer i=1;i<=currentMonth;i++ ){
monthQuery.add('\''+String.valueof(i)+'\'');
}
system.debug('monthQuery is '+monthQuery);
secondWhereClause = ' and Reporting_Year__c =\''+year+'\' and Reporting_Month__c in '+monthQuery+'';

}else if(reportperiod == 'Fiscal'){
system.debug('Entered Fiscal');
if(currentMonth >= 10){
for(Integer i=10;i<=currentMonth;i++ ){
monthQuery.add('\''+String.valueof(i)+'\'');
}
}else{
for(Integer i=1;i<=currentMonth;i++ ){
monthQuery.add('\''+String.valueof(i)+'\'');
}
for(Integer i=10;i<=12;i++ ){
monthQuery1.add('\''+String.valueof(i)+'\'');
}
}
secondWhereClause = ' and Reporting_Year__c =\''+year+'\' and Reporting_Month__c in '+monthQuery+'';
secondWhereClause1 = ' and Reporting_Year__c =\''+previousYear+'\' and Reporting_Month__c in '+monthQuery1+'';

}else if(reportperiod == 'Rolling'){
system.debug('Entered Rolling');
for(Integer i=1;i<currentMonth;i++ ){
monthQuery.add('\''+String.valueof(i)+'\'');
}
for(Integer i=currentMonth;i<=12;i++ ){
monthQuery1.add('\''+String.valueof(i)+'\'');
}

secondWhereClause = ' and Reporting_Year__c =\''+year+'\' and Reporting_Month__c in '+monthQuery+' ';
secondWhereClause1 = ' and Reporting_Year__c =\''+previousYear+'\' and Reporting_Month__c in '+monthQuery1+'';
}




public List<Monthly_home_Hour__c> getManhour() {

List<Monthly_home_Hour__c> finalmph = new List<Monthly_home_Hour__c>();


if(!secondWhereClause1.equals('')){

List<Monthly_home_Hour__c> mph1= Database.query('SELECT Name,Month__c,Reporting_Month__c,Employee__c,Man_hours__c,'
+'Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause+ ' ' + secondWhereClause1 + ' order by Reporting_Month__c ');

for(Integer i=0; i<mph1.size();i++){
finalmph.add(mph1[i]);


List<Monthly_home_Hour__c> mph= Database.query('SELECT Name,Month__c,Reporting_Month__c,Employee__c,Man_hours__c,'
+'Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause + ' ' +secondWhereClause + ' order by Reporting_Month__c ');

for(Integer i=0; i<mph.size();i++){
finalmph.add(mph[i]);
}

return finalmph;
}

public List<Decimal> getCumulativeManhour() {

Decimal cummanhr = 0;
Decimal cummanhrcum = 0;


if(!secondWhereClause1.equals('')){

List<Monthly_home_Hour__c> mph1= Database.query('SELECT Name,Reporting_Month__c,Employee__c,Man_hours__c,'
+'Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause+ ' ' + secondWhereClause1 + ' order by Reporting_Month__c ');

if(mph1.size()>0){
for(Integer i=0;i<mph1.size();i++)
{
cummanhr =mph1[i].Man_hours__c;
cummanhrcum = cummanhrcum + cummanhr;
cummanhr1.add(cummanhrcum);
}
}

List<Monthly_home_Hour__c> mph= Database.query('SELECT Name,Reporting_Month__c,Employee__c,Man_hours__c,'
+'Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause + ' ' +secondWhereClause + ' order by Reporting_Month__c ');

if(mph.size()>0){
for(Integer i=0;i<mph.size();i++)
{
cummanhr =mph[i].Man_hours__c;
cummanhrcum = cummanhrcum + cummanhr;
cummanhr1.add(cummanhrcum);
}

return cummanhr1;
}
public List<Decimal> getAverageEmployee() {
Integer i= 0;
Integer j= 0;
Decimal avgemp = 0;
Decimal avgemployeeset = 0;

if(!secondWhereClause1.equals('')){

List<Monthly_home_Hour__c> mph1= Database.query('SELECT Name,Reporting_Month__c,Employee__c,Man_hours__c,'
+'Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause+ ' ' + secondWhereClause1 + ' order by Reporting_Month__c ');

if(mph1.size()>0){

avgemployeeset = 0;
for(i=0;i<mph1.size();i++)
{
avgemp =mph1[i].Employee__c;

avgemployeeset = ((avgemployeeset*i) + avgemp)/(i+1);

avgemployee.add(avgemployeeset);
j = i+1;
}
}

List<Monthly_home_Hour__c> mph= Database.query('SELECT Name,Reporting_Month__c,Employee__c,Man_hours__c,'
+'Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause + ' ' +secondWhereClause + ' order by Reporting_Month__c ');

if(mph.size()>0){
for(Integer m=0;m<mph.size();m++)
{
avgemp =mph[m].Employee__c;

avgemployeeset = ((avgemployeeset*j) + avgemp)/(j+1);

avgemployee.add(avgemployeeset);
j++;
}
}

return avgemployee;
}


public List<Monthly_home_Hour__c> getCumulativeRolling() {

List<Monthly_home_Hour__c> finalmph = new List<Monthly_home_Hour__c>();

if(!secondWhereClause1.equals('')){
List<Monthly_home_Hour__c> mph1= Database.query('SELECT Name,Month__c,Reporting_Month__c,Incidents__c,Total_Recordable_Rate__c,'
+' Lost_Work_Incidents__c,Lost_Work_Rate__c,Days_Away_From_work__c,'
+' Days_Away_From_Work_Rate__c,Medical_Treatment__c, '
+' Medical_Treatment_Rate__c,Fatalities__c,'
+' Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause+ ' ' + secondWhereClause1 + ' order by Reporting_Month__c ');

for(Integer i=0; i<mph1.size();i++){
finalmph.add(mph1[i]);
}

}
List<Monthly_home_Hour__c> mph= Database.query('SELECT Name,Month__c,Reporting_Month__c,Incidents__c,Total_Recordable_Rate__c,'
+' Lost_Work_Incidents__c,Lost_Work_Rate__c,Days_Away_From_work__c,'
+' Days_Away_From_Work_Rate__c,Medical_Treatment__c, '
+' Medical_Treatment_Rate__c,Fatalities__c,'
+' Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause+ ' ' + secondWhereClause + ' order by Reporting_Month__c ');

for(Integer i=0; i<mph.size();i++){
finalmph.add(mph[i]);
}
return finalmph;
}
}

 

Thanks in advance:)))

 

  • November 25, 2012
  • Like
  • 0

Hi,

 

I am mass cloning the record and for mass cloning the attachment i have written the trigger but its cloning the attachment of first record only and i want to mass clone the attachment with record also.

 

Can anyone please help me to resolve mu problem .Help will really appriciated.Please find attached my trigger below.What changes needed to do for mass cloning the attachment also.

 

trigger CopyAttachments on New_Support__c(after insert)
{
List<Id> parentIds=new List<Id>();
Attachment[] attList = [select id, name, body from Attachment where ParentId = :Trigger.new[0].Parent_New_Support__c];
Attachment[] insertAttList = new Attachment[]{};

for(Attachment a: attList)
{
Attachment att = new Attachment(name = a.name, body = a.body, parentid = Trigger.new[0].id);
insertAttList.add(att);
}
if(insertAttList.size() > 0)
{
insert insertAttList;
}

}

 

Thanks in advance:-)

  • November 20, 2012
  • Like
  • 0

Hi,

 

I am mass cloning the record and for mass cloning the attachment i have written the trigger but its cloning the attachment of first record only and i want to mass clone the attachment with record also.

 

Can anyone please help me to resolve mu problem .Help will really appriciated.Please find attached my trigger below.What changes needed to do for mass cloning the attachment also.

 

trigger CopyAttachments on New_Support__c(after insert)
{
List<Id> parentIds=new List<Id>();
Attachment[] attList = [select id, name, body from Attachment where ParentId = :Trigger.new[0].Parent_New_Support__c];
Attachment[] insertAttList = new Attachment[]{};

for(Attachment a: attList)
{
Attachment att = new Attachment(name = a.name, body = a.body, parentid = Trigger.new[0].id);
insertAttList.add(att);
}
if(insertAttList.size() > 0)
{
insert insertAttList;
}

}

 

Thanks in advance:-)

  • November 20, 2012
  • Like
  • 0

Hi,

 

I am mass cloning the record and for mass cloning the attachment i have written the trigger but its cloning the attachment of first record only and i want to mass clone the attachment with record also.

 

Can anyone please help me to resolve mu problem .Help will really appriciated.Please find attached my trigger below.What changes needed to do for mass cloning the attachment also.

 

trigger CopyAttachments on New_Support__c(after insert)
{
List<Id> parentIds=new List<Id>();
Attachment[] attList = [select id, name, body from Attachment where ParentId = :Trigger.new[0].Parent_New_Support__c];
Attachment[] insertAttList = new Attachment[]{};

for(Attachment a: attList)
{
Attachment att = new Attachment(name = a.name, body = a.body, parentid = Trigger.new[0].id);
insertAttList.add(att);
}
if(insertAttList.size() > 0)
{
insert insertAttList;
}

}

 

Thanks in advance:-)

  • November 20, 2012
  • Like
  • 0

Hi Everyone,

We have a requirement where we need to compare current Client support record with all the old client support record and that needs to be done before saving the record.

We need to compare near about 12 fields for every record which we are selecting during mass operation (can select 100 record for mass operation),but we are not having any field which can used as a key without saving the record.

We tried using map and list but we are getting exceptions ' Too many code statements: 200001' and as well as its making the process too time taking.

Please help to achieve this requirement .

 

Below is the method where we are getting issue:

 

public static Map<Client_support__c,List<String>> checkDuplicatePriceSupportforMassChangeone(List<Client_support__c> PSList){
                   
    List<String> duplicatesPS= new List<String>();    
    List<Client_support__c> OldPS=new List<Client_support__c>();
    oldPS =[select id,status__c,distributor_PRofile__c,Material_Selling__c,Material_Buying__c where status__c='Approved' or status__c='Awaiting distributor Approval' or status__c='Awaiting Nexeo Approval'];
    List <Client_support__c>l1 = new List<Client_support__c>();
    Map<Client_support__c,List<duplicate>> mapPS = new Map<Client_support__c,List<duplicate>>();
    List <String> l2=new List<String>();   
  for(Client_support__c ps:PSList){

    for(Client_support__c ps1:oldPS){

    if(ps.distributor_PRofile__c!=null){
        if(ps.distributor_PRofile__c == ps1.distributor_PRofile__c){
        l1.add(ps1);
    }
    }

    if(ps.Material_Selling__c!=null){
        for(Client_support__c li : L1){
       
            if(ps.Material_Selling__c == ps1.Material_Selling__c){
            //l1.add(li);
            l2.add(li.aggrement_number__c);
            }

        }
    }

   
    }
   
    mapPS.put(ps1 ,l2);

 }   

 

Thanks in advance:))))
                   
   

  • April 04, 2013
  • Like
  • 0

Hi ,

 

I am getting too many SOQL problem ,can anyone please help to resolve,its very urgent.

 

i,

 

Please find my Custom Save code from where i am calling the method 'checkDuplicatestudentdatamasschange'

 

I am not able to recognize how i can create a Map for this checking purpose and this functionality is important for me.

 

Custom Save Method:

 

public void customSave(){


double actualDiscountOne = 0.0;
double actualDiscountTwo = 0.0;
double actualDiscountOneSelling = 0.0;
double actualDiscountTwoSelling = 0.0;
List<Student_Support__c> clonedStudentSupports =null;
if(!renewFlag){
clonedStudentSupports = StudentSupportUtil.cloneStudentSupports(objectName, selectedStudentSupports,StudentSupportUtil.CHANGE,expirationDate,effectiveDate);
}else{
clonedStudentSupports = StudentSupportUtil.cloneStudentSupports(objectName, selectedStudentSupports,StudentSupportUtil.RENEW,expirationDate,null);
}
List<Student_Support__c> updatedCloneList = new List<Student_Support__c>();
for(Student_Support__c studentObj1 : clonedStudentSupports){
SuppprofileIds.add(studentObj1.Student_Profile_ID__c);
}
System.debug('-----------StudentsupportsuppprofileId-------'+SuppprofileIds);
List<Seeker_Profile__c> SuppprofileeObjList =[select Round_Final_Support_to__c from Student_Profile__c where Id in:SuppprofileIds];

for (Integer k = 0; k < SuppprofileeObjList.size(); k++) {
SuppprofileIdRoundno.put(SuppprofileeObjList[k].id,SuppprofileeObjList[k].Round_Final_Support_to__c);
}
System.debug('-----------StudentsupportsuppprofileIdMap-------'+SuppprofileIdRoundno);


for(Student_Support__c studentObj : clonedStudentSupports){

if(studentObj.Support_Type__c==StudentSupportUtil.DEBATE){

if(studentObj.Flat_or_Purchased__c==StudentSupportUtil.FLAT && studentObj.Debate_Editable__c==true){

System.debug('----------FLAT Student Support------');
studentObj.Requested_Debate_Amount__c = nullCheck(studentObj.Requested_Debate_Amount__c) + nullCheck(increaseDebateAmountBy);

}else{

System.debug('------old Purchase Cost-------'+studentObj.Purchase_Cost__c);

System.debug('------Purchase cost Type-------'+purchaseCostType);

System.debug('-----purchaseCostChange-------'+purchaseCostChange);

if(purchaseCostType.equalsIgnoreCase('$')){
studentObj.Purchase_Cost__c = nullCheck(studentObj.Purchase_Cost__c) + nullCheck(purchaseCostChange);
}else if(purchaseCostType.equalsIgnoreCase('%')){
studentObj.Purchase_Cost__c = nullCheck(studentObj.Purchase_Cost__c)+(nullCheck(studentObj.Purchase_Cost__c)*nullCheck(purchaseCostChange));
}

System.debug('------Modified Purchase Cost-------'+studentObj.Purchase_Cost__c);

System.debug('------old Seeker_Supported_Student__c-------'+studentObj.Seeker_Supported_Student__c);

System.debug('------supportedStudentType-------'+supportedStudentType);

System.debug('-----seekerSupportedStudentChange-------'+seekerSupportedStudentChange);

if(supportedStudentType.equalsIgnoreCase('$')){
studentObj.Seeker_Supported_Student__c = nullCheck(studentObj.Seeker_Supported_Student__c) + nullCheck(seekerSupportedStudentChange);
}else if(supportedStudentType.equalsIgnoreCase('%')){
studentObj.Seeker_Supported_Student__c = nullCheck(studentObj.Seeker_Supported_Student__c)+(nullCheck(studentObj.Seeker_Supported_Student__c)*nullCheck(seekerSupportedStudentChange));
}

System.debug('------Modified supportedStudent-------'+studentObj.Seeker_Supported_Student__c);

if(studentObj.X1st_Discount_Type_Buy__c!=null && studentObj.X1st_Discount_Type_Buy__c.equalsIgnoreCase('%')){
actualDiscountOne=studentObj.Purchase_Cost__c*(nullCheck(studentObj.X1st_Discount_Buy__c)/100);
}else{
actualDiscountOne = studentObj.X1st_Discount_Buy__c;
}

if(studentObj.X2nd_Discount_Type_Buy__c!=null && studentObj.X2nd_Discount_Type_Buy__c.equalsIgnoreCase('%')){
actualDiscountTwo=studentObj.Purchase_Cost__c*(nullCheck(studentObj.X2nd_Discount_Buy__c)/100);
}else{
actualDiscountTwo = studentObj.X2nd_Discount_Buy__c;
}


if(studentObj.X1st_Discount_Type_Sell__c!=null && studentObj.X1st_Discount_Type_Sell__c.equalsIgnoreCase('%')){
actualDiscountOneSelling=studentObj.Seeker_Supported_Student__c*(nullCheck(studentObj.X1st_Discount_Sell__c)/100);
}else{
actualDiscountOneSelling = studentObj.X1st_Discount_Sell__c;
}

if(studentObj.X2nd_Discount_Type_Sell__c!=null && studentObj.X2nd_Discount_Type_Sell__c.equalsIgnoreCase('%')){
actualDiscountTwoSelling=studentObj.Seeker_Supported_Student__c*(nullCheck(studentObj.X2nd_Discount_Sell__c)/100);
}else{
actualDiscountTwoSelling = studentObj.X2nd_Discount_Sell__c;
}

studentObj.Net_Purchase_Cost__c = nullCheck(studentObj.Purchase_Cost__c)-nullCheck(actualDiscountOne)-nullCheck(actualDiscountTwo)+nullCheck(studentObj.Freight_Allowance_Buying__c)+nullCheck(studentObj.Other__c);

String Roundsupport1=nullChecknew(SuppprofileIdRoundno.get(studentObj.Seeker_Profile_ID__c));
Integer Roundsupport2=Integer.valueof(Roundsupport1.trim());
system.debug('--------------Roundsupport2----------'+Roundsupport1);
studentObj.Net_Support_Cost__c = nullCheck(studentObj.Seeker_Supported_Student__c) - (nullCheck(actualDiscountOneSelling)+nullCheck(actualDiscountTwoSelling)) - nullCheck(studentObj.Packaging_Allowance__c) - nullCheck(studentObj.Freight_Allowance_Selling__c) - nullCheck(studentObj.Other_Allowances__c);

System.debug('----------Net purchase Cost------'+studentObj.Net_Purchase_Cost__c);
System.debug('----------Net support Cost------'+studentObj.Net_Support_Cost__c);

studentObj.Requested_Debate_Amount__c = (studentObj.Net_Purchase_Cost__c - studentObj.Net_Support_Cost__c).setscale(Roundsupport2);

System.debug('----------Requested_Debate_Amount__c------'+studentObj.Requested_Debate_Amount__c);
}


}/*else if(studentObj.Support_Type__c==StudentSupportUtil.TOPFRONT){

System.debug('------old Purchase Cost-------'+studentObj.Purchase_Cost__c);

System.debug('------Purchase cost Type-------'+purchaseCostType);

System.debug('-----purchaseCostChange-------'+purchaseCostChange);

if(purchaseCostType.equalsIgnoreCase('$')){
studentObj.Purchase_Cost__c = nullCheck(studentObj.Purchase_Cost__c) + nullCheck(purchaseCostChange);
}else if(purchaseCostType.equalsIgnoreCase('%')){
studentObj.Purchase_Cost__c = nullCheck(studentObj.Purchase_Cost__c)+(nullCheck(studentObj.Purchase_Cost__c)*nullCheck(purchaseCostChange));
}

System.debug('------Modified Purchase Cost-------'+studentObj.Purchase_Cost__c);


}*/
if(comments!=null && !comments.equals('')){
// studentObj.Comments__c = System.now()+' '+comments +'\n' + nullCheck(studentObj.Comments__c);
studentObj.Comments__c = comments +'\n' + nullCheck(studentObj.Comments__c);
}
//Setting the default value of review date to 9999/12/31 as per the request from Business users.
//For Mass changed and Mass renew with student changed records
//Salesforce max limit is 4000 so setting that.
//studentObj.Review_Date__c = date.newInstance(4000, 12, 31);

if(validate(studentObj)){
System.debug('------Agreement Number ---------'+studentObj.Agreement_Number__c);
updatedCloneList.add(studentObj);
}

}
System.debug('------updatedCloneList ---------'+updatedCloneList);
insert updatedCloneList;

List<Checkited_Pricing__c> clonedCheckitedPricing = StudentSupportUtil.cloneCheckitedPricing(updatedCloneList);

//Added as per Charlotte. Purchase Cost for Topfront means all the 'Student' in checkited pricing

List<Checkited_Pricing__c> updatedClonedCheckitedPricing = new List<Checkited_Pricing__c>();

for(Checkited_Pricing__c pricingObj:clonedCheckitedPricing){


if(purchaseCostType.equalsIgnoreCase('$')){
pricingObj.Student__c = nullCheck(pricingObj.Student__c) + nullCheck(purchaseCostChange);
}else if(purchaseCostType.equalsIgnoreCase('%')){
pricingObj.Student__c = nullCheck(pricingObj.Student__c) +(nullCheck(pricingObj.Student__c)*nullCheck(purchaseCostChange));
}

updatedClonedCheckitedPricing.add(pricingObj);
}

List<Checkited_Pricing__c> newUpdatedClonedCheckitedPricing = StudentSupportUtil.doTopfrontCalculation(updatedClonedCheckitedPricing);

if(newUpdatedClonedCheckitedPricing!=null && !newUpdatedClonedCheckitedPricing.isEmpty()){

insert newUpdatedClonedCheckitedPricing;

}
}

private double nullCheck(decimal val){
if(val==null){
return 0.0;
}else{
return val;
}
}
private String nullCheck(String val){
if(val==null){
return '';
}else{
return val;
}
}
private String nullChecknew(String val){
if(val==null){
return '0';
}else{
return val;
}
}



private boolean validate(Student_Support__c studentObj){


boolean status = true;

List <String> duplicates = StudentSupportUtil.checkDuplicateStudentSupportforMassChange(studentObj);(I am getting problem here this queery is getting run again and again)
if(duplicates!=null && !duplicates.isEmpty()){
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.Error, 'Support # ' '+duplicates +' record found.'));
status= false;
}

if(status && studentObj.Support_Type__c=='Debate'){
if(studentObj.Flat_or_Purchased__c==StudentSupportUtil.PURCHASED){
if(studentObj.Net_Support_Cost__c==null||studentObj.Net_Support_Cost__c<=0){
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.Error,’msg.'));
status= false;
}
}else{
if(studentObj.Requested_Debate_Amount__c==null || studentObj.Requested_Debate_Amount__c<=0){
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.Error,'Support # 'msg.'));
status= false;
}
}

}

return status;

}



}

 

 

Method in Utill Class :checkDuplicatestudentdatamasschange(Thsi method is getting called again and again can anyone correct what i can use show that SQL :101 not occur)

 

public static List<String> checkDuplicatestudentdatamasschange(Student__c studobj){

Date effectiveDate = studobj.Effective_Date__c;
Date expirationDate= studobj.Expiration_Date__c;
List<String> duplicatesS= new List<String>();
String studentrecordid= studobj.Parent_Student__c;
List<Student__c> studsupport= null;
String soql = 'select id,Parent_Student__c,name,Agreement_Number__c from Student__c where (status__c=\'Approved\' OR status__c =\'Awaiting Approval\' OR status__c =\'Awaiting Stu Approval\' OR status__c =\'Conditionally Approved\' OR status__c =\'Rejected by Stud\')';

if (studobj.Supplier_Profile_ID__c!=null)
soql += ' and Student_Profile_ID__c = \''+studobj.Student_Profile_ID__c+'\'';
if (studobj.teacher__c!=null)
soql += ' and teacher___c = \''+studobj.teacher__c+'\'';

 if (studObj.Effective_Date__c!=null)
            soql += ' and ((Expiration_Date__c = null  or Expiration_Date__c > :effectiveDate) and (Effective_Date__c < :expirationDate))';
        if (stud.Parent_stud_Support__c != null)
            soql += ' and Id != \''+studj.Parent_Price_Support__c+'\'';
System.debug('----------soql-------------------'+soql);

try {
studsupport= Database.query(soql + ' order by Effective_Date__c asc' );
} catch (Exception e) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
}
if(studsupport!=null && !studsupport.isEmpty()){

for(Student__c support:studsupport){
duplicatesS.add(support.Agreement_Number__c);
}

}
System.debug('----------duplicates-------------------'+duplicatesPS);
return duplicatesS;
}

 

 

Please help.

 

 

Thanks:))

  • February 17, 2013
  • Like
  • 0

Hi,

 

I am doing mass update in a class and while doing mass operation i am checking duplicate record based on some condition for this i am calling a method again and again and getting this error can anyone please help how i can bulkyfy my code.code is below,your help will be really appreciated:

 

public static List<String> checkDuplicatestudentdatamasschange(Student__c studobj){

Date effectiveDate = studobj.Effective_Date__c;
Date expirationDate= studobj.Expiration_Date__c;
List<String> duplicatesS= new List<String>();
String studentrecordid= studobj.Parent_Student__c;
List<Student__c> studsupport= null;
String soql = 'select id,Parent_Student__c,name,Agreement_Number__c from Student__c where (status__c=\'Approved\' OR status__c =\'Awaiting Approval\' OR status__c =\'Awaiting Stu Approval\' OR status__c =\'Conditionally Approved\' OR status__c =\'Rejected by Stud\')';

if (studobj.Supplier_Profile_ID__c!=null)
soql += ' and Student_Profile_ID__c = \''+studobj.Student_Profile_ID__c+'\'';
if (studobj.teacher__c!=null)
soql += ' and teacher___c = \''+studobj.teacher__c+'\'';
System.debug('----------soql-------------------'+soql);

try {
studsupport= Database.query(soql + ' order by Effective_Date__c asc' );
} catch (Exception e) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
}
if(studsupport!=null && !studsupport.isEmpty()){

for(Student__c support:studsupport){
duplicatesS.add(support.Agreement_Number__c);
}

}
System.debug('----------duplicates-------------------'+duplicatesPS);
return duplicatesS;
}

 

 

Thanks:))))

  • February 16, 2013
  • Like
  • 0

Hi,

 

I am doing mass update in a class and while doing mass operation i am checking duplicate record based on some condition for this i am calling a method again and again and getting this error can anyone please help how i can bulkyfy my code.code is below,your help will be really appreciated:

 

public static List<String> checkDuplicatestudentdatamasschange(Student__c studobj){

Date effectiveDate = studobj.Effective_Date__c;
Date expirationDate= studobj.Expiration_Date__c;
List<String> duplicatesS= new List<String>();
String studentrecordid= studobj.Parent_Student__c;
List<Student__c> studsupport= null;
String soql = 'select id,Parent_Student__c,name,Agreement_Number__c from Student__c where (status__c=\'Approved\' OR status__c =\'Awaiting Approval\' OR status__c =\'Awaiting Stu Approval\' OR status__c =\'Conditionally Approved\' OR status__c =\'Rejected by Stud\')';

if (studobj.Supplier_Profile_ID__c!=null)
soql += ' and Student_Profile_ID__c = \''+studobj.Student_Profile_ID__c+'\'';
if (studobj.teacher__c!=null)
soql += ' and teacher___c = \''+studobj.teacher__c+'\'';
System.debug('----------soql-------------------'+soql);

try {
studsupport= Database.query(soql + ' order by Effective_Date__c asc' );
} catch (Exception e) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
}
if(studsupport!=null && !studsupport.isEmpty()){

for(Student__c support:studsupport){
duplicatesS.add(support.Agreement_Number__c);
}

}
System.debug('----------duplicates-------------------'+duplicatesPS);
return duplicatesS;
}

 

 

Thanks:))))

  • February 16, 2013
  • Like
  • 0

Hi All,

 

I am having a custom lookup search page where i am showing the account name after search.So while selecting the account to fill the field its working perfectly for all have not contained appostrophy ,its creating problem with appostrophy account name,

 

My code which showing javascript error is

 

Below is my code where the error is coming.

 

Thanks in advanc for you help :-))))

 

<apex:outputLink value="javascript&colon;top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!JSENCODE(a.name)}', false)" rendered="{!actualCustType!='Patner'}">{!a.Name}</apex:outputLink>

  • January 19, 2013
  • Like
  • 0

Greetings to everyone!

 

I've got a problem writing test for my Apex controller. Here is controller:

public class Fullfunctionality_2 {
 
   private List<Item__c> items;
   private String sortDirection = 'ASC';
   private String sortExp = 'name';
   public String NewItemName {get; set;}
   public Integer NewItemQuantity { get; set; }
   public Integer NewItemPrice { get; set; }
   public String NewItemType { get; set; }
   public Date NewItemReleaseDate { get; set; }
   public String IdToDel { get; set; }
   public string searchText {get;set;}
   public List<Item__c> searchResults {get;set;}

   public List<SelectOption> getTypes(){
       List<SelectOption> types = new List<SelectOption>();
       Schema.DescribeFieldResult fieldResult = Item__c.Item_Type__c.getDescribe();
       List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
       for( Schema.PicklistEntry f : ple)
           {
              types.add(new SelectOption(f.getLabel(), f.getValue()));
           }       
       return types;
    }
    
   public PageReference add(){

        Item__c NewItem = new Item__c(            
                Name = NewItemName,
                Item_Price__c = NewItemPrice,
                Items_Available__c = NewItemQuantity,
                Item_Type__c = NewItemType,
                Release_Date__c = NewItemReleaseDate);
                insert NewItem; 
                ViewData();
                PageReference curPage = ApexPages.currentPage(); 
                curPage.getParameters().put('success','true');
                curPage.getParameters().put('id',Apexpages.currentPage().getParameters().get('id'));
                curPage.setRedirect(true);
                NewItemName=null;
                NewItemQuantity=null;
                NewItemPrice = null;
                NewItemReleaseDate = null;
                return null; 
    }     
   public PageReference del() {

        Item__c ItemToDel = [SELECT id
                             FROM Item__c
                             WHERE id = :IdToDel];
        delete ItemToDel;   
               
        PageReference curPage = ApexPages.currentPage(); 
        curPage.getParameters().put('success','true');
        curPage.getParameters().put('id',Apexpages.currentPage().getParameters().get('id'));
        ViewData();
        curPage.setRedirect(false);       
        return curPage;
            
    }    

  public PageReference search() {
        String qry = 'select id, name, createddate, item_price__c from Item__c ' +
        'where name LIKE \'%'+searchText+'%\' order by name';
        searchResults = Database.query(qry);
        PageReference curPage = ApexPages.currentPage(); 
        curPage.getParameters().put('success','true');
        curPage.getParameters().put('id',Apexpages.currentPage().getParameters().get('id'));
        ViewData();
        curPage.setRedirect(true);       
        return null;        
  }    

   public String sortExpression
   {
     get
     {
        return sortExp;
     }
     set
     {
       if (value == sortExp)
         sortDirection = (sortDirection == 'ASC')? 'DESC' : 'ASC';
       else
         sortDirection = 'ASC';
       sortExp = value;
     }
   }

 public String getSortDirection()
 {
    if (sortExpression == null || sortExpression == '')
      return 'ASC';
    else
     return sortDirection;
 }

 public void setSortDirection(String value)
 {  
   sortDirection = value;
 }
  
   public List<Item__c> getItems() {
       return items;
   }

   public PageReference ViewData() {
   
       string sortFullExp = sortExpression  + ' ' + sortDirection;
       items = Database.query('Select id, Name, Item_Price__c, CreatedDate from Item__c order by ' + sortFullExp + ' limit 1000');
       return null;
   }
}

 I wrote a piece of test, it looks like this:

 

@isTest
private class TestFullFunctionality_2 {

static testMethod void testItemEnter() {

    Item__c NewItem = new Item__c(name = 'NEWITEM', Item_Price__c = 100, Item_Type__c = 'Solid', Items_Available__c = 10 );
    insert NewItem;
    Test.startTest();
    Test.stopTest();    
}
}

 ...but still the code coverage total is 0%. What do i do wrong?

 

Thanks in advance.

Hi,

 

Can anyone please help to resolve the error on below code :

 

 soql ='Select Support_ID__c,Support_Type__c,Customer_Name__c,Supplier_Name__c,Nexeo_Group_Name__c,Supplier_Group_Name__c,'+
          'Effective_Date__c,Expiration_Date__c,Net_Support_Cost__c,Net_Purchase_Cost__c,Requested_Rebate_Amount__c,Status__c,'+
          'Name,Id,Nexeo_Group__c,Submitted_to_Supplier_by__c,Submitted_to_Supplier_Date__c,Supplier_1st_Action_by__c,SAP_Transfer__c,'+
          'Supplier_1st_Action_Date__c,Final_Action_by__c,Final_Action_by_Date__c,Additional_Comments__c,Supplier_Group__c,'+
          'Nexeo_Main_Approver__c,Supplier_Main_Approver__c,Material_Description_Buying__c,Supplier_Supported_Price__c,Packaging_Allowance__c,'+
          'Dis2_Sell__c,Dis1_Sell__c,Freight_Allowance_Selling__c,Other_Allowances__c,New_or_Changed__c,'+
          'Supplier_Sales_Contact__c,Competitor_Name__c,Actual_Annual_Volume__c,Competitor_Manufacturer__c,Application__c,Market_Segment__c,Seller__c '+
          'from Price_Record__c where Status__c=' +'\''+PricerecordUtil.AWAITING_SUPPLIER_APPROVAL +'\' AND (Supplier_Group__c IN '+supplierGroupIds+' OR Supplier_Main_Approver__c='+'\''+UserInfo.getUserId()+'\')';
          if (customerName!=null && !customerName.equals(''))
          soql += 'and CustomerName_Mail__c LIKE \'%'+String.escapeSingleQuotes(customerName)+'%\'';
          
          system.debug(soql);
          supplierApprovalList=Database.query(soql);

 

Error is coming on red line.

 

Thanks in advance:)))

  • December 07, 2012
  • Like
  • 0

Hi,

 

Please help to resolve following error:

 

unexpected token: '.'

 

Error is coming for below code can anyone please suggest to resolve the following:

 

  List<Monthly_Plant_Hour__c> mph= Database.query('SELECT Name,Month__c,Reporting_Month__c,Employee__c,Man_hours__c,'
                                            +'Reporting_Year__c FROM Monthly_Plant_Hour__c '
                                                +'where '+ firstWhereClause + ' ' +secondWhereClause + ' order by Reporting_Month__c ');
                                                
        for(Integer i=0; i<mph.size();i++){


            finalmph.add(mph[i]);
        }
                                                
        return finalmph;
    }

 

 

Thanks in advance:))))

  • November 25, 2012
  • Like
  • 0

Hi,

 

Can anyone please suggest to write test class for my below class,because of that i am not able to deploy my application in Production,its urgent please help.

 

public class planthourExtension {
private final Get_Hour_Report__cplant;
public String year;
public String previousYear;
public Integer intYear = 0;
public Integer intPreviousYear = 0;
public String reporttype;
public String reportperiod;
public String reportCategory;
public String facility;
public String country;
public String plantDivision;
List<Decimal> cumulativemanhr=new List<Decimal>();
List<Decimal> cummanhr1 = new List<Decimal>();
List<Decimal> avgemployee = new List<Decimal>();
Decimal **bleep** = 0;
decimal hr = 0;
List<Monthly_home_Hour__c> incidentrec = new list<Monthly_home_Hour__c>(); 
public string firstWhereClause = '';
public string secondWhereClause = '';
public string secondWhereClause1 = '';
public List<string> mon = new List<String>();

public planthourExtension(ApexPages.StandardController controller) {

this.plant = (Plant_Hours_Report__c)controller.getRecord();
Get_Hour_Report__co = [Select Country__c,Division_div__c,Facility__c, Reporting_Category__c,
Report_Year__c,Report_Type__c,Reporting_Period__c
From Get_Hour_Report__cWhere Id =: plant.Id];

year= o.Report_Year__c;
if(year!= null){
intYear = Integer.valueof(year);
intPreviousYear = intYear - 1;
previousYear = String.valueof(intPreviousYear);
}
reporttype=o.Report_Type__c;
reportperiod=o.Reporting_Period__c;
facility = o.Facility__c;
reportCategory = o.Reporting_Category__c;
plantDivision = o.Division_div__c;
country = o.Country__c;
system.debug('reporttype is '+reporttype);

if(reporttype == 'Facility'){
firstWhereClause = 'Facility__c = \''+facility+'\' and Reporting_Category__c =\''+reportCategory+'\'';
}else if(reporttype == 'Sub'){
firstWhereClause = ' Country__c = \''+country+'\' and Reporting_Category__c =\''+reportCategory+'\'';
}else if(reporttype == 'Division'){
firstWhereClause = ' Country__c = \''+country+'\' and Division__c = \''+plantDivision+'\'';
}else {
firstWhereClause = ' Country__c = \''+country+'\'';
}

Date currentDate = date.today();

Integer currentMonth = currentDate.month();
system.debug('Current Month is'+currentMonth );

String[] monthQuery = new String[]{};
String[] monthQuery1 = new String[]{};

if(reportperiod == 'Calendar'){
system.debug('Entered Calendar');
for(Integer i=1;i<=currentMonth;i++ ){
monthQuery.add('\''+String.valueof(i)+'\'');
}
system.debug('monthQuery is '+monthQuery);
secondWhereClause = ' and Reporting_Year__c =\''+year+'\' and Reporting_Month__c in '+monthQuery+'';

}else if(reportperiod == 'Fiscal'){
system.debug('Entered Fiscal');
if(currentMonth >= 10){
for(Integer i=10;i<=currentMonth;i++ ){
monthQuery.add('\''+String.valueof(i)+'\'');
}
}else{
for(Integer i=1;i<=currentMonth;i++ ){
monthQuery.add('\''+String.valueof(i)+'\'');
}
for(Integer i=10;i<=12;i++ ){
monthQuery1.add('\''+String.valueof(i)+'\'');
}
}
secondWhereClause = ' and Reporting_Year__c =\''+year+'\' and Reporting_Month__c in '+monthQuery+'';
secondWhereClause1 = ' and Reporting_Year__c =\''+previousYear+'\' and Reporting_Month__c in '+monthQuery1+'';

}else if(reportperiod == 'Rolling'){
system.debug('Entered Rolling');
for(Integer i=1;i<currentMonth;i++ ){
monthQuery.add('\''+String.valueof(i)+'\'');
}
for(Integer i=currentMonth;i<=12;i++ ){
monthQuery1.add('\''+String.valueof(i)+'\'');
}

secondWhereClause = ' and Reporting_Year__c =\''+year+'\' and Reporting_Month__c in '+monthQuery+' ';
secondWhereClause1 = ' and Reporting_Year__c =\''+previousYear+'\' and Reporting_Month__c in '+monthQuery1+'';
}




public List<Monthly_home_Hour__c> getManhour() {

List<Monthly_home_Hour__c> finalmph = new List<Monthly_home_Hour__c>();


if(!secondWhereClause1.equals('')){

List<Monthly_home_Hour__c> mph1= Database.query('SELECT Name,Month__c,Reporting_Month__c,Employee__c,Man_hours__c,'
+'Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause+ ' ' + secondWhereClause1 + ' order by Reporting_Month__c ');

for(Integer i=0; i<mph1.size();i++){
finalmph.add(mph1[i]);


List<Monthly_home_Hour__c> mph= Database.query('SELECT Name,Month__c,Reporting_Month__c,Employee__c,Man_hours__c,'
+'Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause + ' ' +secondWhereClause + ' order by Reporting_Month__c ');

for(Integer i=0; i<mph.size();i++){
finalmph.add(mph[i]);
}

return finalmph;
}

public List<Decimal> getCumulativeManhour() {

Decimal cummanhr = 0;
Decimal cummanhrcum = 0;


if(!secondWhereClause1.equals('')){

List<Monthly_home_Hour__c> mph1= Database.query('SELECT Name,Reporting_Month__c,Employee__c,Man_hours__c,'
+'Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause+ ' ' + secondWhereClause1 + ' order by Reporting_Month__c ');

if(mph1.size()>0){
for(Integer i=0;i<mph1.size();i++)
{
cummanhr =mph1[i].Man_hours__c;
cummanhrcum = cummanhrcum + cummanhr;
cummanhr1.add(cummanhrcum);
}
}

List<Monthly_home_Hour__c> mph= Database.query('SELECT Name,Reporting_Month__c,Employee__c,Man_hours__c,'
+'Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause + ' ' +secondWhereClause + ' order by Reporting_Month__c ');

if(mph.size()>0){
for(Integer i=0;i<mph.size();i++)
{
cummanhr =mph[i].Man_hours__c;
cummanhrcum = cummanhrcum + cummanhr;
cummanhr1.add(cummanhrcum);
}

return cummanhr1;
}
public List<Decimal> getAverageEmployee() {
Integer i= 0;
Integer j= 0;
Decimal avgemp = 0;
Decimal avgemployeeset = 0;

if(!secondWhereClause1.equals('')){

List<Monthly_home_Hour__c> mph1= Database.query('SELECT Name,Reporting_Month__c,Employee__c,Man_hours__c,'
+'Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause+ ' ' + secondWhereClause1 + ' order by Reporting_Month__c ');

if(mph1.size()>0){

avgemployeeset = 0;
for(i=0;i<mph1.size();i++)
{
avgemp =mph1[i].Employee__c;

avgemployeeset = ((avgemployeeset*i) + avgemp)/(i+1);

avgemployee.add(avgemployeeset);
j = i+1;
}
}

List<Monthly_home_Hour__c> mph= Database.query('SELECT Name,Reporting_Month__c,Employee__c,Man_hours__c,'
+'Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause + ' ' +secondWhereClause + ' order by Reporting_Month__c ');

if(mph.size()>0){
for(Integer m=0;m<mph.size();m++)
{
avgemp =mph[m].Employee__c;

avgemployeeset = ((avgemployeeset*j) + avgemp)/(j+1);

avgemployee.add(avgemployeeset);
j++;
}
}

return avgemployee;
}


public List<Monthly_home_Hour__c> getCumulativeRolling() {

List<Monthly_home_Hour__c> finalmph = new List<Monthly_home_Hour__c>();

if(!secondWhereClause1.equals('')){
List<Monthly_home_Hour__c> mph1= Database.query('SELECT Name,Month__c,Reporting_Month__c,Incidents__c,Total_Recordable_Rate__c,'
+' Lost_Work_Incidents__c,Lost_Work_Rate__c,Days_Away_From_work__c,'
+' Days_Away_From_Work_Rate__c,Medical_Treatment__c, '
+' Medical_Treatment_Rate__c,Fatalities__c,'
+' Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause+ ' ' + secondWhereClause1 + ' order by Reporting_Month__c ');

for(Integer i=0; i<mph1.size();i++){
finalmph.add(mph1[i]);
}

}
List<Monthly_home_Hour__c> mph= Database.query('SELECT Name,Month__c,Reporting_Month__c,Incidents__c,Total_Recordable_Rate__c,'
+' Lost_Work_Incidents__c,Lost_Work_Rate__c,Days_Away_From_work__c,'
+' Days_Away_From_Work_Rate__c,Medical_Treatment__c, '
+' Medical_Treatment_Rate__c,Fatalities__c,'
+' Reporting_Year__c FROM Monthly_home_Hour__c '
+'where '+ firstWhereClause+ ' ' + secondWhereClause + ' order by Reporting_Month__c ');

for(Integer i=0; i<mph.size();i++){
finalmph.add(mph[i]);
}
return finalmph;
}
}

 

Thanks in advance:)))

 

  • November 25, 2012
  • Like
  • 0

Hi,

 

I am mass cloning the record and for mass cloning the attachment i have written the trigger but its cloning the attachment of first record only and i want to mass clone the attachment with record also.

 

Can anyone please help me to resolve mu problem .Help will really appriciated.Please find attached my trigger below.What changes needed to do for mass cloning the attachment also.

 

trigger CopyAttachments on New_Support__c(after insert)
{
List<Id> parentIds=new List<Id>();
Attachment[] attList = [select id, name, body from Attachment where ParentId = :Trigger.new[0].Parent_New_Support__c];
Attachment[] insertAttList = new Attachment[]{};

for(Attachment a: attList)
{
Attachment att = new Attachment(name = a.name, body = a.body, parentid = Trigger.new[0].id);
insertAttList.add(att);
}
if(insertAttList.size() > 0)
{
insert insertAttList;
}

}

 

Thanks in advance:-)

  • November 20, 2012
  • Like
  • 0