• selva kumar 14
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 16
    Replies
Hi Everyone,

I need to convert this formula to SOQL Query. I have tried in many ways. But it shows parsing error.
Can anyone write me a SOQL Query for this. It would be great help to me.

AND (
  AND(
       ISBLANK(Last_Stage_Change__c),
       NOW() - LastModifiedDate > 30,
       Probability < 91,
       Probability > 1
      ),
   AND(
       NOW() - Last_Stage_Change__c  > 30,
       Probability < 91,
       Probability > 1
      )
  )



Please help. Thanks in advance.

 
Hi Everyone,

I have a requirement that, Opportunity StageProcess should hit each stages even if it jump to another stage. In other words,
a opportunity actual stage is "Prospecting" . Then his stage moved to "Closed Won" or any other higher stage. But i should show(Checked) in Opportunity Field history as he has came over all these stages like "Serviceablity","Construction","Job Scheduled","Implementation".

How i can able to acheive this? It maybe trigger or Validation Rule or anything?

It would be great help to me,if you have suggest some ideas.

Thanks in advance.
Hi Everyone,

I have a  issue in my trigger functionality.

My Requirement is given below.

If a  specific recordtype ("Bulk Record Type" ) opportunity is created,then it should select “k) Bulk  PriceBook".

After Save,If i change Bulk to some other record type,then  it should be changed to particular pricebook(Non Bulk Pricebook) .
As well as if other Recordtype to Bulk Record type it should change to "Bulk Pricebook" .
So i have created trigger regarding this requirement.

It is working for that,
1)  Bulk Record Type Choosen --> Bulk Pricebook Assigned
2) Other Record Type to Bulk Change -->Bulk Pricebook Assigned

My only issue with this is,
If i Change Bulk Record type to Other Record Type Pricebook doesn't change.It remains in same Bulk Pricebook.

Is it cases related to where use insert,update in a if else statements?

Please any one help me in my coding to find out.

My trigger is given below.

trigger BulkPricebookOpp on Opportunity (before insert,before update)
{
          if(trigger.isInsert || trigger.isUpdate) {
                 List<Pricebook2> prcbooklists = [select id,name from pricebook2];
                 Map<String,Id> prcbookMaps = new Map<String,Id>();
                 List<RecordType> recordtypId =  [Select Id,Name From RecordType Where SobjectType = 'Opportunity'];
                 Map<Id,String> recMap = new Map<Id,String>();
                  Set<Opportunity> OppItrortunityUpdatesIds = new Set<Opportunity>();
                                               
                if(!prcbooklists.isEmpty()){
                    for(Pricebook2 prcIter : prcbooklists){
                        prcbookMaps.put(prcIter.name,prcIter.id);
                    }
                }
                System.debug('==prcmap'+prcbookMaps);
                
                              
                  for(RecordType rectyp : recordtypId){
                        recMap.put(rectyp.Id,rectyp.name);
                    }       
                 
                            
                for(Opportunity OppItrs : Trigger.new){
                    if(prcbookMaps.size() > 0) {    
                            
                        if (recMap.get(OppItrs.RecordTypeId) == 'k) Bulk Services'){
                            OppItrs.Pricebook2Id = prcbookMaps.get('Bulk Price Book');
                        }
                    }    
        
        else if(Trigger.isAfter)
        {
        if(Trigger.isUpdate)
        {
                List<Pricebook2> prcbooklist = [select id,name from pricebook2];
                 Map<String,Id> prcbookMap = new Map<String,Id>();
                 Map<Id,String> Accmap = new Map<Id,String>();
                 Set<Opportunity> OppItrortunityUpdateIds = new Set<Opportunity>();
                 Set<Id> accountIds = new Set<Id>();
                              
                if(!prcbooklist.isEmpty()){
                    for(Pricebook2 prcIter : prcbooklist){
                        prcbookMap.put(prcIter.name,prcIter.id);
                    }
                }
                System.debug('==prcmap'+prcbookMap);
                
                for(Opportunity OppIdsItr : Trigger.new){
                    accountIds.add(OppIdsItr.accountid);
                    
                }
                for(Account AccItr : [SELECT id,Region__c FROM Account WHERE Id IN:accountIds]){
                    Accmap.put(AccItr.id,AccItr.Region__c);
                }
            
                for(Opportunity OppItr : Trigger.new){
                    if(prcbookMap.size() > 0){    
                            
                        if (Accmap.get(OppItr.accountId) == 'Service 3'){
                            OppItr.Pricebook2Id = prcbookMap.get('Non Bulk Price Book - 3');
                        }
                        else if(Accmap.get(OppItr.accountId) == ' Service 2'){
                            OppItr.Pricebook2Id = prcbookMap.get('Non Bulk Price Book - 2');
                       }
                     }
                 }
             }
        }
    }
  }
}


Thanks in advance
Hi Everyone,

I have a  issue in my trigger functionality.

My Requirement is given below.

If a  specific recordtype ("Bulk Record Type" ) opportunity is created,then it should select “k) Bulk  PriceBook".

After Save,If i change Bulk to some other record type,then  it should be changed to particular pricebook(Non Bulk Pricebook) .
As well as if other Recordtype to Bulk Record type it should change to "Bulk Pricebook" .
So i have created trigger regarding this requirement.

It is working for that,
1)  Bulk Record Type Choosen --> Bulk Pricebook Assigned
2) Other Record Type to Bulk Change -->Bulk Pricebook Assigned

My only issue with this is,
If i Change Bulk Record type to Other Record Type Pricebook doesn't change.It remains in same Bulk Pricebook.


Is it cases related to where use insert,update in a if else statements?

Please any one help me in my coding to find out.

My trigger is given below.

trigger BulkPricebookOpp on Opportunity (before insert,before update)
{
          if(trigger.isInsert || trigger.isUpdate) {
                 List<Pricebook2> prcbooklists = [select id,name from pricebook2];
                 Map<String,Id> prcbookMaps = new Map<String,Id>();
                 List<RecordType> recordtypId =  [Select Id,Name From RecordType Where SobjectType = 'Opportunity'];
                 Map<Id,String> recMap = new Map<Id,String>();
                  Set<Opportunity> OppItrortunityUpdatesIds = new Set<Opportunity>();
                                               
                if(!prcbooklists.isEmpty()){
                    for(Pricebook2 prcIter : prcbooklists){
                        prcbookMaps.put(prcIter.name,prcIter.id);
                    }
                }
                System.debug('==prcmap'+prcbookMaps);
                
                              
                  for(RecordType rectyp : recordtypId){
                        recMap.put(rectyp.Id,rectyp.name);
                    }       
                 
                            
                for(Opportunity OppItrs : Trigger.new){
                    if(prcbookMaps.size() > 0) {    
                            
                        if (recMap.get(OppItrs.RecordTypeId) == 'k) Bulk Services'){
                            OppItrs.Pricebook2Id = prcbookMaps.get('Bulk Price Book');
                        }
                    }    
        
        else if(Trigger.isAfter)
        {
        if(Trigger.isUpdate)
        {
                List<Pricebook2> prcbooklist = [select id,name from pricebook2];
                 Map<String,Id> prcbookMap = new Map<String,Id>();
                 Map<Id,String> Accmap = new Map<Id,String>();
                 Set<Opportunity> OppItrortunityUpdateIds = new Set<Opportunity>();
                 Set<Id> accountIds = new Set<Id>();
                              
                if(!prcbooklist.isEmpty()){
                    for(Pricebook2 prcIter : prcbooklist){
                        prcbookMap.put(prcIter.name,prcIter.id);
                    }
                }
                System.debug('==prcmap'+prcbookMap);
                
                for(Opportunity OppIdsItr : Trigger.new){
                    accountIds.add(OppIdsItr.accountid);
                    
                }
                for(Account AccItr : [SELECT id,Region__c FROM Account WHERE Id IN:accountIds]){
                    Accmap.put(AccItr.id,AccItr.Region__c);
                }
            
                for(Opportunity OppItr : Trigger.new){
                    if(prcbookMap.size() > 0){    
                            
                        if (Accmap.get(OppItr.accountId) == 'Service 3'){
                            OppItr.Pricebook2Id = prcbookMap.get('Non Bulk Price Book - 3');
                        }
                        else if(Accmap.get(OppItr.accountId) == ' Service 2'){
                            OppItr.Pricebook2Id = prcbookMap.get('Non Bulk Price Book - 2');
                       }
                     }
                 }
             }
        }
    }
  }
}



Thanks in advance.
Hi Everyone,

I have executed a test case in sandbox. But it throws the follwoing error.

Error:
System.QueryException: List has no rows for assignment to SObject

Stack Trace:
Class.TestBulkPricebookOpp.validatepric: line 6, column 1

I couldn't able to resolve it. My test class coding is given below.

@isTest
public class TestBulkPricebookOpp {
    Public static testmethod void validatepric(){
    Id pbID = null;

    pbID = [Select Name, Description From Pricebook2 where Name = 'Bulk Price Book'].Id;
    List<RecordType> recordtypId =  [Select SobjectType, Name, Id, DeveloperName From RecordType  Where SobjectType = 'Opportunity' And  Name = 'k) Bulk Services'];
Account obj = new Account( Name = 'Test', Zip_Code__c='29801');
insert obj;

Opportunity objOpp = new Opportunity(Name = 'newTest',recordtypeId=recordtypId[0].Id,AccountId = obj.Id,StageName ='Prospecting',CloseDate=Date.today());
        objOpp.Pricebook2Id=pbID;       
insert objOpp;

Opportunity objUOppt = new opportunity(Id =objOpp.Id );
update objUOppt ;

}
}


Please any one correct me in the coding part. Thanks in advance.
Hi Everyone,

I have a trigger that was properly ran in sandbox. When i try to deploy it into production getting deployment failed. The details shown below.

Apex Test Failures:
TestMultipleDLsTrigger validateMDLs System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, BulkPricebookOpp: execution of BeforeInsert caused by: System.QueryException: List has no rows for assignment to SObject Trigger.BulkPricebookOpp: line 7, column 1: []
Stack Trace: Class.TestMultipleDLsTrigger.validateMDLs: line 5, column 1


Trigger :

trigger BulkPricebookOpp on Opportunity (before insert,before update)
{   
    Id pbID = null;
    Id recordtypId = null;   
    pbID = [Select Name, Description From Pricebook2 where Name =: 'Bulk Price Book'].Id;
    recordtypId =  [Select SobjectType, Name, Id, DeveloperName From RecordType  Where SobjectType = 'Opportunity' And  Name = 'k) Bulk Services'].Id;   

   for(Opportunity obj : trigger.new)
   {
        if(obj.RecordTypeId  == recordtypId)
        {
            obj.Pricebook2Id = pbID;
        }
        }
        }

Is it the reason that which i directly called "Bulk Price Book" name.

Is need to modify trigger in sandbox??

Please any one help on this.
Hi everyone,

I need test cases for the both triggers. Please any one help on this.

Trigger 1 :

trigger ReferralPartner_Lead on Lead (before Insert,before update) {   
    Set<String> referrerNames=new Set<String>();   
    for (Lead ld : trigger.new)
    {
        referrerNames.add(ld.Referral_Text__c);
    }
     System.debug('+++referaltext'+referrerNames);
    Map<String, Referral_Partner__c> refPtrsByName=new Map<String, Referral_Partner__c>();
    for (Referral_Partner__c refPtr : [select id, Name from Referral_Partner__c where name in :referrerNames])
    {
        refPtrsByName.put(refPtr.Name, refPtr);
    }
     System.debug('+++===referalName'+refPtrsByName);   
    for (Lead ld : trigger.new)
    {
        Referral_Partner__c refPtr=refPtrsByName.get(ld.Referral_Text__c);
        if (null!=refPtr)
        {
            ld.Referral_Partner__c=refPtr.id;
        }
       System.debug('+++++++++referalPart'+ld.Referral_Partner__c);
    }
}


Trigger 2 :

trigger BulkPricebookOpp on Opportunity (before insert,before update)
{   
    Id pbID = null;
    Id recordtypId = null;   
    pbID = [Select Name, Description From Pricebook2 where Name =: 'Bulk Price Book'].Id;
    recordtypId =  [Select SobjectType, Name, Id, DeveloperName From RecordType  Where SobjectType = 'Opportunity' And  Name = 'k) Bulk Services'].Id;   
   for(Opportunity obj : trigger.new)
   {
        if(obj.RecordTypeId  == recordtypId)
        {
            obj.Pricebook2Id = pbID;
        }
        else
        {
        if(Trigger.isUpdate){
                List<Pricebook2> prcbooklist = [select id,name from pricebook2];
                 Map<String,Id> prcbookMap = new Map<String,Id>();
                 Map<Id,String> cccAccmap = new Map<Id,String>();
                 Set<Opportunity> OppItrortunityUpdateIds = new Set<Opportunity>();
                 Set<Id> accountIds = new Set<Id>();                             
                if(!prcbooklist.isEmpty()){
                    for(Pricebook2 prcIter : prcbooklist){
                        prcbookMap.put(prcIter.name,prcIter.id);
                    }
                }
                System.debug('==prcmap'+prcbookMap);               
                for(Opportunity OppIdsItr : Trigger.new){
                    accountIds.add(OppIdsItr.accountid);
                    
                }
                for(Account AccItr : [SELECT id,Region__c FROM Account WHERE Id IN:accountIds]){
                    cccAccmap.put(AccItr.id,AccItr.Region__c);
                }           
                for(Opportunity OppItr : Trigger.new){
                    if(prcbookMap.size() > 0){    
                            
                        if (cccAccmap.get(OppItr.accountId) == 'P1'){
                            OppItr.Pricebook2Id = prcbookMap.get('Price Book - 1');
                        }
                        else if(cccAccmap.get(OppItr.accountId) == 'P2'){
                            OppItr.Pricebook2Id = prcbookMap.get('Price Book - 2');
                       }
                                            
                      }
                      System.debug('====assign'+OppItr.Pricebook2Id);
                }
            }
        }
   }
}



Thanks in advance.

 
Hi Everyone,

I don't have much knowledge about apex coding. I have tried few triggers using some developers sample available in discussion forums. But i can't able to acheive my goal. My requirement is given below.

There are a few fields that cannot be updated through the standard SalesForce interface, and can only be updated via Apex code.  We need to duplicate some information from a text field on the Lead and Opportunity screens, and populate it into a lookup field in the same object. Required details are given below.

Object - Lead/Opportunity
Originating field (from) - Referral Text (text)
Destination field (to)  - Referral Partner (lookup)
When to trigger - Upon update/Insert of Referral Text value


It would be much apprciate,share few sample codings. Please help on this.

Thanks in advance.
Hi Everyone,

I need a help to find out API / suggestions . My concern is that, I need to populate data from webform to salesforce. this data need to be insert or update SF objects.

For example, I have data in my webform that, Name, Account Number, email,zipcode. I need to pass these values to a custom object called credits. Before that, I need to check that Account numbers is available in Accounts.
If available,i need to create a opportunity,then within that opportunity i create credits and store the data.
If Accounts not available then need to create a New Account, then create a opportunity,then within that opportunity i create credits and store the data.

Please guide me to acheive this... Thanks in advance.
Hi Everyone,

I don't have much knowledge about coding. I have tried few triggers using some developers sample available in discussion board. But i can't able to acheive my goal. My requirement is given below.

There are a few fields that cannot be updated through the standard SalesForce interface, and can only be updated via Apex code.  We need to duplicate some information from a text field on the Lead and Opportunity screens, and populate it into a lookup field.  Please see the details below:

Object - Lead
Originating field (from) - Referral Text (text)
Destination field (to)  - Referral Partner (lookup)
When to trigger - Upon update/Insert of Referral Text value


Can anyone please help on this.

Thanks in advance.

My trigger which i have created is given below. But it doesn't work.

       trigger Referral_Lead on Lead(After insert || After Update) { {
        for(Lead newLead:Trigger.new){       
            if (newLead.Referral_Text__c!=null) {            
                String refString = newLead.Referral_Text__c;           
                Id referralID = refString;           
                newLead.Referral_Partner__c = referralID;      
            }     
        }   
    }
    }


 
Hi Everyone,

I need to convert this formula to SOQL Query. I have tried in many ways. But it shows parsing error.
Can anyone write me a SOQL Query for this. It would be great help to me.

AND (
  AND(
       ISBLANK(Last_Stage_Change__c),
       NOW() - LastModifiedDate > 30,
       Probability < 91,
       Probability > 1
      ),
   AND(
       NOW() - Last_Stage_Change__c  > 30,
       Probability < 91,
       Probability > 1
      )
  )



Please help. Thanks in advance.

 
Hi Everyone,

I have a requirement that, Opportunity StageProcess should hit each stages even if it jump to another stage. In other words,
a opportunity actual stage is "Prospecting" . Then his stage moved to "Closed Won" or any other higher stage. But i should show(Checked) in Opportunity Field history as he has came over all these stages like "Serviceablity","Construction","Job Scheduled","Implementation".

How i can able to acheive this? It maybe trigger or Validation Rule or anything?

It would be great help to me,if you have suggest some ideas.

Thanks in advance.
Hi Everyone,

I have a  issue in my trigger functionality.

My Requirement is given below.

If a  specific recordtype ("Bulk Record Type" ) opportunity is created,then it should select “k) Bulk  PriceBook".

After Save,If i change Bulk to some other record type,then  it should be changed to particular pricebook(Non Bulk Pricebook) .
As well as if other Recordtype to Bulk Record type it should change to "Bulk Pricebook" .
So i have created trigger regarding this requirement.

It is working for that,
1)  Bulk Record Type Choosen --> Bulk Pricebook Assigned
2) Other Record Type to Bulk Change -->Bulk Pricebook Assigned

My only issue with this is,
If i Change Bulk Record type to Other Record Type Pricebook doesn't change.It remains in same Bulk Pricebook.

Is it cases related to where use insert,update in a if else statements?

Please any one help me in my coding to find out.

My trigger is given below.

trigger BulkPricebookOpp on Opportunity (before insert,before update)
{
          if(trigger.isInsert || trigger.isUpdate) {
                 List<Pricebook2> prcbooklists = [select id,name from pricebook2];
                 Map<String,Id> prcbookMaps = new Map<String,Id>();
                 List<RecordType> recordtypId =  [Select Id,Name From RecordType Where SobjectType = 'Opportunity'];
                 Map<Id,String> recMap = new Map<Id,String>();
                  Set<Opportunity> OppItrortunityUpdatesIds = new Set<Opportunity>();
                                               
                if(!prcbooklists.isEmpty()){
                    for(Pricebook2 prcIter : prcbooklists){
                        prcbookMaps.put(prcIter.name,prcIter.id);
                    }
                }
                System.debug('==prcmap'+prcbookMaps);
                
                              
                  for(RecordType rectyp : recordtypId){
                        recMap.put(rectyp.Id,rectyp.name);
                    }       
                 
                            
                for(Opportunity OppItrs : Trigger.new){
                    if(prcbookMaps.size() > 0) {    
                            
                        if (recMap.get(OppItrs.RecordTypeId) == 'k) Bulk Services'){
                            OppItrs.Pricebook2Id = prcbookMaps.get('Bulk Price Book');
                        }
                    }    
        
        else if(Trigger.isAfter)
        {
        if(Trigger.isUpdate)
        {
                List<Pricebook2> prcbooklist = [select id,name from pricebook2];
                 Map<String,Id> prcbookMap = new Map<String,Id>();
                 Map<Id,String> Accmap = new Map<Id,String>();
                 Set<Opportunity> OppItrortunityUpdateIds = new Set<Opportunity>();
                 Set<Id> accountIds = new Set<Id>();
                              
                if(!prcbooklist.isEmpty()){
                    for(Pricebook2 prcIter : prcbooklist){
                        prcbookMap.put(prcIter.name,prcIter.id);
                    }
                }
                System.debug('==prcmap'+prcbookMap);
                
                for(Opportunity OppIdsItr : Trigger.new){
                    accountIds.add(OppIdsItr.accountid);
                    
                }
                for(Account AccItr : [SELECT id,Region__c FROM Account WHERE Id IN:accountIds]){
                    Accmap.put(AccItr.id,AccItr.Region__c);
                }
            
                for(Opportunity OppItr : Trigger.new){
                    if(prcbookMap.size() > 0){    
                            
                        if (Accmap.get(OppItr.accountId) == 'Service 3'){
                            OppItr.Pricebook2Id = prcbookMap.get('Non Bulk Price Book - 3');
                        }
                        else if(Accmap.get(OppItr.accountId) == ' Service 2'){
                            OppItr.Pricebook2Id = prcbookMap.get('Non Bulk Price Book - 2');
                       }
                     }
                 }
             }
        }
    }
  }
}


Thanks in advance
Hi Everyone,

I have executed a test case in sandbox. But it throws the follwoing error.

Error:
System.QueryException: List has no rows for assignment to SObject

Stack Trace:
Class.TestBulkPricebookOpp.validatepric: line 6, column 1

I couldn't able to resolve it. My test class coding is given below.

@isTest
public class TestBulkPricebookOpp {
    Public static testmethod void validatepric(){
    Id pbID = null;

    pbID = [Select Name, Description From Pricebook2 where Name = 'Bulk Price Book'].Id;
    List<RecordType> recordtypId =  [Select SobjectType, Name, Id, DeveloperName From RecordType  Where SobjectType = 'Opportunity' And  Name = 'k) Bulk Services'];
Account obj = new Account( Name = 'Test', Zip_Code__c='29801');
insert obj;

Opportunity objOpp = new Opportunity(Name = 'newTest',recordtypeId=recordtypId[0].Id,AccountId = obj.Id,StageName ='Prospecting',CloseDate=Date.today());
        objOpp.Pricebook2Id=pbID;       
insert objOpp;

Opportunity objUOppt = new opportunity(Id =objOpp.Id );
update objUOppt ;

}
}


Please any one correct me in the coding part. Thanks in advance.
Hi Everyone,

I have a trigger that was properly ran in sandbox. When i try to deploy it into production getting deployment failed. The details shown below.

Apex Test Failures:
TestMultipleDLsTrigger validateMDLs System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, BulkPricebookOpp: execution of BeforeInsert caused by: System.QueryException: List has no rows for assignment to SObject Trigger.BulkPricebookOpp: line 7, column 1: []
Stack Trace: Class.TestMultipleDLsTrigger.validateMDLs: line 5, column 1


Trigger :

trigger BulkPricebookOpp on Opportunity (before insert,before update)
{   
    Id pbID = null;
    Id recordtypId = null;   
    pbID = [Select Name, Description From Pricebook2 where Name =: 'Bulk Price Book'].Id;
    recordtypId =  [Select SobjectType, Name, Id, DeveloperName From RecordType  Where SobjectType = 'Opportunity' And  Name = 'k) Bulk Services'].Id;   

   for(Opportunity obj : trigger.new)
   {
        if(obj.RecordTypeId  == recordtypId)
        {
            obj.Pricebook2Id = pbID;
        }
        }
        }

Is it the reason that which i directly called "Bulk Price Book" name.

Is need to modify trigger in sandbox??

Please any one help on this.
Hi Everyone,

I don't have much knowledge about apex coding. I have tried few triggers using some developers sample available in discussion forums. But i can't able to acheive my goal. My requirement is given below.

There are a few fields that cannot be updated through the standard SalesForce interface, and can only be updated via Apex code.  We need to duplicate some information from a text field on the Lead and Opportunity screens, and populate it into a lookup field in the same object. Required details are given below.

Object - Lead/Opportunity
Originating field (from) - Referral Text (text)
Destination field (to)  - Referral Partner (lookup)
When to trigger - Upon update/Insert of Referral Text value


It would be much apprciate,share few sample codings. Please help on this.

Thanks in advance.
Hi Everyone,

I need a help to find out API / suggestions . My concern is that, I need to populate data from webform to salesforce. this data need to be insert or update SF objects.

For example, I have data in my webform that, Name, Account Number, email,zipcode. I need to pass these values to a custom object called credits. Before that, I need to check that Account numbers is available in Accounts.
If available,i need to create a opportunity,then within that opportunity i create credits and store the data.
If Accounts not available then need to create a New Account, then create a opportunity,then within that opportunity i create credits and store the data.

Please guide me to acheive this... Thanks in advance.