• lakshya agrawal
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 27
    Replies
1.Create a trigger or workflow that will replace the piping (‘|’) in the name with an underscore (‘_’)

For example, TMT|NE|OC|AMD|Common Flow Migration|8.23 would be updated to:
TMT_NE_OC_AMD_Common Flow Migration_8.23

Naming Convention:-
1.Create a trigger or workflow that will replace the piping (‘|’) in the name with an underscore (‘_’)

 

For example, TMT|NE|OC|AMD|Common Flow Migration|8.23 would be updated to:

TMT_NE_OC_AMD_Common Flow Migration_8.23

 


 
Need to Apply Logic in this validation rule:-
Someone can help?


AND (
ISBLANK(SBQQ__AmendedContract__c ),
ISBLANK(SBQQ__RenewedContract__c),

OR(ISPICKVAL(StageName, 'Proposed'),
ISPICKVAL(StageName, 'Win Decision Expected'),
ISPICKVAL(StageName, 'Contracting'),
ISPICKVAL(StageName, 'Contract Signed')
),
OR(ISPICKVAL(NBR_Status__c, 'Not Started'),
ISPICKVAL(NBR_Status__c, 'Fast track - Submitted'),
ISPICKVAL(NBR_Status__c, 'Fast track - Stop'),
ISPICKVAL(NBR_Status__c, 'NBR 1A - Submitted'),
ISPICKVAL(NBR_Status__c, 'NBR 1A - Stop'),
ISPICKVAL(NBR_Status__c, 'NBR 1B - Stop'),
ISPICKVAL(NBR_Status__c, 'NBR 2 - Stop'),
ISPICKVAL(NBR_Status__c, 'NBR 3 - Stop')
)
)
 
Need to Apply Logic in this validation rule:-

AND (
ISBLANK(SBQQ__AmendedContract__c ),
ISBLANK(SBQQ__RenewedContract__c),

OR(ISPICKVAL(StageName, 'Proposed'),
ISPICKVAL(StageName, 'Win Decision Expected'),
ISPICKVAL(StageName, 'Contracting'),
ISPICKVAL(StageName, 'Contract Signed')
),
OR(ISPICKVAL(NBR_Status__c, 'Not Started'),
ISPICKVAL(NBR_Status__c, 'Fast track - Submitted'),
ISPICKVAL(NBR_Status__c, 'Fast track - Stop'),
ISPICKVAL(NBR_Status__c, 'NBR 1A - Submitted'),
ISPICKVAL(NBR_Status__c, 'NBR 1A - Stop'),
ISPICKVAL(NBR_Status__c, 'NBR 1B - Stop'),
ISPICKVAL(NBR_Status__c, 'NBR 2 - Stop'),
ISPICKVAL(NBR_Status__c, 'NBR 3 - Stop')
)
)
Question 1:- Create Trigger to fulfil below Scenarios?
1.1:- If AFAO Type Opportunity is Closed Won, Create new AFAO Opportunity.

Answer:- 

Apex Class:

public class TriggerHandlerOpportunity {
  public static Boolean isFirstTime = true;     
    public static void createNewAFAO(List<Opportunity> oppList,map<id,Opportunity> oldMap){
        List<Opportunity> OpportunityList = new List<Opportunity>();
        for(Opportunity op:oppList){
            if(op.Opportunity_Type__c == 'AFAO' &&  (op.StageName == 'Closed Signed Up (Won)' &&  oldMap.get(op.id).StageName != op.StageName)){
                Opportunity newOpportunity = new Opportunity();
                newOpportunity.Name = op.name;
                newOpportunity.StageName = op.Stagename;
                newOpportunity.CloseDate = op.CloseDate;
                newOpportunity.AccountId = op.AccountId;
                newOpportunity.Opportunity_Type__c = op.Opportunity_Type__c;
                 OpportunityList.add(newOpportunity);
                    
            }
        }
        insert OpportunityList;
        
    } 
}

Trigger:

trigger TriggerOnOpportunity on Opportunity (after update) {
       if(trigger.isafter && trigger.isupdate){
         if(TriggerHandlerOpportunity.isFirstTime ){
        TriggerHandlerOpportunity.isFirstTime = false;
        TriggerHandlerOpportunity.createNewAFAO(trigger.new,trigger.oldmap);
                  }
            } 
    }

1.2  Move all the existing USM Records with the status “Pending” to another AFPO, and "Convo started”/ “Open" to newly created AFAO.

Hint:

 (a) USM Object -Picklist Field “CAC Status”- (Values - Open, Convo started, Closed Won, Closed Lost, Pending) 

(b) Opportunity Object - Piclklist Field "Opportunity Type"-(Values-AFAO,NAFS,AFPO)

(c) Opportunity and Usm have lookup relationship between them.

(d) Opportunity is parent and USM is child.

Can anyone help by writing trigger for it 

Please see question 1.1 first i.e done but 1.2 can be done with help of 1.1.

please help me.
Question 1:- Create Trigger to fulfil below Scenarios?
1.1:- If AFAO Type Opportunity is Closed Won, Create new AFAO Opportunity.

Answer:- 

Apex Class:

public class TriggerHandlerOpportunity {
  public static Boolean isFirstTime = true;     
    public static void createNewAFAO(List<Opportunity> oppList,map<id,Opportunity> oldMap){
        List<Opportunity> OpportunityList = new List<Opportunity>();
        for(Opportunity op:oppList){
            if(op.Opportunity_Type__c == 'AFAO' &&  (op.StageName == 'Closed Signed Up (Won)' &&  oldMap.get(op.id).StageName != op.StageName)){
                Opportunity newOpportunity = new Opportunity();
                newOpportunity.Name = op.name;
                newOpportunity.StageName = op.Stagename;
                newOpportunity.CloseDate = op.CloseDate;
                newOpportunity.AccountId = op.AccountId;
                newOpportunity.Opportunity_Type__c = op.Opportunity_Type__c;
                 OpportunityList.add(newOpportunity);
                    
            }
        }
        insert OpportunityList;
        
    } 
}

Trigger:

trigger TriggerOnOpportunity on Opportunity (after update) {
       if(trigger.isafter && trigger.isupdate){
         if(TriggerHandlerOpportunity.isFirstTime ){
        TriggerHandlerOpportunity.isFirstTime = false;
        TriggerHandlerOpportunity.createNewAFAO(trigger.new,trigger.oldmap);
                  }
            } 
    }

1.2  Move all the existing USM Records with the status “Pending” to another AFPO, and "Convo started”/ “Open" to newly created AFAO.

Hint:

 (a) USM Object -Picklist Field “CAC Status”- (Values - Open, Convo started, Closed Won, Closed Lost, Pending) 

(b) Opportunity Object - Piclklist Field "Opportunity Type"-(Values-AFAO,NAFS,AFPO)

(c) Opportunity and Usm have lookup relationship between them.

(d) Opportunity is parent and USM is child.

Can anyone help by writing trigger for it 

Please see question 1.1 first i.e done but 1.2 can be done with help of 1.1.

please help me.
 
Trigger:

trigger TriggerOnOpportunity on Opportunity (after update) {
       if(trigger.isafter && trigger.isupdate){
        TriggerHandlerOpportunity.createNewAFAO(trigger.new,trigger.oldmap);
            } 
    }

Apex Class:

public class TriggerHandlerOpportunity {    
    public static void createNewAFAO(List<Opportunity> oppList,map<id,Opportunity> oldMap){
        List<Opportunity> OpportunityList = new List<Opportunity>();
        for(Opportunity op:oppList){
            if(op.Opportunity_Type__c == 'AFAO' &&  (op.StageName == 'Closed Signed Up (Won)' &&  oldMap.get(op.id).StageName != op.StageName)){
                Opportunity newOpportunity = new Opportunity();
                newOpportunity.Name = op.name;
                newOpportunity.StageName = op.Stagename;
                newOpportunity.CloseDate = op.CloseDate;
                newOpportunity.AccountId = op.AccountId;
                newOpportunity.Opportunity_Type__c = op.Opportunity_Type__c;
                 OpportunityList.add(newOpportunity);
                    
            }
        }
        insert OpportunityList;
        
    }
}
 
If NAFS Type Opportunity is Closed Won, Create new NAFS Opportunity.
 this app((https://app.wheniwork.com/ )) content in salesforce how to show??
Trigger OpportuniytTrigger On Opportunity(before update){
OpportuniytTriggerHandler.checkProduct(trigger.new);
}

public class OpportuniytTriggerHandler {

  public static void checkProduct(List<Opportunity> newRecords) {
        List<Id> oppIds =  new List<Id>();
for(Opportunity opp : newRecords)
        {
if(opp.StageName == 'Start' || opp.StageName == 'No Start' || opp.StageName == 'Delayed Start' || opp.StageName == 'Established Patien' || opp.StageName == 'Re-act')
            {
oppIds.add(opp.Id);
}
}

if(oppIds.size() > 0)
    {
List<OpportunityLineItem> oppProduct = [SELECT Id, Name FROM OpportunityLineItem WHERE OpportunityId IN : oppIds];
if(oppProduct.size() == 0 )
        {
newRecords[0].addError('Please select product to select the given StageName.');
}
}
}
}

is this trigger bulkified?
<lightning-record-edit-form object-api-name="Criteria__c" record-id={criteriaId} onsuccess={onSuccessCriteria}>
                    <lightning-messages data-id='formerror'></lightning-messages>
                    <lightning-input-field field-name="Name" required="true">
                        </lightning-input-field>
                    <lightning-input-field field-name="Valuation_Index__c">
                        </lightning-input-field>
                    <lightning-input-field field-name="Criteria_Item_Logic__c">
                        </lightning-input-field>
                    <lightning-input-field field-name="Criteria_Unique_ID__c">
                        </lightning-input-field>
                    </lightning-record-edit-form>

for the field - name ="Name"??/

Naming Convention:-
1.Create a trigger or workflow that will replace the piping (‘|’) in the name with an underscore (‘_’)

 

For example, TMT|NE|OC|AMD|Common Flow Migration|8.23 would be updated to:

TMT_NE_OC_AMD_Common Flow Migration_8.23

 


 
Need to Apply Logic in this validation rule:-

AND (
ISBLANK(SBQQ__AmendedContract__c ),
ISBLANK(SBQQ__RenewedContract__c),

OR(ISPICKVAL(StageName, 'Proposed'),
ISPICKVAL(StageName, 'Win Decision Expected'),
ISPICKVAL(StageName, 'Contracting'),
ISPICKVAL(StageName, 'Contract Signed')
),
OR(ISPICKVAL(NBR_Status__c, 'Not Started'),
ISPICKVAL(NBR_Status__c, 'Fast track - Submitted'),
ISPICKVAL(NBR_Status__c, 'Fast track - Stop'),
ISPICKVAL(NBR_Status__c, 'NBR 1A - Submitted'),
ISPICKVAL(NBR_Status__c, 'NBR 1A - Stop'),
ISPICKVAL(NBR_Status__c, 'NBR 1B - Stop'),
ISPICKVAL(NBR_Status__c, 'NBR 2 - Stop'),
ISPICKVAL(NBR_Status__c, 'NBR 3 - Stop')
)
)
Question 1:- Create Trigger to fulfil below Scenarios?
1.1:- If AFAO Type Opportunity is Closed Won, Create new AFAO Opportunity.

Answer:- 

Apex Class:

public class TriggerHandlerOpportunity {
  public static Boolean isFirstTime = true;     
    public static void createNewAFAO(List<Opportunity> oppList,map<id,Opportunity> oldMap){
        List<Opportunity> OpportunityList = new List<Opportunity>();
        for(Opportunity op:oppList){
            if(op.Opportunity_Type__c == 'AFAO' &&  (op.StageName == 'Closed Signed Up (Won)' &&  oldMap.get(op.id).StageName != op.StageName)){
                Opportunity newOpportunity = new Opportunity();
                newOpportunity.Name = op.name;
                newOpportunity.StageName = op.Stagename;
                newOpportunity.CloseDate = op.CloseDate;
                newOpportunity.AccountId = op.AccountId;
                newOpportunity.Opportunity_Type__c = op.Opportunity_Type__c;
                 OpportunityList.add(newOpportunity);
                    
            }
        }
        insert OpportunityList;
        
    } 
}

Trigger:

trigger TriggerOnOpportunity on Opportunity (after update) {
       if(trigger.isafter && trigger.isupdate){
         if(TriggerHandlerOpportunity.isFirstTime ){
        TriggerHandlerOpportunity.isFirstTime = false;
        TriggerHandlerOpportunity.createNewAFAO(trigger.new,trigger.oldmap);
                  }
            } 
    }

1.2  Move all the existing USM Records with the status “Pending” to another AFPO, and "Convo started”/ “Open" to newly created AFAO.

Hint:

 (a) USM Object -Picklist Field “CAC Status”- (Values - Open, Convo started, Closed Won, Closed Lost, Pending) 

(b) Opportunity Object - Piclklist Field "Opportunity Type"-(Values-AFAO,NAFS,AFPO)

(c) Opportunity and Usm have lookup relationship between them.

(d) Opportunity is parent and USM is child.

Can anyone help by writing trigger for it 

Please see question 1.1 first i.e done but 1.2 can be done with help of 1.1.

please help me.
 
Trigger:

trigger TriggerOnOpportunity on Opportunity (after update) {
       if(trigger.isafter && trigger.isupdate){
        TriggerHandlerOpportunity.createNewAFAO(trigger.new,trigger.oldmap);
            } 
    }

Apex Class:

public class TriggerHandlerOpportunity {    
    public static void createNewAFAO(List<Opportunity> oppList,map<id,Opportunity> oldMap){
        List<Opportunity> OpportunityList = new List<Opportunity>();
        for(Opportunity op:oppList){
            if(op.Opportunity_Type__c == 'AFAO' &&  (op.StageName == 'Closed Signed Up (Won)' &&  oldMap.get(op.id).StageName != op.StageName)){
                Opportunity newOpportunity = new Opportunity();
                newOpportunity.Name = op.name;
                newOpportunity.StageName = op.Stagename;
                newOpportunity.CloseDate = op.CloseDate;
                newOpportunity.AccountId = op.AccountId;
                newOpportunity.Opportunity_Type__c = op.Opportunity_Type__c;
                 OpportunityList.add(newOpportunity);
                    
            }
        }
        insert OpportunityList;
        
    }
}