• Sethu
  • NEWBIE
  • 90 Points
  • Member since 2014
  • Software Engineer

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 18
    Replies
In the order i have a custom field as order no, if i create a first record i enter the order no.
For the next time when i create record for the same contract number, the order no have to insert.How can i do that

Can anyone provide code please.
Hello everyone ,
I want to write a delete trigger on SPETemplate which is my custom object so that User can  only delete records whose stage__c='draft'.
i have written the following piece of code but it wont work...
suggetions are most welcome....

trigger deleteDraftTemplate on SPE_SPETemplate__c (before delete) {
    
    SPE_SPETemplate__c[] recs=new List<SPE_SPETemplate__c>();
for(SPE_SPETemplate__c rec:trigger.old)
{
  if(rec.Stage__c=='Draft')
  {
            SPE_SPETemplate__c tempSpeTemp=new SPE_SPETemplate__c(id=rec.id);
            recs.add(tempSpeTemp);
            //recs.add(rec);
  }
}
delete recs;  

}
Hi All,

I have 2 picklist fields:
1.) Tenure of Support:Values are 3 Years, 4 Years, 5 Years
2.) Installment Period: Monthly, Quarterly, Half-Yearly, Yearly.

Installments: It is another Field(Number)

1.)If i select Tenure of SUpport as 3 Years and Installment Period as Monthly, then update the Installments as 36.
2.)If i select Tenure of SUpport as 4 Years and Installment Period as Monthly, then update the Installments as 48.
3.)If i select Tenure of SUpport as 5 Years and Installment Period as Monthly, then update the Installments as 60.
4.)If i select Tenure of SUpport as 3 Years and Installment Period as Quarterly, then update the Installments as 12.
5.)If i select Tenure of SUpport as 4 Years and Installment Period as Quarterly, then update the Installments as 16.
6.)If i select Tenure of SUpport as 5 Years and Installment Period as Quarterly, then update the Installments as 20.
7.)If i select Tenure of SUpport as 3 Years and Installment Period as Half-Yearly, then update the Installments as 6.
8.)If i select Tenure of SUpport as 4 Years and Installment Period as Half-Yearly, then update the Installments as 8.
9.)If i select Tenure of SUpport as 5 Years and Installment Period as Half-Yearly, then update the Installments as 10.
10)If i select Tenure of SUpport as 3 Years and Installment Period as Yearly, then update the Installments as 3.
11)If i select Tenure of SUpport as 4 Years and Installment Period as Yearly, then update the Installments as 4.
12)If i select Tenure of SUpport as 5 Years and Installment Period as Yearly, then update the Installments as 5.

For that, We are going to use the Field Update evaluates formula.

Is it achieve by Filed update?

If you Say Yes, Can you try out and let me know?

Thanks In Advance..........
Dear All,

While invoking a VF Page through a standard button, users are getting the following error :
Insufficient Privileges You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. For more information, see Insufficient Privileges Errors.

However, I can invoke this VF Page as an administrator.

Please could you help me fix this problem.

An early  response on this will help.

Thanks.

Regards,

Debendra
In the order i have a custom field as order no, if i create a first record i enter the order no.
For the next time when i create record for the same contract number, the order no have to insert.How can i do that

Can anyone provide code please.
Hello everyone ,
I want to write a delete trigger on SPETemplate which is my custom object so that User can  only delete records whose stage__c='draft'.
i have written the following piece of code but it wont work...
suggetions are most welcome....

trigger deleteDraftTemplate on SPE_SPETemplate__c (before delete) {
    
    SPE_SPETemplate__c[] recs=new List<SPE_SPETemplate__c>();
for(SPE_SPETemplate__c rec:trigger.old)
{
  if(rec.Stage__c=='Draft')
  {
            SPE_SPETemplate__c tempSpeTemp=new SPE_SPETemplate__c(id=rec.id);
            recs.add(tempSpeTemp);
            //recs.add(rec);
  }
}
delete recs;  

}
Hi to all

senario : When Ever a record is creted in Student object , get the details in payment object also
student is parrent record && Payment is Child
Fields in Student
Student Name
Batch ( Lookup relation in Traing Object )
Fee
when u inserting the records student name , batch & Fee these fielda are display the payment object that aree student name  & Fee

 trigger studentregis on Student__c(After insert)
   {
        Student__c stu = trigger.New[0];
        Payment__C pay = New Payment__C (StudentName__c=pay.Name_c,
        StudentID = pay.ID,
                                      Batch__C      =pay.Batch__c,
                                      Fee__C       =pay.Fee__C);
             insert stu;
             
    }


Getting an error line 1 Column 1
                      
 
Hi All,

Is there a way to bypass validation rules in Triggers? I have created some new validation rules and I see triggers getting failed due to this.
OR is there any other way to implement validation  rules getting triggered only while manual entry?
Please advise.
Thanks
  • November 10, 2014
  • Like
  • 0
Hi,

I have a piece  of trigger which prevents duplicates on Contacts. I am looking forward to display the existing Contact for which the duplicate was attempted and thus the erro was thrown.
is it possible in this Trigger:

trigger Duplicate1 on Contact (before insert, before update) {
    set<Id> accIds = new set<Id>();

    for(Contact p :trigger.new){
        accIds.add(p.accountId);
    }
    map<Id,account> parentAccmap = new map<Id,account>([select Id,parentId,recordtypeId from account where Id IN :accIds and parentId!=NULL and recordtypeId='012600000005J5J']); //add Site record type Id here.

    set<ID> parentIds = new set<ID>();
    for(Account acc : parentAccmap.values()){
        parentIds.add(acc.parentId);
    }
    
    map<Id,Set<String>> parentPrMap = new map<Id,Set<String>>();
    list<Contact> prParentlist = [select ID,Email,Name,AccountId, Account.recordtypeId,Phone,FirstName, lastName from Contact where AccountId IN:parentIDs and Account.recordtypeId='012600000005J5I']; //add Customer record type Id here.
    for(Contact pr:prParentlist){
        if(parentPrMap.get(pr.AccountId) == null){
            parentPrMap.put(pr.AccountId, new Set<String>());
        }
        parentPrMap.get(pr.AccountId).add(pr.email);
        parentPrMap.get(pr.AccountId).add(pr.phone);
        parentPrMap.get(pr.AccountId).add(pr.firstname);
        parentPrMap.get(pr.AccountId).add(pr.lastname);
    }

list<Contact> prParentlist2 = [select ID,Email,Name,account.parentid, Account.recordtypeId,Phone,FirstName, lastName from Contact where account.parentid in :parentIDs and Account.recordtypeId='012600000005J5J']; //add Customer record type Id here.
    for(Contact pr:prParentlist2){
        if(parentPrMap.get(pr.account.parentid) == null){
            parentPrMap.put(pr.account.parentid, new Set<String>());
        }
        parentPrMap.get(pr.account.parentid).add(pr.email);
    }
    system.debug(parentPrMap);
    
    for(Contact prr:trigger.new){
        if(
            prr.email!=null
            && parentAccmap.containsKey(prr.Accountid)
            && parentPrMap.containsKey(parentAccmap.get(prr.Accountid).ParentId)
        ){
            if((parentPrMap.get(parentAccmap.get(prr.Accountid).ParentId).contains(prr.email))&&(parentPrMap.get(parentAccmap.get(prr.Accountid).ParentId).contains(prr.phone))&&(parentPrMap.get(parentAccmap.get(prr.Accountid).ParentId).contains(prr.lastname))){
                String baseUrl = URL.getSalesforceBaseUrl().toExternalForm()+'/02Z/e?parentId=';
                string errorMsg = '<a style=\'color:1B2BE8\'href="'+baseUrl+ prr.accountid +'"> Please Create a Contact Role  </a>';
                prr.addError('This Contact already exists.'+ errorMsg,false);
            }
        }   
    }
}
 
  • November 05, 2014
  • Like
  • 0
Hi All,

I have 2 picklist fields:
1.) Tenure of Support:Values are 3 Years, 4 Years, 5 Years
2.) Installment Period: Monthly, Quarterly, Half-Yearly, Yearly.

Installments: It is another Field(Number)

1.)If i select Tenure of SUpport as 3 Years and Installment Period as Monthly, then update the Installments as 36.
2.)If i select Tenure of SUpport as 4 Years and Installment Period as Monthly, then update the Installments as 48.
3.)If i select Tenure of SUpport as 5 Years and Installment Period as Monthly, then update the Installments as 60.
4.)If i select Tenure of SUpport as 3 Years and Installment Period as Quarterly, then update the Installments as 12.
5.)If i select Tenure of SUpport as 4 Years and Installment Period as Quarterly, then update the Installments as 16.
6.)If i select Tenure of SUpport as 5 Years and Installment Period as Quarterly, then update the Installments as 20.
7.)If i select Tenure of SUpport as 3 Years and Installment Period as Half-Yearly, then update the Installments as 6.
8.)If i select Tenure of SUpport as 4 Years and Installment Period as Half-Yearly, then update the Installments as 8.
9.)If i select Tenure of SUpport as 5 Years and Installment Period as Half-Yearly, then update the Installments as 10.
10)If i select Tenure of SUpport as 3 Years and Installment Period as Yearly, then update the Installments as 3.
11)If i select Tenure of SUpport as 4 Years and Installment Period as Yearly, then update the Installments as 4.
12)If i select Tenure of SUpport as 5 Years and Installment Period as Yearly, then update the Installments as 5.

For that, We are going to use the Field Update evaluates formula.

Is it achieve by Filed update?

If you Say Yes, Can you try out and let me know?

Thanks In Advance..........
Auction and Bid are objects in lookup where bid is child. For a given auction, I want to find out record id of Bid record with maximum bid amount. Can it be done with aggregate functions? I'm getting correct result when I execute the below mentioned query, but I'm unable to get the record id of bid record.

Select max(Bid_Amount__c) from Bid__c where auction__c='a0617000000MQzm'
Hi.

I am trying to deploy a trigger and test class to prodcution with code coverage of 100% .
My production coverage is 92% But when i validate my change set it says code coverage error-71% ..need 75%.

All my classes and triggers are almost 89-90% .

I just refreshed sandbox too to make sure both are in same settings.Stil same error.

Please help..I need this to solve ASAP!!! please.