• Scott Janis 20
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 4
    Replies
How can I write a text class for this code. 

trigger MDP_Tgr_OpportunityLineItem_Before on OpportunityLineItem (before insert, before update, before delete) {
    system.debug('invoking the before trigger of OpportunityLineItem');
    // for update
    if(trigger.isUpdate || trigger.isInsert){
      if(trigger.isInsert){
          MDP_Tgr_OppLine_Handler.assignOppFieldValuesToOLI(trigger.new);
        }
        if(trigger.isUpdate) {
            MDP_Tgr_OppLine_Handler.updateTitle(trigger.new);
            MDP_Tgr_OppLine_Handler.checkFieldValueChange(trigger.new, trigger.oldMap);
        }
        MDP_Tgr_OppLine_Handler.updateOracleOverride(trigger.new);  
         //MDP_Tgr_OppLine_Handler.checkTotalNEP(trigger.new, trigger.newMap);    // moved to after trigger
    }
    if(trigger.isDelete){      
      system.debug('in the Delete');  
        MDP_Tgr_OppLine_Handler.operativeAPIProfileGotError(trigger.old);
        MDP_Tgr_OppLine_Handler.insertOppLineItemRecToTempCustObj(trigger.old);
    }
}

I have this string that I need to parse out values using a formula field. I have working examples from values 1 , 2 and 3 but I can't see the pattern within these to extend to values 4 , 5 and 6 in the string. Would appreciate any kind of guidance even if its just breaking down the code so I can modify it that is , explaining what's happening.
Article | Onsite | Sponsorship | Editorial | TFK Kid of the year | Standard
Value 1
TRIM(LEFT(AB2__ABMediaElementPath__c , FIND("|", AB2__ABMediaElementPath__c )-1))
Value 2
LEFT(RIGHT(AB2__ABMediaElementPath__c , LEN(AB2__ABMediaElementPath__c ) - FIND ("|", AB2__ABMediaElementPath__c )), FIND("|" , RIGHT(AB2__ABMediaElementPath__c , LEN(AB2__ABMediaElementPath__c ) - FIND ("|", AB2__ABMediaElementPath__c )))-1)
Value three
LEFT(RIGHT(AB2__ABMediaElementPath__c , LEN(RIGHT(AB2__ABMediaElementPath__c , LEN(AB2__ABMediaElementPath__c ) - FIND ("|", AB2__ABMediaElementPath__c ))) - FIND ("|", RIGHT(AB2__ABMediaElementPath__c , LEN(AB2__ABMediaElementPath__c ) - FIND ("|", AB2__ABMediaElementPath__c )))), FIND("|" , RIGHT(AB2__ABMediaElementPath__c , LEN(RIGHT(AB2__ABMediaElementPath__c , LEN(AB2__ABMediaElementPath__c ) - FIND ("|", AB2__ABMediaElementPath__c ))) - FIND ("|", RIGHT(AB2__ABMediaElementPath__c , LEN(AB2__ABMediaElementPath__c ) - FIND ("|", AB2__ABMediaElementPath__c )))))-1)
I have a single name field on our product object that has the follwoing full name name below but I don't know how I can pull them from each delimerter. 
Here is the *code I used for a formula field to pull out the second value 'Onsite' but I don't know what additions I need to make in this to pull out the 4th, 5th and 6th values. If someone can just point me in the direction of what each part of the code is doing I could make the addition. 
Thank you


Video | Onsite | Sponsorship | Editorial | Great Resignation Poll | 640x380


​​​​​​​*LEFT(RIGHT(Name, LEN(Name) - FIND ("|", Name)), FIND("|" , RIGHT(Name, LEN(Name) - FIND ("|", Name)))-1)
I have a process using FLOW File Upload, where the upload button is on the opportunity reocord and so the orginal file references the opportunity. Additionally, a process occurs where a contract record is spun up as a parent of that opportunity and another reference to the same file is created in the 'Content Document Link' object. This all works as expected. 
My question is,how can I proceed to make this link into a public link automatically. I know I can do this using content delivery but is there a way to write to other objects like 'Content Distribution' where the creation of a public link is done automatcally when this file upload process occurs? 
I have a very simple formula so I can render the Schedule Date down to the actual Month. However, there are 175 instances where even though the schedule date is clearly a specific month, the formula is rendering a 'NONE' output meaning the month does not numerically line up with a specific MONTH.


API Name of the field in the line item schedule objct=Schedule_Date_Month_NAME__c

CASE(MONTH(ScheduleDate),
1, "January",
2, "February",
3, "March",
4, "April",
5, "May",
6, "June",
7, "July",
8, "August",
9, "September",
10, "October",
11, "November",
12, "December", "None")
Hello, 

I have a test class which was created to give me coverage for a trigger. Although I know you only need 1% for a trigger to move it to production, I was able to get 79%. The problem is I keep getting the following error  

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: PricebookEntryId (pricebook entry is in a different pricebook than the one assigned to the opportunity): [PricebookEntryId]

I am not clear where my code is rerencing 'another' price book entry. Its a cert simple test script. 


@istest
public class Populate_ExtensionTestclass{

static testmethod void  PopulateExtensiontest(){

Date closeDt = Date.Today();

 date myDate = date.today();

Account a2 = new Account(Name ='icrm testing acc');
insert a2;



    id standardPBID = Test.getStandardPricebookId(); 

 /* Pricebook2 pb22 = new Pricebook2(Name='testDIE',Effective_End_Date__c=closeDt, Effective_Start_Date__c=closeDt);
 insert pb22; */

Product2 pro2 = new Product2(Name='BXCD', isActive=true);
insert pro2;

PricebookEntry pbe2 =new PricebookEntry(unitprice=0.01,Product2Id=pro2.Id,Pricebook2Id=standardPBID,
                                         isActive=true,UseStandardPrice = false);
 insert pbe2;
 
 opportunity oppr = new opportunity(Name='testing DIE 4/6/2015' ,  AccountId= a2.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt,     Pricebook2Id = standardPBID);
 insert oppr;

 OpportunityLineItem OPplineitem2 = new OpportunityLineItem (Quantity=2, OpportunityId=oppr.Id,UnitPrice=0.01,PriceBookEntryId=pbe2.Id);
 insert OPplineitem2;
 }
 static testmethod void  PopulateExtensiontest1(){

Date closeDt = Date.Today();

 date myDate = date.today();

Account a2 = new Account(Name ='Non icrm testing acc');
insert a2;

    id standardPBID = Test.getStandardPricebookId(); 

 /* Pricebook2 pb22 = new Pricebook2(Name='testNonDIE',Effective_End_Date__c=closeDt, Effective_Start_Date__c=closeDt);
 insert pb22; */
 
opportunity oppr = new opportunity(Name='testing NONDIE 4/6/2015' ,  AccountId= a2.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt, Pricebook2Id=standardPBID);
insert oppr;

Product2 pro2 = new Product2(Name='BXCDXXX',isActive=true);
insert pro2;

PricebookEntry pbe2 =new PricebookEntry(unitprice=1,Product2Id=pro2.Id,Pricebook2Id=standardPBID,
                                         isActive=true,UseStandardPrice = false);
 insert pbe2;

 OpportunityLineItem OPplineitem2 = new OpportunityLineItem (Quantity=25, OpportunityId=oppr.Id,UnitPrice=1,PriceBookEntryId=pbe2.Id);
 insert OPplineitem2;
 }
 }
 
Hello, 

I need help in getting  test coverage for this trigger. I am a newbie but I've looked at some trailheads and the type triggers they show as examples are much different then this trigger. I just need to know HOW I showd starte as this looks like it access a bunch of oother APEX classes. I really just want to deactivate it in production which is the only reason I need to push it from Dev to Prod. 
Thanks. 

trigger MDP_Tgr_Opportunity_After on Opportunity (after insert, after update, after delete) {

    
    system.debug('in the MDP_Tgr_Opportunity_After trigger');
    
    if(!MDP_Utils.updateOpportunityfromSalesTeamHandler){

      
        if(!V2SA_Trg_Opportunity_Helper.isValidVPAccountOwner(Trigger.newMap)) return;

        
        if (trigger.isInsert) {
            system.debug('in the insert statement of MDP_Tgr_Opportunity_After trigger');
            
            system.debug('LR: AFTER VP VALIDATION');

           
            MDP_Tgr_Opportunity_Handler.CreateSharesOnInsert(trigger.new);
            
            
            
           
            system.debug('end of the insert statement of MDP_Tgr_Opportunity_After trigger');
     
        if(trigger.isUpdate){
            system.debug('in the update statement of MDP_Tgr_Opportunity_After trigger');
            
            MDP_Tgr_Opportunity_Handler.CreateSharesOnUpdate(trigger.new, trigger.oldMap);
            
            
            MDP_Tgr_Opportunity_Handler.sendOMSMessages(Trigger.new, Trigger.oldMap);
            
            MDP_Tgr_Opportunity_Handler.setPriceBookAfterUpdate(Trigger.new, Trigger.oldMap);
            system.debug('end of the update statement of MDP_Tgr_Opportunity_After trigger'); 
        }
    }
    system.debug('end of the MDP_Tgr_Opportunity_After trigger');

} // End: trigger MDP_Tgr_Opportunity_After
 
How can I write a text class for this code. 

trigger MDP_Tgr_OpportunityLineItem_Before on OpportunityLineItem (before insert, before update, before delete) {
    system.debug('invoking the before trigger of OpportunityLineItem');
    // for update
    if(trigger.isUpdate || trigger.isInsert){
      if(trigger.isInsert){
          MDP_Tgr_OppLine_Handler.assignOppFieldValuesToOLI(trigger.new);
        }
        if(trigger.isUpdate) {
            MDP_Tgr_OppLine_Handler.updateTitle(trigger.new);
            MDP_Tgr_OppLine_Handler.checkFieldValueChange(trigger.new, trigger.oldMap);
        }
        MDP_Tgr_OppLine_Handler.updateOracleOverride(trigger.new);  
         //MDP_Tgr_OppLine_Handler.checkTotalNEP(trigger.new, trigger.newMap);    // moved to after trigger
    }
    if(trigger.isDelete){      
      system.debug('in the Delete');  
        MDP_Tgr_OppLine_Handler.operativeAPIProfileGotError(trigger.old);
        MDP_Tgr_OppLine_Handler.insertOppLineItemRecToTempCustObj(trigger.old);
    }
}
Hello, 

I have a test class which was created to give me coverage for a trigger. Although I know you only need 1% for a trigger to move it to production, I was able to get 79%. The problem is I keep getting the following error  

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: PricebookEntryId (pricebook entry is in a different pricebook than the one assigned to the opportunity): [PricebookEntryId]

I am not clear where my code is rerencing 'another' price book entry. Its a cert simple test script. 


@istest
public class Populate_ExtensionTestclass{

static testmethod void  PopulateExtensiontest(){

Date closeDt = Date.Today();

 date myDate = date.today();

Account a2 = new Account(Name ='icrm testing acc');
insert a2;



    id standardPBID = Test.getStandardPricebookId(); 

 /* Pricebook2 pb22 = new Pricebook2(Name='testDIE',Effective_End_Date__c=closeDt, Effective_Start_Date__c=closeDt);
 insert pb22; */

Product2 pro2 = new Product2(Name='BXCD', isActive=true);
insert pro2;

PricebookEntry pbe2 =new PricebookEntry(unitprice=0.01,Product2Id=pro2.Id,Pricebook2Id=standardPBID,
                                         isActive=true,UseStandardPrice = false);
 insert pbe2;
 
 opportunity oppr = new opportunity(Name='testing DIE 4/6/2015' ,  AccountId= a2.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt,     Pricebook2Id = standardPBID);
 insert oppr;

 OpportunityLineItem OPplineitem2 = new OpportunityLineItem (Quantity=2, OpportunityId=oppr.Id,UnitPrice=0.01,PriceBookEntryId=pbe2.Id);
 insert OPplineitem2;
 }
 static testmethod void  PopulateExtensiontest1(){

Date closeDt = Date.Today();

 date myDate = date.today();

Account a2 = new Account(Name ='Non icrm testing acc');
insert a2;

    id standardPBID = Test.getStandardPricebookId(); 

 /* Pricebook2 pb22 = new Pricebook2(Name='testNonDIE',Effective_End_Date__c=closeDt, Effective_Start_Date__c=closeDt);
 insert pb22; */
 
opportunity oppr = new opportunity(Name='testing NONDIE 4/6/2015' ,  AccountId= a2.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt, Pricebook2Id=standardPBID);
insert oppr;

Product2 pro2 = new Product2(Name='BXCDXXX',isActive=true);
insert pro2;

PricebookEntry pbe2 =new PricebookEntry(unitprice=1,Product2Id=pro2.Id,Pricebook2Id=standardPBID,
                                         isActive=true,UseStandardPrice = false);
 insert pbe2;

 OpportunityLineItem OPplineitem2 = new OpportunityLineItem (Quantity=25, OpportunityId=oppr.Id,UnitPrice=1,PriceBookEntryId=pbe2.Id);
 insert OPplineitem2;
 }
 }
 
Hello, 

I need help in getting  test coverage for this trigger. I am a newbie but I've looked at some trailheads and the type triggers they show as examples are much different then this trigger. I just need to know HOW I showd starte as this looks like it access a bunch of oother APEX classes. I really just want to deactivate it in production which is the only reason I need to push it from Dev to Prod. 
Thanks. 

trigger MDP_Tgr_Opportunity_After on Opportunity (after insert, after update, after delete) {

    
    system.debug('in the MDP_Tgr_Opportunity_After trigger');
    
    if(!MDP_Utils.updateOpportunityfromSalesTeamHandler){

      
        if(!V2SA_Trg_Opportunity_Helper.isValidVPAccountOwner(Trigger.newMap)) return;

        
        if (trigger.isInsert) {
            system.debug('in the insert statement of MDP_Tgr_Opportunity_After trigger');
            
            system.debug('LR: AFTER VP VALIDATION');

           
            MDP_Tgr_Opportunity_Handler.CreateSharesOnInsert(trigger.new);
            
            
            
           
            system.debug('end of the insert statement of MDP_Tgr_Opportunity_After trigger');
     
        if(trigger.isUpdate){
            system.debug('in the update statement of MDP_Tgr_Opportunity_After trigger');
            
            MDP_Tgr_Opportunity_Handler.CreateSharesOnUpdate(trigger.new, trigger.oldMap);
            
            
            MDP_Tgr_Opportunity_Handler.sendOMSMessages(Trigger.new, Trigger.oldMap);
            
            MDP_Tgr_Opportunity_Handler.setPriceBookAfterUpdate(Trigger.new, Trigger.oldMap);
            system.debug('end of the update statement of MDP_Tgr_Opportunity_After trigger'); 
        }
    }
    system.debug('end of the MDP_Tgr_Opportunity_After trigger');

} // End: trigger MDP_Tgr_Opportunity_After