• Jim Montgomery
  • NEWBIE
  • 80 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 30
    Replies
I need to pull a list of value from a custom object to use as the selectable values in a multi select picklist.
I know how to set the picklist up in the VF page, but need the class that will select the values into the list that will feed the picklist object.
I have a custom object "Inventory", that has  a master detil relationship with the account object.
I need to be able to copy all of the related Inventory records to a custon object that has a master detail relationship to case, when the Account lookup is populated on the case reocrd.
Getting this error

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PfxTaxUpdateOppProposal: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.PfxTaxUpdateOppProposal: line 6, column 1: [] 
Stack Trace: Class.TestAxcessInsertTaxUpdateOpps.InsertOpp: line 20, column 1


On this test class

@isTest
Private Class TestPfxInsertTaxUpdateOpps{
static testMethod void InsertOpp(){

TaxUpdateYear__C TUY = new TaxUpdateYear__c(
name = 'UpdateYear',
year__c = '2018');
insert TUY;


Account A = new Account(
            Name = 'myAcct', 
            BillingStreet='25 Upland Drive',
            BillingPostalCode='94127',
            BillingCountry='United States',
            BillingCity='San Francisco',
            Pfx_Tax_Update_Counter__c = 0 );
        insert A;
        
        Account_x_reference__c xref = new account_x_reference__c(
name = '990026',
applicationid__c = '990026', 
application__c = 'AMS', ams_special_agreement__c = 'X', ams_consolidation_code__c = '028',
account__c = a.id);
insert xref;
        
        A.Pfx_Tax_Update_Counter__C = 1;
        a.Tax_Update_Account_Number__c = xref.id;
        
        update a;
        
        
   
        }
        }  

on this trigger

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
trigger AxcessTaxUpdateOppProposal on Account (after update) {
    for (Account A:trigger.new){
    TaxUpdateYear__C TUY = TaxUpdateYear__c.getInstance('UpdateYear');
    String Year = TUY.year__c;
           Account oldAccount = Trigger.oldMap.get(A.Id);
        if(oldAccount.Axcess_Tax_Update_Counter__C <>  A.Axcess_Tax_Update_Counter__C){
          Opportunity O = new Opportunity(
          accountId = A.Id,
          name = a.name +' - '+Year+' Tax Update Order',
          amount = 150.00,
          StageName = '5. Time to Buy',
          ForecastCategoryName = 'High Probability',
          Forecast_Type__c = 'High(>90%)',
          Primary_contact_for_proposal__c = a.tax_update_contact__c,
          primary_contact_email__c = a.tax_update_contact_email__c,
          primary_contact_phone__C = a.tax_Update_Contact_phone__c,
          product_category__c = 'Small Firm Software',
          product_sub_category__c = 'Tax',
          type = 'New to Existing',
          RecordTypeId = '01231000001NWytAAG',
          closedate = system.Today(),
          OwnerId = UserInfo.getUserId()); 
          insert O;
            
            apttus_proposal__proposal__c P = new apttus_proposal__proposal__c(
            apttus_proposal__account__c = A.Id,
            apttus_proposal__proposal_name__c = O.name,
            apttus_proposal__approval_stage__c = 'Approved',
            apttus_proposal__opportunity__c = O.Id,
            quote_total__C = 150.00,
            RecordTypeId = '012i0000001EOtSAAW',
            apttus_QPConfig__PriceListId__c = 'a1fi0000000y6L4AAI',
            OwnerId = UserInfo.getUserId(),
            annual_start_date__c = system.Today()
          ,erp_account__c = A.Tax_Update_Account_number__c );            
            insert P;
            
            apttus_Config2__ProductConfiguration__c C = new apttus_Config2__ProductConfiguration__c (
            name = p.name,
            ownerId = UserInfo.getUserId(),
            Apttus_Config2__BusinessObjectId__c = P.Id,
            Apttus_Config2__BusinessObjectType__c = 'Proposal',
            Apttus_Config2__EffectivePriceListId__c = 'a1fi0000000y6L4AAI',
            Apttus_Config2__PriceListId__c = 'a1fi0000000y6L4AAI',
            Apttus_QPConfig__Proposald__c = P.Id,
            Apttus_Config2__Status__C = 'Finalized',
            Apttus_Config2__VersionNumber__c = 1,
            Proposal_ID__c = P.Id);
            Insert C;
            
             Apttus_Config2__LineItem__c CLI = new Apttus_Config2__LineItem__c(
                Apttus_Config2__ConfigurationId__c = C.Id,
                Apttus_Config2__ChargeType__c = 'One Time Fee',
                Apttus_Config2__BasePrice__c = 150.00,
                Apttus_Config2__BaseExtendedPrice__c = 150.00,
                Apttus_Config2__ExtendedPrice__c = 150.00,
                Apttus_Config2__IsPrimaryLine__c = true,
                Apttus_Config2__ItemSequence__c = 1,
                Apttus_Config2__LineNumber__c = 1,
                Apttus_Config2__ListPrice__c = 150.00,
                Apttus_Config2__LineStatus__c = 'New',
                Apttus_Config2__NetPrice__c = 150.00,
                Apttus_Config2__PriceListId__c = 'a1fi0000000y6L4AAI',
                apttus_config2__PriceListItemId__c = 'a1e0S0000007RYK',
                Apttus_Config2__PriceType__c = 'One Time',
                Apttus_Config2__ProductId__c = '01t0S000000krh9',
                Apttus_Config2__Quantity__c = 1,
                Apttus_Config2__SellingFrequency__c = 'Yearly',
                Apttus_Config2__SyncStatus__c = 'Synchronized',
                Apttus_Config2__PricingStatus__c = 'Complete',
                Apttus_Config2__PrimaryLineNumber__c = 1);
                Insert CLI; 
            
             
              apttus_proposal__proposal_line_item__c PLI = new apttus_proposal__proposal_line_item__c(
              apttus_proposal__proposal__c = p.Id,
                apttus_proposal__product__c = '01t0S000000krh9',
                apttus_qpconfig__quantity2__c = 1,
                apttus_qpconfig__linenumber__c = 1,
                apttus_qpconfig__itemsequence__c = 1,
                apttus_qpconfig__listprice__c = 150.00000,
                apttus_qpconfig__netprice__c = 150.00,
                apttus_qpconfig__linestatus__c = 'New',
                apttus_qpconfig__lineType__c = 'Product/Service',
                apttus_proposal__description__c = 'CCH AXCESS TAX UPDATE SEMINAR - MTS',
                apttus_qpconfig__PriceListItemId__c = 'a1e0S0000007RYK');
                insert PLI;
             Template_Line_item__C TLI = new Template_Line_Item__C(
                OwnerId = UserInfo.getUserId(),
                name = 'QLI-Record',
                ams_product_Category__c = 'Tax Professional & Client Services',
                Product__c = '01t0S000000krh9',
                Quote_Proposal__C = p.Id,
                display_ams_product_category__c = 'Tax Professional & Client Services',
                proposal_line_item__C = PLI.Id);
                
                insert TLI;
                
                  P.quote_total__c = 150.00;
                Update P;
                
                opportunitylineitem OLI = new opportunitylineitem(
                opportunityId = O.Id,
                product2Id = '01t0S000000krh9',
                Quantity = 1,
                TotalPrice = 150.00,
                Item_Number__C = '1',
                BasePrice__c = 150.00,
                PriceBookEntryId = '01u0S000001Lr93');
            
                
                insert OLI;   
               
                
   }
}
}


Trigger has 100% coverage in test.
Not sure why it is failing during deployment.
 
I have a trigger that inserts new line items into a custom object. One of the items I need to insert is the productID of a specific product.
How can I use [select id from product2 where productcode = 12345']  in an apex trigger?
trigger OutsourceOrderTotal on Apttus_Proposal__Proposal__c (after update) {    
    
  
       for(apttus_proposal__proposal__c p : trigger.new)
           if(p.os_offshore_1040_1041_dollars__c == null 
              && p.os_offshore_business_dollars__c == null 
              && p.os_offshore_charter_dollars__c == null 
              && p.os_onshore_1040_1041_dollars__c == null 
             && p.os_onshore_business_dollars__c == null
             &&p.os_onshore_charter_dollars__c == null)
           {
        p.os_order_total_trigger__c = 0;
    }
    else
         {             
            p.os_order_total_trigger__c = p.os_offshore_1040_1041_dollars__c +  p.os_offshore_business_dollars__c + p.os_offshore_charter_dollars__c
             + p.os_onshore_1040_1041_dollars__c + p.os_onshore_business_dollars__c + p.os_onshore_charter_dollars__c;
           }  
    
       
}
I have a process builder process that will create a new opportunity when a checkbox is set to true on the account.
I create the opportunity no problem, but I then want to also create a custom object related to the newly created opportunity as the next action in the process. is this possible?
I am getting "Too mant SOQL Queries" error in this chunk of code. it is in an Apex class, and I know they are running a SOQL query in a for loop (no no), but not sure how to correctly create and reference the map that they should be using.


if(opptyWonIds.size()<0){
            for(Opportunity wonOpp : [SELECT Id, Opportunity_Closed_Lost__c, Opportunity_Partial_Won__c, Opportunity_Closed_Won__c 
                                           FROM Opportunity WHERE Id IN: opptyWonIds]){
                if(wonOpp.Opportunity_Closed_Won__c != true){
                    wonOpp.Opportunity_Closed_Won__c = true;
                    if(wonOpp.Opportunity_Partial_Won__c == true || wonOpp.Opportunity_Closed_Lost__c == true){
                        wonOpp.Opportunity_Partial_Won__c = false;
                        wonOpp.Opportunity_Closed_Lost__c = false;
                   }
                    System.debug('*********************wonOpp: '+wonOpp);
                   opportunitiesToUpdate.add(wonOpp);
Here is my code.Link is blank.

Trigger SAPOrderComplete on Apttus_Proposal__Proposal__c (before update) {
for(apttus_proposal__proposal__c Proposal:trigger.new){
 apttus_proposal__proposal__c oldProposal = Trigger.oldMap.get(Proposal.Id);
  if((oldProposal.sap_order_complete__c == null || oldProposal.sap_order_complete__c == false) && proposal.sap_order_complete__c == true)
  {
  proposal.sap_order_processing_stage__c = 'Complete';
  proposal.sap_order_corrected__c = false;
  proposal.sap_order_rejected__c = false;
  if(proposal.sap_order_entered_date__c == null)
  {
  proposal.sap_order_entered_date__c = system.today();
  }
  Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
       
        String getProcessor = [select name from user where Id = :trigger.new[0].sap_order_processor__c].Name;
        String getAccount = [select name from account where id = :trigger.new[0].apttus_proposal__account__c].name;
        
        
        String[] Account = new String[] {getAccount};
        String[] Processor = new String[] {getProcessor};
        
        
        mail.TargetObjectId = (proposal.ownerId);
       
        mail.setSubject('Order completed for account: '+Account);
        mail.setHTMLBody('Order has been completed for proposal: <html><a href="'+URL.getSalesforceBaseUrl().toExternalForm() +'/'+Proposal.Id+'"></a></html>');
        mail.setSaveAsActivity(false);    
          
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
            
   }
}
}
Here is my code. Not sure why it is throwing this error. Without the display name setting, all works fine but appears as from the logged in user.

<apex:page standardController="Apttus_Proposal__Proposal__c">
<script type="text/javascript"> var __sfdcSessionId = '{!GETSESSIONID()}';  </script>
<script src="/soap/ajax/34.0/connection.js" type="text/javascript"></script> <script type="text/javascript">
window.onLoad = SendMail()
function SendMail()
{ try
{ sforce.connection.sessionId = "{!$Api.Session_ID}";
var target = "{!Apttus_Proposal__Proposal__c.opp_primary_contactId__c}";
 var message = new sforce.SingleEmailMessage();
message.replyTo = "noreply@wolterskluwer.com";
message.targetObjectId = target;
message.templateId = "00X0Z000001Fyuu";
message.saveAsActivity = false;
message.SenderDisplayName = "noreply@wolterskluwer.com";
var result = sforce.connection.sendEmail([message]);
if(result[0].success == 'true') { alert("Mail sent successfully"); }
else
{ alert("Error sending email."); } }catch(e) { alert("Error Occurred: \n\n" + (e.message||e)); } }
</script>
</apex:page>
I am running this script in a VF page. When executed, the url the link goes to has undefined at the end with an error that the URL no longerv exists.

<apex:page standardController="Opportunity">
<script src="/soap/ajax/10.0/connection.js"> </script > <script src="/soap/ajax/10.0/apex.js"> </script >
<script type="text/javascript">
window.onload=init()
function init()
{ var p = new sforce.SObject('Opportunity');
p.id = "{!Opportunity.Id}";
p.Tax_Renewal_SFS_Books_Complete__c = true;
result = sforce.connection.update([p]);
window.location.href = "https://wktaa.my.salesforce.com/"+p.Id; };
</script>
</apex:page>

It performs the field update, just errors out on the re-direct.
I have the same code running on another object and it works fine.
Any ideas?
Trying to assign extended_maintenance_months__c as the variable months in the definition of addMonths.

trigger SoftwareAnnualEndDates on Apttus_Proposal__Proposal__c (After update) {

    List<apttus_proposal__proposal_line_item__c> lstToUpdate = new List<apttus_proposal__proposal_line_item__c>();

    for(apttus_proposal__proposal_line_item__c obj :[select maintenance_end_date__c, proposal_end_date__c,extended_maintenance_months__c from apttus_proposal__proposal_line_item__c where extended_maintenance_months__c >0 and apttus_proposal__proposal__c != null and apttus_proposal__proposal__c in : trigger.new])
       
    {         
        obj.maintenance_end_date__c = proposal_end_date__c.addMonths(Months);

        lstToUpdate.add(obj);
   }

    if(!lstToUpdate.isEmpty())

        update lstToUpdate;

}
Code.
Getting sent to the login page on re-direct.

<apex:page standardController="Apttus_Proposal__Proposal__c"> <script src="/soap/ajax/10.0/connection.js"> </script > <script src="/soap/ajax/10.0/apex.js"> </script > <apex:iframe src="{!URLFOR($Resource.SAP_Order_Checklist)}" id="theIframe"/> <script type="text/javascript"> window.onload=init() function init() { var p = new sforce.SObject('Apttus_Proposal__Proposal__c'); p.Id = "{!Apttus_Proposal__Proposal__c.Id}"; p.sap_checklist_accessed__c = true; result = sforce.connection.update([p]); location.href="https://wktaatest--taatest.cs54.my.salesforce.com/"+p.Id }; </script> </apex:page>
Here is my code.

trigger CopyPromotionName on Apttus_Proposal__Proposal_Line_Item__c (after insert,after update) {


  Map<String,String> PromotionLookup = new Map<String,String>();
  Set<String> PromotionCode = new Set<String>();    

  for(Apttus_proposal__proposal_line_Item__c p:Trigger.new) {
    PromotionCode.add(p.apts_promo_code__c);
  }
  
  for(Promotion__c QP:

    [SELECT      name,promo_code__c
     FROM        Promotion__c
     WHERE       promo_code__c IN :PromotionCode]) {

     PromotionLookup.put(QP.Name,QP.Promotion_Code__c);

  }

  for(Apttus_proposal__proposal_line_Item__c p:Trigger.new) {

    if(PromotionLookup.containsKey(p.apts_Promo_Code__c)) {

      p.Promotion_Name__C = PromotionLookup.get(QP.name);

    }

  }
Here is my code, but it does not fire.

apex:page standardController="Opportunity"> <script src="/soap/ajax/10.0/connection.js"> </script > <script src="/soap/ajax/10.0/apex.js"> </script > <body onload="init()"/> <script type="text/javascript"> Function init() { alert("1") } { var p = new sforce.SObject('opportunity'); p.id = document.getElementById; var fulldate = (today.getMonth()+1)+'/'+today.getDate()+'/'+today.getFullYear(); var OppDateRaw = (new Date('{p.CloseDate}')); var formattedOppDate = (OppDateRaw.getMonth()+1) + '/'+OppDateRaw.getDate()+'/'+OppDateRaw.getFullYear(); if( formattedOppDate < fulldate) { alert("Close date cannot be in the past"); } else { if("{p.AMS_Order_Processing_Stage__c}" === "Approved" ) { p.AMS_Order_Processing_Stage__c = "Submitted to Order Processing"; result = sforce.connection.update([p]); location.reload(true); } else { alert("This opportunity has not been approved."); } } } window.history.back() } </script> </apex:page>
I am trying to have the selected row highlighted when the select button is clicked.
Since there is no action associated with the select command link, the page refreshes after clicking select, thus erasing any styling not based on the parameter ConId.
I am trying to have the styling applied conditionally based on the page parameter ConId.

<apex:page standardController="Account"> <apex:form > <apex:pageblock > <apex:pageblocktable value="{!account.Contacts}" var="item"> <apex:column headerValue="Select"> <apex:commandLink > <Apex:Outputtext value="Select"/> <apex:Param name="ConId" value="{!item.id}"/> </apex:CommandLink> </apex:column> <apex:column value="{!item.name}" style="{!if(item.id='{!$CurrentPage.parameters.ConId}','color:red','color:black')}"/> <apex:Column value="{!item.title}"/> <apex:Column value="{!item.Phone}"/> <apex:Column value="{!item.email}"/> <apex:Column value="{!item.mobilephone}"/> <apex:Column value="{!item.Inactive__c}"/> <apex:Column value="{!item.id}"/> </apex:pageblockTable> </apex:Pageblock> <br/> <br/> <apex:OutputLink value="{!account.ContactCallURL1__c}{!$CurrentPage.parameters.ConId}{!account.ContactCallURL2__c}"> <apex:OutputText style="color:blue;" value="Next"/> </apex:OutputLink> strId = {!$CurrentPage.parameters.ConId} </apex:form> </apex:page>
I am trying to write a custom VF page to display account history only for the logged in user.
I am using account as the standard controller, and have an extension controller to do the filtering.
I am getting the above error when attempting to save my VF page.

Class:
public class AccExtensions{
      Public List<Account> AHS{get;set;}
            public AccExtensions(ApexPages.StandardController controller) {
          AHS=[select id, name,(select ActivityDate, ActivityType from ActivityHistories where OwnerId = :UserInfo.getUserId())from account where ID=:ApexPages.currentPage().getParameters().get('id')];
          for(Account ah:AHS) {
 
             
                AHS.add(ah);
}
}
}

VF Page

<apex:page standardController="Account" extensions="AccExtensions" >
<apex:pageBlock>
<apex:pageblockTable value="{!AHS}" var="acch">
<apex:Column headervalue = "Date" value="{!acch.ActivityDate}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:page>
 
Getting error "Loop Variable Mut be of Type Account Line 7".
Here is my code.
No classes named accoutn.

trigger HasWorkPaperManager on Account (after insert, after update) {

    Map<ID, Account> parentAccount = new Map<ID, Account>();
    List<Id> listIds = new List<Id>();
    List<Id> LineItems = new List<Id>();

    for (AMS_Inventory_Rollup__c childObj : Trigger.new) {
        listIds.add(childObj.AccountID__c);
        LineItems.add(childObj.Id);
    }
  
    parentAccount = new Map<Id, Account>([SELECT id,Has_WorkPaper_Manager__c,(Select id from Ams_inventory_rollups__r where name = '511000') FROM account WHERE ID IN :listIds]);
   
    for (AMS_Inventory_Rollup__c AMSInventoryRollup: Trigger.new){
         Account myParentAccount = parentAccount.get(AMSInventoryRollup.Account);
        if(parentAccount.containsKey(AMSInventoryRollup.Account) && parentaccount.get(AMSInventoryRollup.Account).AMSInventoryRollups__r.size() > 0)
        {
            myParentAccount.Has_WorkPaper_Manager__c = true;
        }
        else
        {
            myParentAccount.Has_WorkPaper_Manager__c = false ;
        }
    }
    update parentAccount.values();
 }
I have a custom object BI Retention that I need to link to opportunities.
Basically, if the DTN, month and year match, I want to insert the BI.ID into the BI lookup field on the opportunity.
Here is what I have so far, but getting error invalid foriegn key relationship BI_Retention_Quota.Retention_month__c.

trigger BI_Retention_Quota on Opportunity (before insert, before update) {   
  List<BI_Retention_Quota__c > BI = [select Retention_Month__c,Retention_DTN__C from BI_Retention_Quota__c ];
{
    if(Trigger.isBefore)
{

 if (Trigger.isInsert || Trigger.isUpdate)
{
  for(Opportunity  Opp : trigger.new)      

 {
     for (BI_Retention_Quota__c b : BI)
     {
         if (b.retention_month__c.month = opp.retention_month__c.month && b.retention_month__c.year    = opp.retention_month__c.year && b.retention_dtn__c = opp.renewal_rep_dtn__c)
         {         
                        opp.BI_Retention_Quota__c = b.Id;
         }   
                                     

           }

       }

    }

}

}
}
 
Attempting to sort this table by row_number, but it is not working.
Any help would be appreciated.
The custom controller already combines 2 unrelated objects, so cannot use a wrapper to sort.



<apex:page StandardController="Apttus_Proposal__Proposal__c" extensions="AMSRDControllerExtensionSFDC"  sidebar="False" showHeader="false" pageStyle="width:1100px;">
   
    
     <apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" />
  <apex:includeScript value="//cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.17.8/js/jquery.tablesorter.min.js" />
  <apex:stylesheet value="//cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.17.8/css/theme.blue.css" />

  <table id="RenewalData">
  <thead>
          <tr>
            <th>Row Number</th>
            <th>Quantity</th>
            <th>Product Code</th>
            <th>Product Description</th>
          
          </tr>
          <tr/>
          </thead>
       
         
          <apex:repeat value="{!finalList}" var="obj"> 
           <tbody>
                   <tr>
            <td>{!obj.row_number}</td>
            <td>{!obj.Quantity}</td> 
            <td>{!obj.product_code}</td>
            <td>{!obj.product_description}</td>
          </tr>
          </tbody>
          </apex:repeat>
    </table>   
  <script>
    $(document).ready(function() 
    { 
        $("[id$='RenewalData']").tablesorter(); 
    });   
  </script>
</apex:page>

I am trying to append data from 2 seperate lists into a single list in an apex class.
I keep getting an error"Illegal assignment from List<AMS_Renewal_Data__c> to List<Apttus_Proposal__Proposal__c> at line 12 column 1".
Class below.
Any assistance will be greatly appreciated!

public with sharing class AMSRDController {
Public List<apttus_proposal__Proposal__c> RenewalData{get;set;}
Public List<apttus_proposal__Proposal__c> Junk{get;set;}

Public AMSRDController() {
GetRenewalData();
GetJunk();
GetCombinedList();
}
Public Void GetRenewalData()
{
RenewalData = [select product_description__c from AMS_Renewal_Data__c where id = :ApexPages.currentPage().getParameters().get('id')];
}
Public Void GetJunk()
{
Junk = [select product_description__c from Apttus_Proposal__Proposal_Line_Item__c where id = :ApexPages.currentPage().getParameters().get('id')];
}
Public List<apttus_proposal__Proposal__c> GetCombinedList()
{
List<apttus_proposal__Proposal__c> CombinedItems=new List<apttus_proposal__Proposal__c>();
CombinedItems.addAll(RenewalData);
CombinedItems.addAll(Junk);

return CombinedItems;
}
}
I have a custom object "Inventory", that has  a master detil relationship with the account object.
I need to be able to copy all of the related Inventory records to a custon object that has a master detail relationship to case, when the Account lookup is populated on the case reocrd.
Getting this error

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PfxTaxUpdateOppProposal: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.PfxTaxUpdateOppProposal: line 6, column 1: [] 
Stack Trace: Class.TestAxcessInsertTaxUpdateOpps.InsertOpp: line 20, column 1


On this test class

@isTest
Private Class TestPfxInsertTaxUpdateOpps{
static testMethod void InsertOpp(){

TaxUpdateYear__C TUY = new TaxUpdateYear__c(
name = 'UpdateYear',
year__c = '2018');
insert TUY;


Account A = new Account(
            Name = 'myAcct', 
            BillingStreet='25 Upland Drive',
            BillingPostalCode='94127',
            BillingCountry='United States',
            BillingCity='San Francisco',
            Pfx_Tax_Update_Counter__c = 0 );
        insert A;
        
        Account_x_reference__c xref = new account_x_reference__c(
name = '990026',
applicationid__c = '990026', 
application__c = 'AMS', ams_special_agreement__c = 'X', ams_consolidation_code__c = '028',
account__c = a.id);
insert xref;
        
        A.Pfx_Tax_Update_Counter__C = 1;
        a.Tax_Update_Account_Number__c = xref.id;
        
        update a;
        
        
   
        }
        }  

on this trigger

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
trigger AxcessTaxUpdateOppProposal on Account (after update) {
    for (Account A:trigger.new){
    TaxUpdateYear__C TUY = TaxUpdateYear__c.getInstance('UpdateYear');
    String Year = TUY.year__c;
           Account oldAccount = Trigger.oldMap.get(A.Id);
        if(oldAccount.Axcess_Tax_Update_Counter__C <>  A.Axcess_Tax_Update_Counter__C){
          Opportunity O = new Opportunity(
          accountId = A.Id,
          name = a.name +' - '+Year+' Tax Update Order',
          amount = 150.00,
          StageName = '5. Time to Buy',
          ForecastCategoryName = 'High Probability',
          Forecast_Type__c = 'High(>90%)',
          Primary_contact_for_proposal__c = a.tax_update_contact__c,
          primary_contact_email__c = a.tax_update_contact_email__c,
          primary_contact_phone__C = a.tax_Update_Contact_phone__c,
          product_category__c = 'Small Firm Software',
          product_sub_category__c = 'Tax',
          type = 'New to Existing',
          RecordTypeId = '01231000001NWytAAG',
          closedate = system.Today(),
          OwnerId = UserInfo.getUserId()); 
          insert O;
            
            apttus_proposal__proposal__c P = new apttus_proposal__proposal__c(
            apttus_proposal__account__c = A.Id,
            apttus_proposal__proposal_name__c = O.name,
            apttus_proposal__approval_stage__c = 'Approved',
            apttus_proposal__opportunity__c = O.Id,
            quote_total__C = 150.00,
            RecordTypeId = '012i0000001EOtSAAW',
            apttus_QPConfig__PriceListId__c = 'a1fi0000000y6L4AAI',
            OwnerId = UserInfo.getUserId(),
            annual_start_date__c = system.Today()
          ,erp_account__c = A.Tax_Update_Account_number__c );            
            insert P;
            
            apttus_Config2__ProductConfiguration__c C = new apttus_Config2__ProductConfiguration__c (
            name = p.name,
            ownerId = UserInfo.getUserId(),
            Apttus_Config2__BusinessObjectId__c = P.Id,
            Apttus_Config2__BusinessObjectType__c = 'Proposal',
            Apttus_Config2__EffectivePriceListId__c = 'a1fi0000000y6L4AAI',
            Apttus_Config2__PriceListId__c = 'a1fi0000000y6L4AAI',
            Apttus_QPConfig__Proposald__c = P.Id,
            Apttus_Config2__Status__C = 'Finalized',
            Apttus_Config2__VersionNumber__c = 1,
            Proposal_ID__c = P.Id);
            Insert C;
            
             Apttus_Config2__LineItem__c CLI = new Apttus_Config2__LineItem__c(
                Apttus_Config2__ConfigurationId__c = C.Id,
                Apttus_Config2__ChargeType__c = 'One Time Fee',
                Apttus_Config2__BasePrice__c = 150.00,
                Apttus_Config2__BaseExtendedPrice__c = 150.00,
                Apttus_Config2__ExtendedPrice__c = 150.00,
                Apttus_Config2__IsPrimaryLine__c = true,
                Apttus_Config2__ItemSequence__c = 1,
                Apttus_Config2__LineNumber__c = 1,
                Apttus_Config2__ListPrice__c = 150.00,
                Apttus_Config2__LineStatus__c = 'New',
                Apttus_Config2__NetPrice__c = 150.00,
                Apttus_Config2__PriceListId__c = 'a1fi0000000y6L4AAI',
                apttus_config2__PriceListItemId__c = 'a1e0S0000007RYK',
                Apttus_Config2__PriceType__c = 'One Time',
                Apttus_Config2__ProductId__c = '01t0S000000krh9',
                Apttus_Config2__Quantity__c = 1,
                Apttus_Config2__SellingFrequency__c = 'Yearly',
                Apttus_Config2__SyncStatus__c = 'Synchronized',
                Apttus_Config2__PricingStatus__c = 'Complete',
                Apttus_Config2__PrimaryLineNumber__c = 1);
                Insert CLI; 
            
             
              apttus_proposal__proposal_line_item__c PLI = new apttus_proposal__proposal_line_item__c(
              apttus_proposal__proposal__c = p.Id,
                apttus_proposal__product__c = '01t0S000000krh9',
                apttus_qpconfig__quantity2__c = 1,
                apttus_qpconfig__linenumber__c = 1,
                apttus_qpconfig__itemsequence__c = 1,
                apttus_qpconfig__listprice__c = 150.00000,
                apttus_qpconfig__netprice__c = 150.00,
                apttus_qpconfig__linestatus__c = 'New',
                apttus_qpconfig__lineType__c = 'Product/Service',
                apttus_proposal__description__c = 'CCH AXCESS TAX UPDATE SEMINAR - MTS',
                apttus_qpconfig__PriceListItemId__c = 'a1e0S0000007RYK');
                insert PLI;
             Template_Line_item__C TLI = new Template_Line_Item__C(
                OwnerId = UserInfo.getUserId(),
                name = 'QLI-Record',
                ams_product_Category__c = 'Tax Professional & Client Services',
                Product__c = '01t0S000000krh9',
                Quote_Proposal__C = p.Id,
                display_ams_product_category__c = 'Tax Professional & Client Services',
                proposal_line_item__C = PLI.Id);
                
                insert TLI;
                
                  P.quote_total__c = 150.00;
                Update P;
                
                opportunitylineitem OLI = new opportunitylineitem(
                opportunityId = O.Id,
                product2Id = '01t0S000000krh9',
                Quantity = 1,
                TotalPrice = 150.00,
                Item_Number__C = '1',
                BasePrice__c = 150.00,
                PriceBookEntryId = '01u0S000001Lr93');
            
                
                insert OLI;   
               
                
   }
}
}


Trigger has 100% coverage in test.
Not sure why it is failing during deployment.
 
I have a trigger that inserts new line items into a custom object. One of the items I need to insert is the productID of a specific product.
How can I use [select id from product2 where productcode = 12345']  in an apex trigger?
trigger OutsourceOrderTotal on Apttus_Proposal__Proposal__c (after update) {    
    
  
       for(apttus_proposal__proposal__c p : trigger.new)
           if(p.os_offshore_1040_1041_dollars__c == null 
              && p.os_offshore_business_dollars__c == null 
              && p.os_offshore_charter_dollars__c == null 
              && p.os_onshore_1040_1041_dollars__c == null 
             && p.os_onshore_business_dollars__c == null
             &&p.os_onshore_charter_dollars__c == null)
           {
        p.os_order_total_trigger__c = 0;
    }
    else
         {             
            p.os_order_total_trigger__c = p.os_offshore_1040_1041_dollars__c +  p.os_offshore_business_dollars__c + p.os_offshore_charter_dollars__c
             + p.os_onshore_1040_1041_dollars__c + p.os_onshore_business_dollars__c + p.os_onshore_charter_dollars__c;
           }  
    
       
}
I am getting "Too mant SOQL Queries" error in this chunk of code. it is in an Apex class, and I know they are running a SOQL query in a for loop (no no), but not sure how to correctly create and reference the map that they should be using.


if(opptyWonIds.size()<0){
            for(Opportunity wonOpp : [SELECT Id, Opportunity_Closed_Lost__c, Opportunity_Partial_Won__c, Opportunity_Closed_Won__c 
                                           FROM Opportunity WHERE Id IN: opptyWonIds]){
                if(wonOpp.Opportunity_Closed_Won__c != true){
                    wonOpp.Opportunity_Closed_Won__c = true;
                    if(wonOpp.Opportunity_Partial_Won__c == true || wonOpp.Opportunity_Closed_Lost__c == true){
                        wonOpp.Opportunity_Partial_Won__c = false;
                        wonOpp.Opportunity_Closed_Lost__c = false;
                   }
                    System.debug('*********************wonOpp: '+wonOpp);
                   opportunitiesToUpdate.add(wonOpp);
Trying to assign extended_maintenance_months__c as the variable months in the definition of addMonths.

trigger SoftwareAnnualEndDates on Apttus_Proposal__Proposal__c (After update) {

    List<apttus_proposal__proposal_line_item__c> lstToUpdate = new List<apttus_proposal__proposal_line_item__c>();

    for(apttus_proposal__proposal_line_item__c obj :[select maintenance_end_date__c, proposal_end_date__c,extended_maintenance_months__c from apttus_proposal__proposal_line_item__c where extended_maintenance_months__c >0 and apttus_proposal__proposal__c != null and apttus_proposal__proposal__c in : trigger.new])
       
    {         
        obj.maintenance_end_date__c = proposal_end_date__c.addMonths(Months);

        lstToUpdate.add(obj);
   }

    if(!lstToUpdate.isEmpty())

        update lstToUpdate;

}
Code.
Getting sent to the login page on re-direct.

<apex:page standardController="Apttus_Proposal__Proposal__c"> <script src="/soap/ajax/10.0/connection.js"> </script > <script src="/soap/ajax/10.0/apex.js"> </script > <apex:iframe src="{!URLFOR($Resource.SAP_Order_Checklist)}" id="theIframe"/> <script type="text/javascript"> window.onload=init() function init() { var p = new sforce.SObject('Apttus_Proposal__Proposal__c'); p.Id = "{!Apttus_Proposal__Proposal__c.Id}"; p.sap_checklist_accessed__c = true; result = sforce.connection.update([p]); location.href="https://wktaatest--taatest.cs54.my.salesforce.com/"+p.Id }; </script> </apex:page>
Here is my code.

trigger CopyPromotionName on Apttus_Proposal__Proposal_Line_Item__c (after insert,after update) {


  Map<String,String> PromotionLookup = new Map<String,String>();
  Set<String> PromotionCode = new Set<String>();    

  for(Apttus_proposal__proposal_line_Item__c p:Trigger.new) {
    PromotionCode.add(p.apts_promo_code__c);
  }
  
  for(Promotion__c QP:

    [SELECT      name,promo_code__c
     FROM        Promotion__c
     WHERE       promo_code__c IN :PromotionCode]) {

     PromotionLookup.put(QP.Name,QP.Promotion_Code__c);

  }

  for(Apttus_proposal__proposal_line_Item__c p:Trigger.new) {

    if(PromotionLookup.containsKey(p.apts_Promo_Code__c)) {

      p.Promotion_Name__C = PromotionLookup.get(QP.name);

    }

  }
Here is my code, but it does not fire.

apex:page standardController="Opportunity"> <script src="/soap/ajax/10.0/connection.js"> </script > <script src="/soap/ajax/10.0/apex.js"> </script > <body onload="init()"/> <script type="text/javascript"> Function init() { alert("1") } { var p = new sforce.SObject('opportunity'); p.id = document.getElementById; var fulldate = (today.getMonth()+1)+'/'+today.getDate()+'/'+today.getFullYear(); var OppDateRaw = (new Date('{p.CloseDate}')); var formattedOppDate = (OppDateRaw.getMonth()+1) + '/'+OppDateRaw.getDate()+'/'+OppDateRaw.getFullYear(); if( formattedOppDate < fulldate) { alert("Close date cannot be in the past"); } else { if("{p.AMS_Order_Processing_Stage__c}" === "Approved" ) { p.AMS_Order_Processing_Stage__c = "Submitted to Order Processing"; result = sforce.connection.update([p]); location.reload(true); } else { alert("This opportunity has not been approved."); } } } window.history.back() } </script> </apex:page>
I am trying to have the selected row highlighted when the select button is clicked.
Since there is no action associated with the select command link, the page refreshes after clicking select, thus erasing any styling not based on the parameter ConId.
I am trying to have the styling applied conditionally based on the page parameter ConId.

<apex:page standardController="Account"> <apex:form > <apex:pageblock > <apex:pageblocktable value="{!account.Contacts}" var="item"> <apex:column headerValue="Select"> <apex:commandLink > <Apex:Outputtext value="Select"/> <apex:Param name="ConId" value="{!item.id}"/> </apex:CommandLink> </apex:column> <apex:column value="{!item.name}" style="{!if(item.id='{!$CurrentPage.parameters.ConId}','color:red','color:black')}"/> <apex:Column value="{!item.title}"/> <apex:Column value="{!item.Phone}"/> <apex:Column value="{!item.email}"/> <apex:Column value="{!item.mobilephone}"/> <apex:Column value="{!item.Inactive__c}"/> <apex:Column value="{!item.id}"/> </apex:pageblockTable> </apex:Pageblock> <br/> <br/> <apex:OutputLink value="{!account.ContactCallURL1__c}{!$CurrentPage.parameters.ConId}{!account.ContactCallURL2__c}"> <apex:OutputText style="color:blue;" value="Next"/> </apex:OutputLink> strId = {!$CurrentPage.parameters.ConId} </apex:form> </apex:page>
I am trying to write a custom VF page to display account history only for the logged in user.
I am using account as the standard controller, and have an extension controller to do the filtering.
I am getting the above error when attempting to save my VF page.

Class:
public class AccExtensions{
      Public List<Account> AHS{get;set;}
            public AccExtensions(ApexPages.StandardController controller) {
          AHS=[select id, name,(select ActivityDate, ActivityType from ActivityHistories where OwnerId = :UserInfo.getUserId())from account where ID=:ApexPages.currentPage().getParameters().get('id')];
          for(Account ah:AHS) {
 
             
                AHS.add(ah);
}
}
}

VF Page

<apex:page standardController="Account" extensions="AccExtensions" >
<apex:pageBlock>
<apex:pageblockTable value="{!AHS}" var="acch">
<apex:Column headervalue = "Date" value="{!acch.ActivityDate}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:page>
 
Getting error "Loop Variable Mut be of Type Account Line 7".
Here is my code.
No classes named accoutn.

trigger HasWorkPaperManager on Account (after insert, after update) {

    Map<ID, Account> parentAccount = new Map<ID, Account>();
    List<Id> listIds = new List<Id>();
    List<Id> LineItems = new List<Id>();

    for (AMS_Inventory_Rollup__c childObj : Trigger.new) {
        listIds.add(childObj.AccountID__c);
        LineItems.add(childObj.Id);
    }
  
    parentAccount = new Map<Id, Account>([SELECT id,Has_WorkPaper_Manager__c,(Select id from Ams_inventory_rollups__r where name = '511000') FROM account WHERE ID IN :listIds]);
   
    for (AMS_Inventory_Rollup__c AMSInventoryRollup: Trigger.new){
         Account myParentAccount = parentAccount.get(AMSInventoryRollup.Account);
        if(parentAccount.containsKey(AMSInventoryRollup.Account) && parentaccount.get(AMSInventoryRollup.Account).AMSInventoryRollups__r.size() > 0)
        {
            myParentAccount.Has_WorkPaper_Manager__c = true;
        }
        else
        {
            myParentAccount.Has_WorkPaper_Manager__c = false ;
        }
    }
    update parentAccount.values();
 }