• theop
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 9
    Replies

Hi, I have a strange issue. Users can't view/edit tasks where they aren't the owner. These tasks are on a custom object.

Here is what I've checked so far:

Profiles have full CRUD access on the custom object and fields.
Field level security on Task, everything is visible.
General User Permissions, Edit Tasks is Checked.
Tried all this on 3 different licenses: Standard, Force.com - One App and Salesforce Platform


Any insight will be greatly appreciated!
Theo

  • May 08, 2013
  • Like
  • 0

Hi, when you're on a Portal Contact you can "Login as Portal User", this takes you to the portal logged in as the user. Is there anyway you can log into a "site" with this Portal Contac credentialst? Thanks

  • April 16, 2013
  • Like
  • 0

Hi, I have a datatable that doesn't seem to want to render in a popup and the data is there. The command links show and function fine, ex: http://puu.sh/2gfL8

 

Any help appreciated, thanks,

Theo

 

@@@this.PopedSpecialEventFees: (evt__Event_Fee__c:{Name=Registration, evt__Description__c=<br>, CurrencyIsoCode=USD, Id=a0rV0000000Owo9IAC, evt__Amount__c=100.00, evt__Category__c=Attendee}, evt__Event_Fee__c:{Name=Lunch Fee, evt__Description__c=<br>, CurrencyIsoCode=USD, Id=a0rV0000000OwoEIAS, evt__Amount__c=20.00, evt__Category__c=Attendee}, evt__Event_Fee__c:{Name=Event Fee Payment - 30 days, evt__Description__c=<br>, CurrencyIsoCode=USD, Id=a0rV0000000OwPWIA0, evt__Amount__c=500.00, evt__Category__c=Attendee}, evt__Event_Fee__c:{Name=Event Fee Payment - 60 days, evt__Description__c=<br>, CurrencyIsoCode=USD, Id=a0rV0000000OwPbIAK, evt__Amount__c=450.00, evt__Category__c=Attendee})

 

 

    public pagereference showSEPopUp(){
        List<evt__Event_Fee__c> tempPopedSpecialEventFees = [SELECT Id, Name, evt__Amount__c, evt__Category__c, evt__Description__c
                                      FROM evt__Event_Fee__c 
                                      WHERE evt__Active__c = true
                                      ORDER BY evt__Order__c];

        
        System.debug('@@@this.PopedSpecialEventFees: ' + this.PopedSpecialEventFees);
        this.sePopup = true;
        
        this.PopedSpecialEventFees = tempPopedSpecialEventFees;
        
        return null;
    }//showPopUp

 

                <apex:actionRegion id="act"> 
                    <apex:outputPanel id="sepopup">
                        <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!sePopup}"/>
                        <apex:outputPanel styleClass="custPopup" id="opanel" layout="block" rendered="{!sePopup}">
                            start
                            <apex:outputPanel id="sefees" >
                                <apex:dataTable value="{!PopedSpecialEventFees}" var="eventfee" id="eventfees">
                                    <apex:column value="{!eventfee.Name}" headerValue="Name"/>
                                    <apex:column value="{!eventfee.evt__Category__c}" headerValue="Category"/>
                                    <apex:column value="{!eventfee.evt__Description__c}"  headerValue="Description"/>
                                    <apex:column value="{!eventfee.evt__Amount__c}"  headerValue="Amount"/>
                                </apex:dataTable>
                            </apex:outputPanel>
                            end
                            <table>
                                <tr>
                                    <td width="20%">
                                        <div style="float:left">
                                            <apex:commandlink action="{!HidePopUps}" rerender="sepopup">
                                                <apex:image style="" id="theCancelImage" value="{!URLFOR($Resource.ACAMS__Resources,'image/cancel.png')}" />
                                            </apex:commandlink>
                                        </div>
                                        <div style="float:right">
                                            <apex:commandlink action="{!AddToCart}" rerender="sepopup">
                                                <apex:image style="" id="theAddToCartImage" value="{!URLFOR($Resource.ACAMS__Resources,'image/addtocart.png')}" />
                                            </apex:commandlink>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                            
                        </apex:outputPanel>
                    </apex:outputPanel>
                </apex:actionRegion>

 

  • March 12, 2013
  • Like
  • 0

Is it possible to allow users to change their own manager? Thanks

  • February 20, 2013
  • Like
  • 0

Hi, I have an approval process and would like to post to Chatter group on Approved. I have check the Send Session Id checkbox and here is my endpoint:

 

https://cs12.salesforce.com/services/data/v26.0/chatter/feeds/record/0F9V00000008SF1/feed-items?text=first+outbound+message

 

In the Outboud Messaging Delivery Status I get a faliture reason: (401) Unauthorized What I'm I missing?

Thanks for any help.

  • January 28, 2013
  • Like
  • 0

This is on the sandbox and I can't figure out why this trigger test isn't firing. All system debug get hit and have the correct data, System.debug('@@@ trgInsertNote');

 

trigger trgInsertNote on Note (after insert) {
    
    System.debug('@@@ trgInsertNote');
    BMCServiceDesk__Incident__c toUpdate = new BMCServiceDesk__Incident__c();
    
    for(Note n : Trigger.New){
        String nName = n.ParentId;
        String iName = Schema.getGlobalDescribe().get('BMCServiceDesk__Incident__c').getDescribe().getKeyPrefix();
        
        if ( nName.startsWith(iName) && !n.IsPrivate ) {
            
            toUpdate = [SELECT X3Ci_Last_Note__c FROM BMCServiceDesk__Incident__c WHERE Id = :nName][0];
            if ( n.Body == '' || n.body == null )
                toUpdate.X3Ci_Last_Note__c = n.Title;
            else
                toUpdate.X3Ci_Last_Note__c = n.Title + ': ' + n.Body;
        }
    }
    
    if ( toUpdate != null)
        update toUpdate;
}

 

@isTest(SeeAllData=true) 
public with sharing class TestTrgInsertNote{
    private static TestMethod void testInsertNoteMethod(){
        
        Profile cvProfile = [select id from profile where name = 'Standard User' limit 1];
        User usrCV = new User();
        usrCV.LastName='Test Client Value';
        usrCV.Username='dsfg@gmail.com23453245';
        usrCV.Alias='tesy07';
        usrCV.Email='sdfg@sdfg.com';
        usrCV.CommunityNickname='Test CV Contact';
        usrCV.TimeZoneSidKey='America/Los_Angeles';
        usrCV.localesidkey='en_US';
        usrCV.EmailEncodingKey='ISO-8859-1';
        usrCV.LanguageLocaleKey ='en_US';
        usrCV.ProfileId=cvProfile.id;
        usrCV.IsActive = true;
        Insert usrCV;
        System.debug('@@@ TestTrgInsertNote.usrCV: ' + usrCV);
        
        BMCServiceDesk__Incident__c testIncident = new BMCServiceDesk__Incident__c();
        testIncident.Subject__c = 'Test Incident';
        testIncident.BMCServiceDesk__FKClient__c = usrCV.Id;
        insert testIncident;
        System.debug('@@@ TestTrgInsertNote.testIncident: ' + testIncident);
        
        Note newNote = new Note(Title='Test title', Body='Test body', ParentId = testIncident.Id, IsPrivate = false);
        System.debug('@@@ TestTrgInsertNote.newNote: ' + newNote);
    }
}

 

  • December 31, 2013
  • Like
  • 0

I have a workflow that kicks of when the stage changes to 'Closed Won' The issue is that the workflow doesn't get kicked of if a brand new opportunity gets created and immediated set to 'Closed Won' I'm trying to check to see if the StageName is ISBLANK, ISNULL, etc. But can't get the right combination. When the stage gets changed on when it was set to something works. Evaluation Criteria is set to 'Evaluate the rule when a record is created, and every time it’s edited' Here is what I've tried. Thanks for any help.

 

OR(
AND( NOT(ISPICKVAL(PRIORVALUE(StageName ), "Closed Won")), ISPICKVAL( StageName , "Closed Won") ), 
AND( ISNULL(PRIORVALUE(StageName)), ISPICKVAL( StageName , "Closed Won") ) 
)

 

OR(
AND( NOT(ISPICKVAL(PRIORVALUE(StageName ), "Closed Won")), ISPICKVAL( StageName , "Closed Won") ), 
AND( ISBLANK(PRIORVALUE(StageName)), ISPICKVAL( StageName , "Closed Won") ) 
)

 

OR( 
AND( NOT(ISPICKVAL(PRIORVALUE(StageName ), "Closed Won")), ISPICKVAL( StageName , "Closed Won") ), 
AND( ISPICKVAL(PRIORVALUE(StageName ), ""), ISPICKVAL( StageName , "Closed Won") ) 
)

 

  • December 24, 2012
  • Like
  • 0

I've created a VF page to add multiple products based of http://bobbuzzard.blogspot.co.uk/2011/07/managing-list-of-new-records-in.html

 

Everything works execpt when I try to Save I get the error: common.apex.runtime.impl.ExecutionException: Invalid conversion from runtime type String to SOBJECT:Opportunity

 
But, I'm not assign the opportunity to anything and System.debug don't get trigger in the Save function. Any help will greatly appriciated! Thanks
 
<apex:page standardController="Product2" extensions="CustomProducts" tabStyle="Opportunity">
<apex:sectionHeader title="Custom Messaging Products" subtitle="{!oppSO.Name}"/>
<apex:form >
     <apex:inputHidden value="{!oppSO}"/>
    
      <apex:pageBlock title="New Message Tier Products">
          
          <apex:pageMessages />
              
          <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
                       <apex:column headerValue="Ident">
            <apex:outputText value="{!wrapper.ident}"/>
         </apex:column>
             <apex:column headerValue="Min">
                <apex:inputField value="{!wrapper.p.Min__c}"/>
             </apex:column>
             <apex:column headerValue="Max">
                <apex:inputField value="{!wrapper.p.Max__c}"/>
             </apex:column>
             <apex:column headerValue="Action">
                <apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable" immediate="true">
                   <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/> 
                </apex:commandButton>
             </apex:column>
          </apex:pageBlockTable>
          
          <apex:pageBlockButtons >
              <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable" immediate="true">
                  <apex:param name="addCount" value="1" assignTo="{!addCount}"/> 
              </apex:commandButton>
              <apex:commandButton value="Save" action="{!save}"/>
              <apex:commandButton value="Cancel" action="{!cancel}"/>
          </apex:pageBlockButtons>
      </apex:pageBlock>
      
    </apex:form>
</apex:page>

 

public class CustomProducts {
    
    public Opportunity oppSO {get;set;}
    public List<Product2WrapperCustomMsg> wrappers {get;set;}
    public static Integer toDelIdent {get; set;}
	public static Integer addCount {get; set;}
 	private Integer nextIdent;
        
    static final String STR_CUSTOM_LOOLKUP_PRE = 'SB-US-MSGCUSTOM';
    static final String STR_CUSTOM_LOOLKUP_POST = '-USAGE-MT';
    static final String LKP_QBFAMILY = '44100 · Sales Revenue - Standard Rate M';
        
    //
    // Contructor
    //
    public CustomProducts(ApexPages.StandardController controller) {
        String oppId = (String)Apexpages.currentPage().getParameters().get('oppid');
        this.oppSO = [Select Id, Name From Opportunity Where Id = :oppId];
        System.debug('@@@this.oppSO: ' + this.oppSO);
        
        wrappers = new List<Product2WrapperCustomMsg>();
        for (Integer idx = 0; idx < 4; idx++) 
        {
            if (nextIdent == null)
                nextIdent = this.GetNextIncrement();
            else
                nextIdent++;
            
            wrappers.add(new Product2WrapperCustomMsg(nextIdent));
            
        }

    }
    
    public Integer GetNextIncrement()
    {
        Integer currentMax = 0;
        for(Product2 p:[Select Id, Name, ProductCode from Product2 WHERE ProductCode LIKE :STR_CUSTOM_LOOLKUP_PRE + '%'])
        {	
            //SB-US-MSGCUSTOM1-USAGE-MT
            String tempCode = p.ProductCode.substring(STR_CUSTOM_LOOLKUP_PRE.length()); 
            tempCode = tempCode.substring(0, tempCode.indexOf('-')); 
            
            if (integer.valueof(tempCode) > currentMax )
                currentMax = integer.valueof(tempCode);
            
        } //for
        
        return currentMax + 1;
    } // GetNextIncrement
    
    public PageReference save()
    {
            System.debug('@@@ CustomProducts.save.wrappers : ' + wrappers );
        List<Product2> prds = new List<Product2>();
        for (Product2WrapperCustomMsg wrap : wrappers)
        {
            wrap.p.Name = GetProductName(wrap.p.Min__c, wrap.p.Max__c);
            prds.add(wrap.p);
            System.debug('@@@ CustomProducts.save.wrap.p : ' + wrap.p );
        }
        
        insert prds;
        
        return new PageReference('/006V0000002zPVi');
        
        //return new PageReference('/' + Schema.getGlobalDescribe().get('Opportunity').getDescribe().getKeyPrefix() + '/o');
    } // save
    
    public void delWrapper() {
        Integer toDelPos=-1;
        for (Integer idx=0; idx<wrappers.size(); idx++) {
            if (wrappers[idx].ident==toDelIdent) {
                toDelPos=idx;
            }
        }
        
        if (-1!=toDelPos) {
            wrappers.remove(toDelPos);
        }
    } // delWrapper
    
    public void addRows() {
        nextIdent = nextIdent + 1;
        wrappers.add(new Product2WrapperCustomMsg(nextIdent));
        System.debug('@@@ CustomProducts.addRows.wrappers: ' + wrappers);
    }
    
    // Format: Message Plan - Up to 100,000 Messages - Mobile Terminated (MT)
    // Format: Message Plan - 500,000-1,000,000 Messages - Mobile Terminated (MT)
    // Format: Message Plan - 1,000,000 and Above Messages - Mobile Terminated (MT)
    public String GetProductName(Decimal min, Decimal max)
    {
        String retString = '';
        
        if (min == 0 || min == 1) {
            retString = 'Message Plan - Up to ' + max + ' Messages - Mobile Terminated (MT)';
        }
        else if (max == 999999999) {
            retString = 'Message Plan - ' + min + ' and Above Messages - Mobile Terminated (MT)';
        }
        else {
            retString = 'Message Plan - ' + min + '-' + max + ' Messages - Mobile Terminated (MT)';
        }
        System.debug('@@@ Product2WrapperCustomMsg.GetProductName.retString : ' + retString );
        return retString ;
        
    } // GetProductName
    
    public class Product2WrapperCustomMsg
    {
        public Product2 p {get; private set;}
        public Integer ident {get; private set;}
       
        public Product2WrapperCustomMsg(Integer inIdent)
        {
			ident = inIdent;
            
            p = new Product2();
            //p.Name = CustomProducts.GetProductName(0, 999999999);
            p.ProductCode = STR_CUSTOM_LOOLKUP_PRE  + inIdent + STR_CUSTOM_LOOLKUP_POST;
            p.Min__c = 0;
            p.Max__c = 999999999;
            p.QB_Do_Sync__c = true;
            p.QB_AccountFamily__c = LKP_QBFAMILY;
            p.Message_Product_Id__c = inIdent;
            p.CanUseQuantitySchedule = true;
            p.Family = 'Message Plan Tiered';
        }
    } // Product2WrapperCustomMsg
}

 

  • December 16, 2012
  • Like
  • 0

Hi, I have a datatable that doesn't seem to want to render in a popup and the data is there. The command links show and function fine, ex: http://puu.sh/2gfL8

 

Any help appreciated, thanks,

Theo

 

@@@this.PopedSpecialEventFees: (evt__Event_Fee__c:{Name=Registration, evt__Description__c=<br>, CurrencyIsoCode=USD, Id=a0rV0000000Owo9IAC, evt__Amount__c=100.00, evt__Category__c=Attendee}, evt__Event_Fee__c:{Name=Lunch Fee, evt__Description__c=<br>, CurrencyIsoCode=USD, Id=a0rV0000000OwoEIAS, evt__Amount__c=20.00, evt__Category__c=Attendee}, evt__Event_Fee__c:{Name=Event Fee Payment - 30 days, evt__Description__c=<br>, CurrencyIsoCode=USD, Id=a0rV0000000OwPWIA0, evt__Amount__c=500.00, evt__Category__c=Attendee}, evt__Event_Fee__c:{Name=Event Fee Payment - 60 days, evt__Description__c=<br>, CurrencyIsoCode=USD, Id=a0rV0000000OwPbIAK, evt__Amount__c=450.00, evt__Category__c=Attendee})

 

 

    public pagereference showSEPopUp(){
        List<evt__Event_Fee__c> tempPopedSpecialEventFees = [SELECT Id, Name, evt__Amount__c, evt__Category__c, evt__Description__c
                                      FROM evt__Event_Fee__c 
                                      WHERE evt__Active__c = true
                                      ORDER BY evt__Order__c];

        
        System.debug('@@@this.PopedSpecialEventFees: ' + this.PopedSpecialEventFees);
        this.sePopup = true;
        
        this.PopedSpecialEventFees = tempPopedSpecialEventFees;
        
        return null;
    }//showPopUp

 

                <apex:actionRegion id="act"> 
                    <apex:outputPanel id="sepopup">
                        <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!sePopup}"/>
                        <apex:outputPanel styleClass="custPopup" id="opanel" layout="block" rendered="{!sePopup}">
                            start
                            <apex:outputPanel id="sefees" >
                                <apex:dataTable value="{!PopedSpecialEventFees}" var="eventfee" id="eventfees">
                                    <apex:column value="{!eventfee.Name}" headerValue="Name"/>
                                    <apex:column value="{!eventfee.evt__Category__c}" headerValue="Category"/>
                                    <apex:column value="{!eventfee.evt__Description__c}"  headerValue="Description"/>
                                    <apex:column value="{!eventfee.evt__Amount__c}"  headerValue="Amount"/>
                                </apex:dataTable>
                            </apex:outputPanel>
                            end
                            <table>
                                <tr>
                                    <td width="20%">
                                        <div style="float:left">
                                            <apex:commandlink action="{!HidePopUps}" rerender="sepopup">
                                                <apex:image style="" id="theCancelImage" value="{!URLFOR($Resource.ACAMS__Resources,'image/cancel.png')}" />
                                            </apex:commandlink>
                                        </div>
                                        <div style="float:right">
                                            <apex:commandlink action="{!AddToCart}" rerender="sepopup">
                                                <apex:image style="" id="theAddToCartImage" value="{!URLFOR($Resource.ACAMS__Resources,'image/addtocart.png')}" />
                                            </apex:commandlink>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                            
                        </apex:outputPanel>
                    </apex:outputPanel>
                </apex:actionRegion>

 

  • March 12, 2013
  • Like
  • 0

Hi, I have an approval process and would like to post to Chatter group on Approved. I have check the Send Session Id checkbox and here is my endpoint:

 

https://cs12.salesforce.com/services/data/v26.0/chatter/feeds/record/0F9V00000008SF1/feed-items?text=first+outbound+message

 

In the Outboud Messaging Delivery Status I get a faliture reason: (401) Unauthorized What I'm I missing?

Thanks for any help.

  • January 28, 2013
  • Like
  • 0

This is on the sandbox and I can't figure out why this trigger test isn't firing. All system debug get hit and have the correct data, System.debug('@@@ trgInsertNote');

 

trigger trgInsertNote on Note (after insert) {
    
    System.debug('@@@ trgInsertNote');
    BMCServiceDesk__Incident__c toUpdate = new BMCServiceDesk__Incident__c();
    
    for(Note n : Trigger.New){
        String nName = n.ParentId;
        String iName = Schema.getGlobalDescribe().get('BMCServiceDesk__Incident__c').getDescribe().getKeyPrefix();
        
        if ( nName.startsWith(iName) && !n.IsPrivate ) {
            
            toUpdate = [SELECT X3Ci_Last_Note__c FROM BMCServiceDesk__Incident__c WHERE Id = :nName][0];
            if ( n.Body == '' || n.body == null )
                toUpdate.X3Ci_Last_Note__c = n.Title;
            else
                toUpdate.X3Ci_Last_Note__c = n.Title + ': ' + n.Body;
        }
    }
    
    if ( toUpdate != null)
        update toUpdate;
}

 

@isTest(SeeAllData=true) 
public with sharing class TestTrgInsertNote{
    private static TestMethod void testInsertNoteMethod(){
        
        Profile cvProfile = [select id from profile where name = 'Standard User' limit 1];
        User usrCV = new User();
        usrCV.LastName='Test Client Value';
        usrCV.Username='dsfg@gmail.com23453245';
        usrCV.Alias='tesy07';
        usrCV.Email='sdfg@sdfg.com';
        usrCV.CommunityNickname='Test CV Contact';
        usrCV.TimeZoneSidKey='America/Los_Angeles';
        usrCV.localesidkey='en_US';
        usrCV.EmailEncodingKey='ISO-8859-1';
        usrCV.LanguageLocaleKey ='en_US';
        usrCV.ProfileId=cvProfile.id;
        usrCV.IsActive = true;
        Insert usrCV;
        System.debug('@@@ TestTrgInsertNote.usrCV: ' + usrCV);
        
        BMCServiceDesk__Incident__c testIncident = new BMCServiceDesk__Incident__c();
        testIncident.Subject__c = 'Test Incident';
        testIncident.BMCServiceDesk__FKClient__c = usrCV.Id;
        insert testIncident;
        System.debug('@@@ TestTrgInsertNote.testIncident: ' + testIncident);
        
        Note newNote = new Note(Title='Test title', Body='Test body', ParentId = testIncident.Id, IsPrivate = false);
        System.debug('@@@ TestTrgInsertNote.newNote: ' + newNote);
    }
}

 

  • December 31, 2013
  • Like
  • 0

I have a workflow that kicks of when the stage changes to 'Closed Won' The issue is that the workflow doesn't get kicked of if a brand new opportunity gets created and immediated set to 'Closed Won' I'm trying to check to see if the StageName is ISBLANK, ISNULL, etc. But can't get the right combination. When the stage gets changed on when it was set to something works. Evaluation Criteria is set to 'Evaluate the rule when a record is created, and every time it’s edited' Here is what I've tried. Thanks for any help.

 

OR(
AND( NOT(ISPICKVAL(PRIORVALUE(StageName ), "Closed Won")), ISPICKVAL( StageName , "Closed Won") ), 
AND( ISNULL(PRIORVALUE(StageName)), ISPICKVAL( StageName , "Closed Won") ) 
)

 

OR(
AND( NOT(ISPICKVAL(PRIORVALUE(StageName ), "Closed Won")), ISPICKVAL( StageName , "Closed Won") ), 
AND( ISBLANK(PRIORVALUE(StageName)), ISPICKVAL( StageName , "Closed Won") ) 
)

 

OR( 
AND( NOT(ISPICKVAL(PRIORVALUE(StageName ), "Closed Won")), ISPICKVAL( StageName , "Closed Won") ), 
AND( ISPICKVAL(PRIORVALUE(StageName ), ""), ISPICKVAL( StageName , "Closed Won") ) 
)

 

  • December 24, 2012
  • Like
  • 0

Hi,

 

#issue 1: OpportunityTeamMember trigger only fired in some cases 

 

I need a trigger which will update numbers after opportunity team member is added or delete. However, I found in following case, the tirgger will not be fired

 

“Add Default Team” on Opportunity team related list in Opportunity view layout

“Add Account Team” on Opportunity team related list in Opportunity view layout

Delete an opporutinty, which will delete OpportunityTeamMember records also

Undelete an opporutinty, which will undelete OpportunityTeamMember records also

 

Any workaround for these cases?

 

#issue 1: How to get Personal setting

I tried to figure out a workround for “Add Default Team” through overwritting it. I tried to read opportunity owner's personal default opportunity team settings, and add them through apex. But how to retrieve Personal setting, like opportunity team settings, through apex. ?

 

Thanks

James

 

I've created a VF page to add multiple products based of http://bobbuzzard.blogspot.co.uk/2011/07/managing-list-of-new-records-in.html

 

Everything works execpt when I try to Save I get the error: common.apex.runtime.impl.ExecutionException: Invalid conversion from runtime type String to SOBJECT:Opportunity

 
But, I'm not assign the opportunity to anything and System.debug don't get trigger in the Save function. Any help will greatly appriciated! Thanks
 
<apex:page standardController="Product2" extensions="CustomProducts" tabStyle="Opportunity">
<apex:sectionHeader title="Custom Messaging Products" subtitle="{!oppSO.Name}"/>
<apex:form >
     <apex:inputHidden value="{!oppSO}"/>
    
      <apex:pageBlock title="New Message Tier Products">
          
          <apex:pageMessages />
              
          <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
                       <apex:column headerValue="Ident">
            <apex:outputText value="{!wrapper.ident}"/>
         </apex:column>
             <apex:column headerValue="Min">
                <apex:inputField value="{!wrapper.p.Min__c}"/>
             </apex:column>
             <apex:column headerValue="Max">
                <apex:inputField value="{!wrapper.p.Max__c}"/>
             </apex:column>
             <apex:column headerValue="Action">
                <apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable" immediate="true">
                   <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/> 
                </apex:commandButton>
             </apex:column>
          </apex:pageBlockTable>
          
          <apex:pageBlockButtons >
              <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable" immediate="true">
                  <apex:param name="addCount" value="1" assignTo="{!addCount}"/> 
              </apex:commandButton>
              <apex:commandButton value="Save" action="{!save}"/>
              <apex:commandButton value="Cancel" action="{!cancel}"/>
          </apex:pageBlockButtons>
      </apex:pageBlock>
      
    </apex:form>
</apex:page>

 

public class CustomProducts {
    
    public Opportunity oppSO {get;set;}
    public List<Product2WrapperCustomMsg> wrappers {get;set;}
    public static Integer toDelIdent {get; set;}
	public static Integer addCount {get; set;}
 	private Integer nextIdent;
        
    static final String STR_CUSTOM_LOOLKUP_PRE = 'SB-US-MSGCUSTOM';
    static final String STR_CUSTOM_LOOLKUP_POST = '-USAGE-MT';
    static final String LKP_QBFAMILY = '44100 · Sales Revenue - Standard Rate M';
        
    //
    // Contructor
    //
    public CustomProducts(ApexPages.StandardController controller) {
        String oppId = (String)Apexpages.currentPage().getParameters().get('oppid');
        this.oppSO = [Select Id, Name From Opportunity Where Id = :oppId];
        System.debug('@@@this.oppSO: ' + this.oppSO);
        
        wrappers = new List<Product2WrapperCustomMsg>();
        for (Integer idx = 0; idx < 4; idx++) 
        {
            if (nextIdent == null)
                nextIdent = this.GetNextIncrement();
            else
                nextIdent++;
            
            wrappers.add(new Product2WrapperCustomMsg(nextIdent));
            
        }

    }
    
    public Integer GetNextIncrement()
    {
        Integer currentMax = 0;
        for(Product2 p:[Select Id, Name, ProductCode from Product2 WHERE ProductCode LIKE :STR_CUSTOM_LOOLKUP_PRE + '%'])
        {	
            //SB-US-MSGCUSTOM1-USAGE-MT
            String tempCode = p.ProductCode.substring(STR_CUSTOM_LOOLKUP_PRE.length()); 
            tempCode = tempCode.substring(0, tempCode.indexOf('-')); 
            
            if (integer.valueof(tempCode) > currentMax )
                currentMax = integer.valueof(tempCode);
            
        } //for
        
        return currentMax + 1;
    } // GetNextIncrement
    
    public PageReference save()
    {
            System.debug('@@@ CustomProducts.save.wrappers : ' + wrappers );
        List<Product2> prds = new List<Product2>();
        for (Product2WrapperCustomMsg wrap : wrappers)
        {
            wrap.p.Name = GetProductName(wrap.p.Min__c, wrap.p.Max__c);
            prds.add(wrap.p);
            System.debug('@@@ CustomProducts.save.wrap.p : ' + wrap.p );
        }
        
        insert prds;
        
        return new PageReference('/006V0000002zPVi');
        
        //return new PageReference('/' + Schema.getGlobalDescribe().get('Opportunity').getDescribe().getKeyPrefix() + '/o');
    } // save
    
    public void delWrapper() {
        Integer toDelPos=-1;
        for (Integer idx=0; idx<wrappers.size(); idx++) {
            if (wrappers[idx].ident==toDelIdent) {
                toDelPos=idx;
            }
        }
        
        if (-1!=toDelPos) {
            wrappers.remove(toDelPos);
        }
    } // delWrapper
    
    public void addRows() {
        nextIdent = nextIdent + 1;
        wrappers.add(new Product2WrapperCustomMsg(nextIdent));
        System.debug('@@@ CustomProducts.addRows.wrappers: ' + wrappers);
    }
    
    // Format: Message Plan - Up to 100,000 Messages - Mobile Terminated (MT)
    // Format: Message Plan - 500,000-1,000,000 Messages - Mobile Terminated (MT)
    // Format: Message Plan - 1,000,000 and Above Messages - Mobile Terminated (MT)
    public String GetProductName(Decimal min, Decimal max)
    {
        String retString = '';
        
        if (min == 0 || min == 1) {
            retString = 'Message Plan - Up to ' + max + ' Messages - Mobile Terminated (MT)';
        }
        else if (max == 999999999) {
            retString = 'Message Plan - ' + min + ' and Above Messages - Mobile Terminated (MT)';
        }
        else {
            retString = 'Message Plan - ' + min + '-' + max + ' Messages - Mobile Terminated (MT)';
        }
        System.debug('@@@ Product2WrapperCustomMsg.GetProductName.retString : ' + retString );
        return retString ;
        
    } // GetProductName
    
    public class Product2WrapperCustomMsg
    {
        public Product2 p {get; private set;}
        public Integer ident {get; private set;}
       
        public Product2WrapperCustomMsg(Integer inIdent)
        {
			ident = inIdent;
            
            p = new Product2();
            //p.Name = CustomProducts.GetProductName(0, 999999999);
            p.ProductCode = STR_CUSTOM_LOOLKUP_PRE  + inIdent + STR_CUSTOM_LOOLKUP_POST;
            p.Min__c = 0;
            p.Max__c = 999999999;
            p.QB_Do_Sync__c = true;
            p.QB_AccountFamily__c = LKP_QBFAMILY;
            p.Message_Product_Id__c = inIdent;
            p.CanUseQuantitySchedule = true;
            p.Family = 'Message Plan Tiered';
        }
    } // Product2WrapperCustomMsg
}

 

  • December 16, 2012
  • Like
  • 0