• Tamara Hay
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 3
    Replies
Hoping someone can help me.
I need to find a way to add products to other line items without creating them as seperate products.
What I mean, we have products that get added to line items as the primary products. Often, we need to add other products related to these line items, such as install fee's and additional products (almost like a bundle situation).

Currently, we add all of these as individual line items, but this causes issues further down our sales process.

Ive tried creating a Junction object, related lists, lookup fields etc but I cant find anything that works.

We have a visualforce page to select initial product, and we have a custom object called "Provisioning Details" that we use to add all the technical requirements related to a line item.
Ideally, id like either a opplineitem related list within the provisioning detail object, or a way to add a secondary product line item to the primary line item.

Anyone have any suggestions on the best way to do this?
I have a custom button that we use for generting Docusign orders. This button is a copy of another working button, but uses different ID's as its for a different region with a different process. 
Ive been getting a parser error but unable to determine why:
{!REQUIRESCRIPT("/soap/ajax/27.0/connection.js")}

var querysql = 'select Contact__C, Role__C from Contact_Role__c where Role__c=\'Opportunity contact\' and Opportunity__c=\'';
querysql = querysql+'{!Opportunity.Id}\'';
//alert(querysql);
var result = sforce.connection.query(querysql);
var arrayResults = result.getArray("records");

var querysq2 = 'select id,OwnerId from Opportunity where Id=\'';
querysq2 = querysq2+'{!Opportunity.Id}\'';

var result2 = sforce.connection.query(querysq2);
var arrayResults2 = result2.getArray("records");

var querysq3 = 'select id,UserRoleId from User where Id=\'';
querysq3 = querysq3+arrayResults3[0].OwnerId+'\'';

var result3 = sforce.connection.query(querysq3);
var arrayResults3 = result3.getArray("records");

var querysq4 = 'select id,UserRoleId from User where Id=\'';
querysq4 = querysq4+arrayResults4[0].OwnerId+'\'';

var result4 = sforce.connection.query(querysq4);
var arrayResults4 = result4.getArray("records");

if(arrayResults[0])
{
var OCRrecord = arrayResults[0];
}
console.log(OCRrecord);
//alert(result);
//alert(arrayResults);
//alert('the id of the contact is '+ OCRrecord.ContactId);

var querysql1 = 'select ID from User where name like \'%Sales Support%\' limit 1';
//alert(querysql1);
var result1 = sforce.connection.query(querysql1);
var arrayResults1 = result1.getArray("records");
var ds1="";
var ds2="";
var ds3="";
var ds4="";
if(arrayResults1[0])
{
var OCRrecord1 = arrayResults1[0];
console.log(OCRrecord1);
ds1="&DocuSignR1Id="+OCRrecord.ContactId+"&DocuSignR1Role=Signer+1&DocuSignR1RoutingOrder=1";


if(arrayResults4[0].UserRoleId =="00E6F000001Jo7b" ||arrayResults3[0].UserRoleId =="00EN0000000Tu5H" ||arrayResults3[0].UserRoleId =="00E6F000001Jo7d"){
ds2="&DocuSignR2Id=00E6F000001Jo7c&DocuSignR2Role=Signer+2&DocuSignR2RoutingOrder=2";

}
else if(arrayResults4[0].UserRoleId =="00E6F000001Jo7L" ||arrayResults3[0].UserRoleId =="00E6F000001Jo7M" || UserRoleId =="00E6F000001Jo7Q" || UserRoleId =="00E6F000001Jo7P"){
ds2="&DocuSignR2Id=00E6F000001Jo7K&DocuSignR2Role=Signer+2&DocuSignR2RoutingOrder=2";
}
else if(arrayResults4[0].UserRoleId =="00E6F000001Jo7X" ||UserRoleId =="00E6F000001Jpc9"){
ds2="&DocuSignR2Id=00E6F000001Jo7K&DocuSignR2Role=Signer+2&DocuSignR2RoutingOrder=2";
}
else{
ds2="&DocuSignR2Id=00E6F000001Jo7K&DocuSignR2Role=Signer+2&DocuSignR2RoutingOrder=2";
}
ds3="&DocuSignR3Id=00E6F000001Jo7O&DocuSignR3Role=Signer+3&DocuSignR3RoutingOrder=3";
}
ds4="&DocuSignR4Id=00E6F000001Jo7R&DocuSignR4Role=Signer+4&DocuSignR3RoutingOrder=4";
}
else
{
alert('user name "Sales Support" no longer exists');
}
console.log(ds1);
console.log(ds2);
console.log(ds3);
//alert(result1);
//alert(arrayResults1);
//alert('the id of the contact is '+ OCRrecord1.ContactId);
/*

&DocuSignR1Id="+OCRrecord.ContactId+"\
&DocuSignR1RoutingOrder=1"+ds1+ds2+ds3+ds4+"\
&DocuSignR1Role=Signer+1\*/

console.log(ds1+ds2+ds3+ds4);

var discountstatus ="{!Opportunity.Allowed_to_Generate_Quote__c}";
if(discountstatus == "Yes")
var opportunityapproved ="{!Opportunity.Opportunity_Approved__c}";
if(opportunityapproved == "Yes"){
var congaurl="https://composer.congamerge.com?sessionId={!API.Session_ID}\
&serverUrl={!API.Partner_Server_URL_80}\
&ID={!Opportunity.Id}\
&DocuSignVisible=1"+ds1+ds2+ds3+ds4+"\
&TemplateID={!Opportunity.Template_ID__c}\
&QueryID=[primarycontact]a0T6F00000MlxhO?pv0={!Opportunity.Id}~pv1=True\
&QueryID=[customcontactrole]a0T6F00000MlxZ5?pv0={!Opportunity.Id}~pv1=False\
&QueryID=[iptransit]a0T6F00000NHA5v?pv0={!Opportunity.Id}~pv1=IP Transit\
&QueryID=[ethernet]a0T6F00000NHA5v?pv0={!Opportunity.Id}~pv1=Ethernet\
&QueryID=[ipwan]a0T6F00000NHA5v?pv0={!Opportunity.Id}~pv1=IP WAN\
&QueryID=[datacentre]a0T6F00000NHA5v?pv0={!Opportunity.Id}~pv1=Data Centre\
&QueryID=[darkfibre]a0T6F00000NHA5v?pv0={!Opportunity.Id}~pv1=Dark Fibre\
&QueryID=[networkservices]a0T6F00000NHA5v?pv0={!Opportunity.Id}~pv1=Network Services\
&QueryID=[businessconnect]a0T6F00000NHA5v?pv0={!Opportunity.Id}~pv1=Business Connect\
&QueryID=[voice]a0T6F00000NHA5v?pv0={!Opportunity.Id}~pv1=Voice\
&QueryID=[wholesaleaccess]a0T6F00000NHA5v?pv0={!Opportunity.Id}~pv1=Wholesale Access\
&QueryID=[setup]a0T90000005Vfuz?pv0={!Opportunity.Id}~pv1=Setup\
&QueryID=[monthly]a0T90000005Vfuz?pv0={!Opportunity.Id}~pv1=Monthly\
&QueryID=[charges]a0T90000005Vfuz?pv0={!Opportunity.Id}\
&MFTS0=test_Date_field__c\
&MFTSValue0=Today\
&fp0=1\
&LG0=0\
&DocuSignExpireIn=120\
&LG4=1\
&LG3=1\
&ds2=1\
&DS7Preview=17\
&ds7=7\
&DocuSignTag=1\
&OFN=Service+Order+-+-{!Opportunity.Quote_Number__c}-+{!Opportunity.Account}+-+{!NOW()}\
&EmailRelatedToId={!Opportunity.Id}\
&EmailTemplateId=00X90000001EMwL";
//alert(congaurl);
window.open(congaurl,"mywindow","scrollbars=1,resizable=1, height=300");
}
else {
alert ("Opportunity has exceeded the max discount level and needs to be submitted for Approval. Please click the 'Submit for Approval' button");
}
I have a link on my opportunity line item that users click to create a case for a specific team. Currently, the case record type creates as the default record type which is "Sales Support", however these need to override the default assignment rules and create a "Feasibility" case.
We had a developer create this who is no longer with us. There is a controller and visualforce page.
This is what I have:

Visualforce page:

<apex:page standardController="Case" extensions="FeasibilityRequestCaseController">
<script language="javascript">
   window.onload = new function() 
   { 
      // bring popup window to front
      window.focus(); 
      var ele=document.getElementById('{!$Component.form.block.section.olilookupid}');
      if (ele)
      {
         ele.focus();
      }
       
      var ele1=winMain.document.getElementById('{!$CurrentPage.parameters.olilookupid}');
      ele1.value=olilookupid;
       
   }
   
   function fillIn(addressField, olilookupid)
   {
      var winMain=window.opener;
      if (null==winMain)
      {
         winMain=window.parent.opener;
      }
      var ele=winMain.document.getElementById('{!$CurrentPage.parameters.olilookupid}');
      ele.value=olilookupid;

      var ele1=winMain.document.getElementById('{!$CurrentPage.parameters.olilookupid}');
      ele1.value=olilookupid;
               
      CloseWindow();
   }

   function CloseWindow()
   {
      alert('Thanks for raising new case for feasibility request. Feasibilty analysis personnel will update available feasibility options for you shortly.');
      var winMain=window.opener;
      if (null==winMain)
      {
         winMain=window.parent.opener;
      }
      winMain.closeLookupPopup();
   }
</script>    
    
    
<apex:pageBlock >
<apex:pageBlockSection title="Raise a New Case - Request Feasibility Analysis" columns="1" showHeader="True" collapsible="False">
</apex:pageBlockSection>
</apex:pageBlock>
<apex:form >
<apex:pageBlock title="Feasibility Request - Case Information" >
<apex:pageBlockButtons >
    <apex:commandButton action="{!save}" value="Submit for Feasibility Analysis" oncomplete="CloseWindow();"/>
</apex:pageBlockButtons>
    <apex:pageBlockSection >
    <apex:inputField value="{!frc.Subject}" style="width: 360px;"/>        
    <apex:inputField value="{!frc.Opportunity__c}"/>
    <apex:inputField value="{!frc.Reason}"/>
    <apex:inputField value="{!frc.Status}"/>
    <apex:inputField value="{!frc.Description}" style="width: 360px; height: 40px"/>
    <apex:inputField value="{!frc.Origin}"/>
    <!--<apex:inputField value="{!frc.RecordType.Name}"/>-->
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>


Controller:
public class FeasibilityRequestCaseController {
    public String oliID{get; set;}
    public String olilookupid{get; set;}
    public Case frc{get; set;}
    public String address{get; set;}
    
public FeasibilityRequestCaseController (ApexPages.StandardController controller) {
        String oliId = ApexPages.currentPage().getParameters().get('oliIDForNewCase');
        String olilookupid = ApexPages.currentPage().getParameters().get('olilookupid');
        String caseName = '';
        String caseAddress = '';
        opportunitylineitem oli;
        Id oppId;
        Id oppLIId;
        //oliId = '\'' + oliId + '\'';

        System.debug('FeasibilityRequestCaseController:: oliId - ' + oliId + ' :: olilookupid - ' + olilookupid);
        System.debug('Query:: Select id, name, Address_AEnd__c, OpportunityId from opportunitylineitem where id = ' + olilookupid);
    
        if(olilookupid!=null){    
        oli = [Select id, name, Address_AEnd__c, OpportunityId from opportunitylineitem where id = :olilookupid];
                caseName = oli.Name;
                caseAddress = oli.Address_AEnd__c;
                oppId = oli.OpportunityId;
                oppLIId = oli.Id;
        }
        
        // RecordType recordType = [Select Id From RecordType  Where SobjectType = 'Case' and Name = 'NZ Feasibility'];
    
        frc = new Case();    
        frc.Subject='New Feasibility Request: ' + olilookupid;
        frc.Reason='Supplier quote request';
        frc.Status='Open';    
        frc.Origin='Opportunity';
        frc.Description='Please provide feasibility for Address: ' + oliId;
        // frc.RecordType=recordType;
        frc.isBEnd__c=false;
        //frc.Related_Product_del__C = oppLIId;
        frc.oliid__c=olilookupid;
        if(oppId!=null) frc.Opportunity__c= oppId;
    }

public pagereference Save()
    {
        insert frc;
        Case c = [select Casenumber from Case where id=:frc.id];
        system.debug('New Case Number: ' + c.Casenumber );
        return null;
    }
        
}
I work for a highly successful fast growing Telecommuncations company and im looking for an experience developer for a full time permanent role based in Sydney.
Contact me If ou would like more details:
tamara.hay@vocus.com.au
I have the below trigger which adds a dropdown called Provisioning_Detail__c when a product is added. This works fine when adding single product or different products, but if we want to add more than 1 or the same product, we need to click "Save" and go through the entire product selector again or the proisioning details object does not save to the product line item.
Can someone help me amend the code so we dont need to save and re-add the product every time.


trigger CreateProvisioningDetailNew on OpportunityLineItem (after insert) {
    List<Provisioning_Detail__c> newProvDetailList = new List<Provisioning_Detail__c>();
    Map<Id,opportunityLineItem> oppAndIdMap = new Map<Id,opportunityLineItem>();
    Map<Id,Id> oppLineAndProvUpdateInfoMap = new  Map<Id,Id>();
    String oppAndProductName;
    Database.SaveResult[] lsr;
   
    Set<Id> insertedProvId = new Set<Id>();
    for(opportunityLineItem  oppl:[select id,opportunity.id,opportunity.name,pricebookEntry.Name  from opportunityLineItem where id in :trigger.newMap.keyset()]){
        oppAndIdMap.put(oppl.Id,oppl);
    }
    
    for(OpportunityLineItem oli:trigger.new){
        if((oli.Provisioning_Detail__c==null) &&(oli.Provisioning_Detail_Required__c=='Yes')){
            Provisioning_Detail__c newProvDet = new Provisioning_Detail__c();
            newProvDet.Product_Family__c = oli.Product_Family__c;
            //newProvDet.Opportunity__r.id = oli.Opportunity.id;
            newProvDet.Opportunity__c=oli.OpportunityId;
            newProvDet.Opp_Line_Item_ID__c = oli.id;
            oppAndProductName =oppAndIdMap.get(oli.id).opportunity.name + oppAndIdMap.get(oli.id).pricebookEntry.Name; 
            newProvDet.Name =oppAndProductName.left(80);
            newProvDet.Product_Name__c = oppAndIdMap.get(oli.id).pricebookEntry.Name; 
            newProvDetailList.add(newProvDet);
        }
    }
    try{
       lsr = database.insert(newProvDetailList);
    }catch(DmlException de){
        system.debug('---------->>>>>>>>>>>>>'+de.getMessage());
    }
    for(Database.SaveResult dsr : lsr){
        insertedProvId.add(dsr.getId());
    }
    for(Provisioning_Detail__c p:[select id,Opp_Line_Item_ID__c  from Provisioning_Detail__c where id in:insertedProvId]){
        oppLineAndProvUpdateInfoMap.put(p.Opp_Line_Item_ID__c,p.id);
    }
   List<opportunityLineItem> oppLineItemList = new List<opportunityLineItem>([select id,Provisioning_Detail__c from opportunityLineItem where id in:oppLineAndProvUpdateInfoMap.keyset()]);
   for(opportunityLineItem ol:oppLineItemList ){
       ol.Provisioning_Detail__c = oppLineAndProvUpdateInfoMap.get(ol.Id);
   }
   try{
       database.update(oppLineItemList);
   }catch(DmlException dmll){
       system.debug('------------>>>>>>>>>>>>>>>>>>'+dmll.getMessage());
Ive created a 2 step apprval process, with the assigned approver different for each step. When testing, the first step works, but it never follows through to step 2. If i re-click "submit for approval" once the first step is approved, it just resubmits that again and its oesnt automaticallyflow through to step 2.
Am I missing something?

Hoping someone can help me.
I need to find a way to add products to other line items without creating them as seperate products.
What I mean, we have products that get added to line items as the primary products. Often, we need to add other products related to these line items, such as install fee's and additional products (almost like a bundle situation).

Currently, we add all of these as individual line items, but this causes issues further down our sales process.

Ive tried creating a Junction object, related lists, lookup fields etc but I cant find anything that works.

We have a visualforce page to select initial product, and we have a custom object called "Provisioning Details" that we use to add all the technical requirements related to a line item.
Ideally, id like either a opplineitem related list within the provisioning detail object, or a way to add a secondary product line item to the primary line item.

Anyone have any suggestions on the best way to do this?
I have the below trigger which adds a dropdown called Provisioning_Detail__c when a product is added. This works fine when adding single product or different products, but if we want to add more than 1 or the same product, we need to click "Save" and go through the entire product selector again or the proisioning details object does not save to the product line item.
Can someone help me amend the code so we dont need to save and re-add the product every time.


trigger CreateProvisioningDetailNew on OpportunityLineItem (after insert) {
    List<Provisioning_Detail__c> newProvDetailList = new List<Provisioning_Detail__c>();
    Map<Id,opportunityLineItem> oppAndIdMap = new Map<Id,opportunityLineItem>();
    Map<Id,Id> oppLineAndProvUpdateInfoMap = new  Map<Id,Id>();
    String oppAndProductName;
    Database.SaveResult[] lsr;
   
    Set<Id> insertedProvId = new Set<Id>();
    for(opportunityLineItem  oppl:[select id,opportunity.id,opportunity.name,pricebookEntry.Name  from opportunityLineItem where id in :trigger.newMap.keyset()]){
        oppAndIdMap.put(oppl.Id,oppl);
    }
    
    for(OpportunityLineItem oli:trigger.new){
        if((oli.Provisioning_Detail__c==null) &&(oli.Provisioning_Detail_Required__c=='Yes')){
            Provisioning_Detail__c newProvDet = new Provisioning_Detail__c();
            newProvDet.Product_Family__c = oli.Product_Family__c;
            //newProvDet.Opportunity__r.id = oli.Opportunity.id;
            newProvDet.Opportunity__c=oli.OpportunityId;
            newProvDet.Opp_Line_Item_ID__c = oli.id;
            oppAndProductName =oppAndIdMap.get(oli.id).opportunity.name + oppAndIdMap.get(oli.id).pricebookEntry.Name; 
            newProvDet.Name =oppAndProductName.left(80);
            newProvDet.Product_Name__c = oppAndIdMap.get(oli.id).pricebookEntry.Name; 
            newProvDetailList.add(newProvDet);
        }
    }
    try{
       lsr = database.insert(newProvDetailList);
    }catch(DmlException de){
        system.debug('---------->>>>>>>>>>>>>'+de.getMessage());
    }
    for(Database.SaveResult dsr : lsr){
        insertedProvId.add(dsr.getId());
    }
    for(Provisioning_Detail__c p:[select id,Opp_Line_Item_ID__c  from Provisioning_Detail__c where id in:insertedProvId]){
        oppLineAndProvUpdateInfoMap.put(p.Opp_Line_Item_ID__c,p.id);
    }
   List<opportunityLineItem> oppLineItemList = new List<opportunityLineItem>([select id,Provisioning_Detail__c from opportunityLineItem where id in:oppLineAndProvUpdateInfoMap.keyset()]);
   for(opportunityLineItem ol:oppLineItemList ){
       ol.Provisioning_Detail__c = oppLineAndProvUpdateInfoMap.get(ol.Id);
   }
   try{
       database.update(oppLineItemList);
   }catch(DmlException dmll){
       system.debug('------------>>>>>>>>>>>>>>>>>>'+dmll.getMessage());