• pdosta
  • NEWBIE
  • 0 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 15
    Replies

Can anyone give a suggestion on the below test.  When running the test, it does not return any rows and does not give me adequate coverage.

 

Controller

 

public class psuIdRequestController {
 private String requestid;
    public Participant_ID_Request__c participantmgr;
    public String strStatus;
    public User user;
    public Contact contactBusiness;
    public Contact contactTechnical;
    public Contact contactFinance;
    public Contact contactTreasury;
    public String comment;
    public String approver;
    public Date approvalDate;
    
    
    public psuIdRequestController(ApexPages.StandardController stdController) {
        requestid = ApexPages.currentPage().getparameters().get('requestid');

        //Fetch participant for Participant ID Request record.
        participantmgr = [select Id, Name, DCF_Approval_Due_Date__c,
                        Business_DCF_Approver__c, Technical_DCF_Approver__c, Finance_DCF_Approver__c, Treasury_DCF_Approver__c,
                        Business_DCF_Approval__c, Technical_DCF_Approval__c, Finance_DCF_Approval__c, Treasury_DCF_Approval__c,
                        Business_DCF_Approval_Date__c, Technical_DCF_Approval_Date__c, Finance_DCF_Approval_Date__c, Treasury_DCF_Approval_Date__c,
                        Business_DCF_Comments__c, Technical_DCF_Comments__c, Finance_DCF_Comments__c, Treasury_DCF_Comments__c      
                        from Participant_ID_Request__c where Id =:requestid limit 1];

     try{
        contactBusiness = [select Id, Name from Contact where Id =: participantmgr.Business_DCF_Approver__c limit 1];
        contactTechnical = [select Id, Name from Contact where Id =: participantmgr.Technical_DCF_Approver__c limit 1];
        contactFinance = [select Id, Name from Contact where Id =: participantmgr.Finance_DCF_Approver__c limit 1];
        contactTreasury = [select Id, Name from Contact where Id =: participantmgr.Treasury_DCF_Approver__c limit 1];
        
        }
    catch(QueryException e){
     // System.assert(false,'You must be assigned as an approver for this participant.');    
        
        }
    
    }
  
    public Participant_ID_Request__c getparticipant(){
        return participantmgr;
    }
    
    public void Approve(){
        setStatus('Approved');      
    }
    public void Reject(){
        setStatus('Rejected');
    }
    public String getUserName(){
        return UserInfo.getName();
    }
    public String getStatus(){ 
        if(UserInfo.getName() == contactBusiness.Name ){
                return participantmgr.Business_DCF_Approval__c;
            }
            else if (UserInfo.getName() == contactTechnical.Name ){
                return participantmgr.Technical_DCF_Approval__c;
            }
            else if (UserInfo.getName() == contactFinance.Name ){
                return participantmgr.Finance_DCF_Approval__c;
            }
            else if (participantmgr.Treasury_DCF_Approver__c <> Null ){
                if (UserInfo.getName() == contactTreasury.Name ){
                    return participantmgr.Treasury_DCF_Approval__c;
                }
            }
        return strStatus;
    }
    public void setStatus(String status){
    
        if(UserInfo.getName() == contactBusiness.Name ){
            participantmgr.Business_DCF_Approval__c = status;
            participantmgr.Business_DCF_Comments__c = comment;
            participantmgr.Business_DCF_Approval_Date__c = approvalDate;
            update participantmgr;
        }
        else if (UserInfo.getName() == contactTechnical.Name ){
            participantmgr.Technical_DCF_Approval__c = status;
            participantmgr.Technical_DCF_Comments__c = comment;
            participantmgr.Technical_DCF_Approval_Date__c = approvalDate;
            update participantmgr;
        }
        else if (UserInfo.getName() == contactFinance.Name ){
            participantmgr.Finance_DCF_Approval__c = status;
            participantmgr.Finance_DCF_Comments__c = comment;
            participantmgr.Finance_DCF_Approval_Date__c = approvalDate;
            update participantmgr;
        }
        else if (participantmgr.Treasury_DCF_Approver__c <> Null ){
            if (UserInfo.getName() == contactTreasury.Name ){
            participantmgr.Treasury_DCF_Approval__c = status;
            participantmgr.Treasury_DCF_Comments__c = comment;
            participantmgr.Treasury_DCF_Approval_Date__c = approvalDate;
            update participantmgr;
            }
        }
    }
            
    public String getParticipantName() {
        return participantmgr.Name;       
    }
    
    public String getComment(){
    
            if(UserInfo.getName() == contactBusiness.Name ){
                return participantmgr.Business_DCF_Comments__c ;
            }
            else if (UserInfo.getName() == contactTechnical.Name ){
                return participantmgr.Technical_DCF_Comments__c;
            }
            else if (UserInfo.getName() == contactFinance.Name ){
                return participantmgr.Finance_DCF_Comments__c;
            }
            else if (participantmgr.Treasury_DCF_Approver__c <> Null ){
                if (UserInfo.getName() == contactTreasury.Name ){
                    return participantmgr.Treasury_DCF_Comments__c;
                }
                else{
                    comment = '';
                    return comment; 
                }
            }
            else{
                comment = '';
                return comment; 
            }
    }
    
    public void setComment(String value){
        comment = value;        
    }
    
    public Date getapprovalDate(){
    
            if(UserInfo.getName() == contactBusiness.Name ){
                return participantmgr.Business_DCF_Approval_Date__c;
            }
            else if (UserInfo.getName() == contactTechnical.Name ){
                return participantmgr.Technical_DCF_Approval_Date__c;
            }
            else if (UserInfo.getName() == contactFinance.Name ){
                return participantmgr.Finance_DCF_Approval_Date__c;
            }
            else if (participantmgr.Treasury_DCF_Approver__c <> Null ){
                if (UserInfo.getName() == contactTreasury.Name ){
                    return participantmgr.Treasury_DCF_Approval_Date__c;
                }
                else{
                    approvalDate = null;
                    return approvalDate; 
                }
            }
            else{
                approvalDate = null;
                return approvalDate;
            } 
    }
    
    public String getApprover(){
            if(UserInfo.getName() == contactBusiness.Name ){
                return contactBusiness.Name;
            }
            else if (UserInfo.getName() == contactTechnical.Name ){
                return contactTechnical.Name;
            }
            else if (UserInfo.getName() == contactFinance.Name ){
                return contactFinance.Name;
            }
            else if (participantmgr.Treasury_DCF_Approver__c <> Null ){
                if (UserInfo.getName() == contactTreasury.Name ){
                    return contactTreasury.Name;
                }
                else{
                approver = 'Not Eligilble to approve';
                return approver; 
                }
            }
            else{
                approver = 'Not Eligilble to approve';
                return approver; 
            }
    }

}

 Test

 

    static testmethod void testPsuIdRequest()
    {
        User BusinessUser = [select id,name,ContactId from User where Profile.Name = 'PORTAL: GNS Technical Account Management' and IsActive = true limit 1];
        User TechnicalUser = [select id,name,ContactId from User where Profile.Name = 'PORTAL: GNS Partner Operations' and IsActive = true limit 1];
        User FinanceUser = [select id,name,ContactId from User where Profile.Name = 'PORTAL: GNS Finance' and IsActive = true limit 1];
        User InvalidUser = [select id,name,ContactId from User where Profile.Name = 'PORTAL: AMEX Treasury' and IsActive = true limit 1];

        System.RunAs(BusinessUser){        
        RecordType recreq = [select ID,Name from RecordType where Name = 'ID REQUEST: Draft Approved' and SObjectType = 'Participant_ID_Request__c'];
        Participant_ID_Request__c preq = new Participant_ID_Request__c(recordtypeid=recreq.Id,
        Name='Test Deal1'); 
        insert preq;
        

            ApexPages.PageReference testpage = Page.psudcfreview;
            ApexPages.StandardController con = new ApexPages.StandardController(preq);
            psuIdRequestController pnid = new psuIdRequestController(con);
            Test.setCurrentPage(testpage);
            ApexPages.currentPage().getParameters().get('requestid');
    
            pnid = new psuIdRequestController(con);
            pnid.comment = 'testing';
            pnid.approve();
            }
        }

 

 

 

  • November 30, 2010
  • Like
  • 0

I know there is work going on to fix this, but currently I cannot deploy any change sets and cannot deploy anything using the IDE because for some reason my test code coverage is not at least 75%.  Using the IDE I have tried to delete the MyProfilePageController() class, but it won't let me because my code coverage is not 75%....when I try to deploy amendments to my test classes to fix the coverage issue, it won't let me because of this class...additionally, when trying to get help from the HelpDesk we have gotten nowhere.  We need to deploy code for a new site but are currently stuck so ANY help with this would be much appreciated.

  • November 21, 2010
  • Like
  • 0

I need help with writing a test method for a class that creates opens a Visualforce page with predetermined parameters.  I have no idea where to begin if anyone can steer me in the right direction.

 

Here is the class...how do I write the method to test this?

 

 

public class psuNewCurrency
{
        private final Participant_ID_Request__c request;
        private final Participant_ID__c objParticipant_Id;
        public String Participant_ID;
        public String Participant_ID_id;
        public String Request_ID;
        public String Request_Name;
        public String Record_Type;
        
public psuNewCurrency(ApexPages.StandardController controller)
{
    this.objParticipant_Id=[select Id, Name, Participant_ID_Generation__c  from Participant_ID__c where Name=:System.CurrentPageReference().getParameters().get('CF00NS0000000O8dw')];
    Participant_ID = System.CurrentPageReference().getParameters().get('CF00NS0000000O8dw');
    Record_Type = System.CurrentPageReference().getParameters().get('RecordType');
    Participant_ID_id = objParticipant_Id.Id;
    Request_ID = objParticipant_Id.Participant_ID_Generation__c;
    this.request=[select Id, Name  from Participant_ID_Request__c where Id= :Request_ID ];
    Request_Name = request.Name; 
    
}
public Pagereference pageredir()
{
    
        Pagereference newpage = new Pagereference ('/a0O/e?CF00NS0000000O8dw='+ Participant_ID 
                    +'&CF00NS0000000O8dw_lkid='+ Participant_ID_id 
                    +'&CF00NS0000000OAKq_lkid='+ Request_ID
                    +'&CF00NS0000000OAKq='+ Request_Name 
                    +'&retURL='+ Participant_ID_id
                    +'&RecordType='+ Record_Type
                    +'&_CONFIRMATIONTOKEN=fzXMPMYOtRvbVHrmy6.3rdbroMrAH.pxVXb2iB71kL.oPdjgcmNKyWCeyGwgB68fQ7wBH_Zv5wDZyDMNz1NAt562.Ll8FVIhhjSmAuY6c9d8a2SLLWoZlctxQxROV.l7RHe32ME9Xr9XLz2y3aX7UmhlCYEe4RPZiluYf979pzFIyH3l' 
                    +'&cancelURL='+ Participant_ID_id
                    +'&ent=01IS00000008Xhj' //Currency Relationship Object
                    +'&nooverride=1');
    return newpage;
 
}
}

 

 

I have a need to create a Picklist based on a Custom Object, then based on the selection in the Picklist, update a Lookup Relationship field (Lookup__c).  I have the Picklist code and the Visualforce page, but I cannot figure out how to update the Lookup field.  The requirement is to update the Lookup field with the Id of the selection of the Picklist.  Below are my code, can anyone help?

 

Class

 

public class enrollSave{
    
    String mpi;

    public String getCoa() { return this.mpi; }

    public void setCoa(String s) { this.mpi = s; }
    
        public List<SelectOption> getCoas() {
          List<SelectOption> optionList = new List<SelectOption>();
          optionList.add(new SelectOption('','- None -'));
        
          for (Custom_Object_A__c coa : [SELECT Name FROM Custom_Object_A__c ORDER BY Name]){
            optionList.add(new SelectOption(coa.id,coa.Name));
          }
          return optionList;     
        }
    
    ApexPages.StandardController controller;
    public enrollSave(ApexPages.StandardController con){
        controller = con;
    }            
 
    public PageReference save() {
        controller.save();
        return page.aeskenrollconfirm;
    }
}

 Visualforce

 

<apex:page showHeader="false" standardController="Custom_Object_A__c" extensions="enrollSave" standardStylesheets="false">
        <apex:form >
            <apex:pageBlock >
                    <apex:pageblockSectionItem >
                        <apex:outputLabel value="Select Option" for="options"/>
                            <apex:selectList value="{!coa}" size="1" id="options">
                            <apex:selectOptions value="{!coas}"/>
                            </apex:selectList>
                    </apex:pageblockSectionItem>
                    <apex:pageblockSectionItem >
                            <apex:inputField value="{!Lookup__c}" size="1" id="relationship" rendered="false">
                    </apex:pageblockSectionItem>
                </apex:pageBlockSection>
            <apex:pageblockButtons location="bottom">
                <apex:commandButton action="{!Save}" value="Submit Enrollment" />
            </apex:pageblockButtons>
            </apex:pageBlock>
        </apex:form>
</apex:page>

 

 

 

When I try to allow a public site a Rich Text field to render on a Visualforce page, it does not allow for the image upload capability.  Is there a way to allow for this?

I have searched all over and cannot find any advice on creating a record with an attachment in the same Visualforce page.  Has nayone posted anything for this?

  • April 30, 2010
  • Like
  • 0

Hello,

I need help with a trigger.  I am trying to assign the correct Id on a Lookup Field based on querying for a corresponding value on the related Custom Object.  Here is my trigger, but all I get is "Expression cannot be assigned at line -1 column -1".  Help would be greatly appreciated!

 

 

trigger objectConnect on Custom_Object_B__c (after insert) {

    Map<String, Custom_Object_B__c> cobMap = new Map<String, Custom_Object_B__c>();

    for (Custom_Object_B__c cob : System.Trigger.new) {
        if (cob.ID_Field__c == null) {
            cob.ID_Field__c.addError('A valid ID is required.');
        } 
        else {
            skcMap.put(cob.ID_Field__c, cob);
            }
    }

    for (Custom_Object_A__c coa : [SELECT Id, ID_Field__c FROM Custom_Object_A__c WHERE SKID__c IN :cobMap.KeySet()]) {
            Custom_Object_B__c.Look_Up_Field__c = coa.Id;
    }
}

 Anyone know what my problem is?  I have searched on the error, but have not found anyone with that same error.

 

  • April 30, 2010
  • Like
  • 0

When I try to display a Rich Text Field on a Visualforce Page on a Public Site, it does not show.  How can I get it to show?

  • April 29, 2010
  • Like
  • 0

Hello I am trying to use an Apex trigger to create Sharing on a custome object with a Customer Portal User referenced on the object.  Unfortunately I can only get to the Contact ID, but I want to retrieve the Contact's Customer Portal User ID, can anyone help?  Here is my code currently:

 

trigger BusinessApexShare on Participant_ID_Request__c (before update) { if(trigger.isUpdate) { List<Participant_ID_Request__Share> pidshr = new List<Participant_ID_Request__Share>(); Participant_ID_Request__Share bshr; for(Participant_ID_Request__c pid : trigger.new) { bshr = new Participant_ID_Request__Share(); bshr.ParentId = pid.Id; bshr.UserOrGroupId = pid.Business_Approver__c; bshr.AccessLevel = 'edit'; bshr.RowCause = Schema.Participant_ID_Request__Share.RowCause.ID_REQUEST_Business_Share__c; pidshr.add(bshr); } Database.SaveResult[] lsr = Database.insert(pidshr,false); Integer i=0; for(Database.SaveResult sr : lsr){ if(!sr.isSuccess()){ Database.Error err = sr.getErrors()[0]; if(!(err.getStatusCode() == StatusCode.FIELD_INTEGRITY_EXCEPTION && err.getMessage().contains('AccessLevel'))){ trigger.newMap.get(pidshr[i].ParentId). addError('Unable to grant sharing access due to the following exception: ' + err.getMessage()); } }i++; } } }

 When I try to save the record, I get the following error: "User/Group ID: id value of incorrect type"

 

 

  • February 10, 2010
  • Like
  • 0
I have a need to query on the relationship between Customer Portal Profiles and the Portals available to those Profiles...is there a way to query for this from the API?
  • August 07, 2009
  • Like
  • 0

Can anyone give a suggestion on the below test.  When running the test, it does not return any rows and does not give me adequate coverage.

 

Controller

 

public class psuIdRequestController {
 private String requestid;
    public Participant_ID_Request__c participantmgr;
    public String strStatus;
    public User user;
    public Contact contactBusiness;
    public Contact contactTechnical;
    public Contact contactFinance;
    public Contact contactTreasury;
    public String comment;
    public String approver;
    public Date approvalDate;
    
    
    public psuIdRequestController(ApexPages.StandardController stdController) {
        requestid = ApexPages.currentPage().getparameters().get('requestid');

        //Fetch participant for Participant ID Request record.
        participantmgr = [select Id, Name, DCF_Approval_Due_Date__c,
                        Business_DCF_Approver__c, Technical_DCF_Approver__c, Finance_DCF_Approver__c, Treasury_DCF_Approver__c,
                        Business_DCF_Approval__c, Technical_DCF_Approval__c, Finance_DCF_Approval__c, Treasury_DCF_Approval__c,
                        Business_DCF_Approval_Date__c, Technical_DCF_Approval_Date__c, Finance_DCF_Approval_Date__c, Treasury_DCF_Approval_Date__c,
                        Business_DCF_Comments__c, Technical_DCF_Comments__c, Finance_DCF_Comments__c, Treasury_DCF_Comments__c      
                        from Participant_ID_Request__c where Id =:requestid limit 1];

     try{
        contactBusiness = [select Id, Name from Contact where Id =: participantmgr.Business_DCF_Approver__c limit 1];
        contactTechnical = [select Id, Name from Contact where Id =: participantmgr.Technical_DCF_Approver__c limit 1];
        contactFinance = [select Id, Name from Contact where Id =: participantmgr.Finance_DCF_Approver__c limit 1];
        contactTreasury = [select Id, Name from Contact where Id =: participantmgr.Treasury_DCF_Approver__c limit 1];
        
        }
    catch(QueryException e){
     // System.assert(false,'You must be assigned as an approver for this participant.');    
        
        }
    
    }
  
    public Participant_ID_Request__c getparticipant(){
        return participantmgr;
    }
    
    public void Approve(){
        setStatus('Approved');      
    }
    public void Reject(){
        setStatus('Rejected');
    }
    public String getUserName(){
        return UserInfo.getName();
    }
    public String getStatus(){ 
        if(UserInfo.getName() == contactBusiness.Name ){
                return participantmgr.Business_DCF_Approval__c;
            }
            else if (UserInfo.getName() == contactTechnical.Name ){
                return participantmgr.Technical_DCF_Approval__c;
            }
            else if (UserInfo.getName() == contactFinance.Name ){
                return participantmgr.Finance_DCF_Approval__c;
            }
            else if (participantmgr.Treasury_DCF_Approver__c <> Null ){
                if (UserInfo.getName() == contactTreasury.Name ){
                    return participantmgr.Treasury_DCF_Approval__c;
                }
            }
        return strStatus;
    }
    public void setStatus(String status){
    
        if(UserInfo.getName() == contactBusiness.Name ){
            participantmgr.Business_DCF_Approval__c = status;
            participantmgr.Business_DCF_Comments__c = comment;
            participantmgr.Business_DCF_Approval_Date__c = approvalDate;
            update participantmgr;
        }
        else if (UserInfo.getName() == contactTechnical.Name ){
            participantmgr.Technical_DCF_Approval__c = status;
            participantmgr.Technical_DCF_Comments__c = comment;
            participantmgr.Technical_DCF_Approval_Date__c = approvalDate;
            update participantmgr;
        }
        else if (UserInfo.getName() == contactFinance.Name ){
            participantmgr.Finance_DCF_Approval__c = status;
            participantmgr.Finance_DCF_Comments__c = comment;
            participantmgr.Finance_DCF_Approval_Date__c = approvalDate;
            update participantmgr;
        }
        else if (participantmgr.Treasury_DCF_Approver__c <> Null ){
            if (UserInfo.getName() == contactTreasury.Name ){
            participantmgr.Treasury_DCF_Approval__c = status;
            participantmgr.Treasury_DCF_Comments__c = comment;
            participantmgr.Treasury_DCF_Approval_Date__c = approvalDate;
            update participantmgr;
            }
        }
    }
            
    public String getParticipantName() {
        return participantmgr.Name;       
    }
    
    public String getComment(){
    
            if(UserInfo.getName() == contactBusiness.Name ){
                return participantmgr.Business_DCF_Comments__c ;
            }
            else if (UserInfo.getName() == contactTechnical.Name ){
                return participantmgr.Technical_DCF_Comments__c;
            }
            else if (UserInfo.getName() == contactFinance.Name ){
                return participantmgr.Finance_DCF_Comments__c;
            }
            else if (participantmgr.Treasury_DCF_Approver__c <> Null ){
                if (UserInfo.getName() == contactTreasury.Name ){
                    return participantmgr.Treasury_DCF_Comments__c;
                }
                else{
                    comment = '';
                    return comment; 
                }
            }
            else{
                comment = '';
                return comment; 
            }
    }
    
    public void setComment(String value){
        comment = value;        
    }
    
    public Date getapprovalDate(){
    
            if(UserInfo.getName() == contactBusiness.Name ){
                return participantmgr.Business_DCF_Approval_Date__c;
            }
            else if (UserInfo.getName() == contactTechnical.Name ){
                return participantmgr.Technical_DCF_Approval_Date__c;
            }
            else if (UserInfo.getName() == contactFinance.Name ){
                return participantmgr.Finance_DCF_Approval_Date__c;
            }
            else if (participantmgr.Treasury_DCF_Approver__c <> Null ){
                if (UserInfo.getName() == contactTreasury.Name ){
                    return participantmgr.Treasury_DCF_Approval_Date__c;
                }
                else{
                    approvalDate = null;
                    return approvalDate; 
                }
            }
            else{
                approvalDate = null;
                return approvalDate;
            } 
    }
    
    public String getApprover(){
            if(UserInfo.getName() == contactBusiness.Name ){
                return contactBusiness.Name;
            }
            else if (UserInfo.getName() == contactTechnical.Name ){
                return contactTechnical.Name;
            }
            else if (UserInfo.getName() == contactFinance.Name ){
                return contactFinance.Name;
            }
            else if (participantmgr.Treasury_DCF_Approver__c <> Null ){
                if (UserInfo.getName() == contactTreasury.Name ){
                    return contactTreasury.Name;
                }
                else{
                approver = 'Not Eligilble to approve';
                return approver; 
                }
            }
            else{
                approver = 'Not Eligilble to approve';
                return approver; 
            }
    }

}

 Test

 

    static testmethod void testPsuIdRequest()
    {
        User BusinessUser = [select id,name,ContactId from User where Profile.Name = 'PORTAL: GNS Technical Account Management' and IsActive = true limit 1];
        User TechnicalUser = [select id,name,ContactId from User where Profile.Name = 'PORTAL: GNS Partner Operations' and IsActive = true limit 1];
        User FinanceUser = [select id,name,ContactId from User where Profile.Name = 'PORTAL: GNS Finance' and IsActive = true limit 1];
        User InvalidUser = [select id,name,ContactId from User where Profile.Name = 'PORTAL: AMEX Treasury' and IsActive = true limit 1];

        System.RunAs(BusinessUser){        
        RecordType recreq = [select ID,Name from RecordType where Name = 'ID REQUEST: Draft Approved' and SObjectType = 'Participant_ID_Request__c'];
        Participant_ID_Request__c preq = new Participant_ID_Request__c(recordtypeid=recreq.Id,
        Name='Test Deal1'); 
        insert preq;
        

            ApexPages.PageReference testpage = Page.psudcfreview;
            ApexPages.StandardController con = new ApexPages.StandardController(preq);
            psuIdRequestController pnid = new psuIdRequestController(con);
            Test.setCurrentPage(testpage);
            ApexPages.currentPage().getParameters().get('requestid');
    
            pnid = new psuIdRequestController(con);
            pnid.comment = 'testing';
            pnid.approve();
            }
        }

 

 

 

  • November 30, 2010
  • Like
  • 0

I know there is work going on to fix this, but currently I cannot deploy any change sets and cannot deploy anything using the IDE because for some reason my test code coverage is not at least 75%.  Using the IDE I have tried to delete the MyProfilePageController() class, but it won't let me because my code coverage is not 75%....when I try to deploy amendments to my test classes to fix the coverage issue, it won't let me because of this class...additionally, when trying to get help from the HelpDesk we have gotten nowhere.  We need to deploy code for a new site but are currently stuck so ANY help with this would be much appreciated.

  • November 21, 2010
  • Like
  • 0

I need help with writing a test method for a class that creates opens a Visualforce page with predetermined parameters.  I have no idea where to begin if anyone can steer me in the right direction.

 

Here is the class...how do I write the method to test this?

 

 

public class psuNewCurrency
{
        private final Participant_ID_Request__c request;
        private final Participant_ID__c objParticipant_Id;
        public String Participant_ID;
        public String Participant_ID_id;
        public String Request_ID;
        public String Request_Name;
        public String Record_Type;
        
public psuNewCurrency(ApexPages.StandardController controller)
{
    this.objParticipant_Id=[select Id, Name, Participant_ID_Generation__c  from Participant_ID__c where Name=:System.CurrentPageReference().getParameters().get('CF00NS0000000O8dw')];
    Participant_ID = System.CurrentPageReference().getParameters().get('CF00NS0000000O8dw');
    Record_Type = System.CurrentPageReference().getParameters().get('RecordType');
    Participant_ID_id = objParticipant_Id.Id;
    Request_ID = objParticipant_Id.Participant_ID_Generation__c;
    this.request=[select Id, Name  from Participant_ID_Request__c where Id= :Request_ID ];
    Request_Name = request.Name; 
    
}
public Pagereference pageredir()
{
    
        Pagereference newpage = new Pagereference ('/a0O/e?CF00NS0000000O8dw='+ Participant_ID 
                    +'&CF00NS0000000O8dw_lkid='+ Participant_ID_id 
                    +'&CF00NS0000000OAKq_lkid='+ Request_ID
                    +'&CF00NS0000000OAKq='+ Request_Name 
                    +'&retURL='+ Participant_ID_id
                    +'&RecordType='+ Record_Type
                    +'&_CONFIRMATIONTOKEN=fzXMPMYOtRvbVHrmy6.3rdbroMrAH.pxVXb2iB71kL.oPdjgcmNKyWCeyGwgB68fQ7wBH_Zv5wDZyDMNz1NAt562.Ll8FVIhhjSmAuY6c9d8a2SLLWoZlctxQxROV.l7RHe32ME9Xr9XLz2y3aX7UmhlCYEe4RPZiluYf979pzFIyH3l' 
                    +'&cancelURL='+ Participant_ID_id
                    +'&ent=01IS00000008Xhj' //Currency Relationship Object
                    +'&nooverride=1');
    return newpage;
 
}
}

 

 

I have a need to create a Picklist based on a Custom Object, then based on the selection in the Picklist, update a Lookup Relationship field (Lookup__c).  I have the Picklist code and the Visualforce page, but I cannot figure out how to update the Lookup field.  The requirement is to update the Lookup field with the Id of the selection of the Picklist.  Below are my code, can anyone help?

 

Class

 

public class enrollSave{
    
    String mpi;

    public String getCoa() { return this.mpi; }

    public void setCoa(String s) { this.mpi = s; }
    
        public List<SelectOption> getCoas() {
          List<SelectOption> optionList = new List<SelectOption>();
          optionList.add(new SelectOption('','- None -'));
        
          for (Custom_Object_A__c coa : [SELECT Name FROM Custom_Object_A__c ORDER BY Name]){
            optionList.add(new SelectOption(coa.id,coa.Name));
          }
          return optionList;     
        }
    
    ApexPages.StandardController controller;
    public enrollSave(ApexPages.StandardController con){
        controller = con;
    }            
 
    public PageReference save() {
        controller.save();
        return page.aeskenrollconfirm;
    }
}

 Visualforce

 

<apex:page showHeader="false" standardController="Custom_Object_A__c" extensions="enrollSave" standardStylesheets="false">
        <apex:form >
            <apex:pageBlock >
                    <apex:pageblockSectionItem >
                        <apex:outputLabel value="Select Option" for="options"/>
                            <apex:selectList value="{!coa}" size="1" id="options">
                            <apex:selectOptions value="{!coas}"/>
                            </apex:selectList>
                    </apex:pageblockSectionItem>
                    <apex:pageblockSectionItem >
                            <apex:inputField value="{!Lookup__c}" size="1" id="relationship" rendered="false">
                    </apex:pageblockSectionItem>
                </apex:pageBlockSection>
            <apex:pageblockButtons location="bottom">
                <apex:commandButton action="{!Save}" value="Submit Enrollment" />
            </apex:pageblockButtons>
            </apex:pageBlock>
        </apex:form>
</apex:page>

 

 

 

Hello,

I need help with a trigger.  I am trying to assign the correct Id on a Lookup Field based on querying for a corresponding value on the related Custom Object.  Here is my trigger, but all I get is "Expression cannot be assigned at line -1 column -1".  Help would be greatly appreciated!

 

 

trigger objectConnect on Custom_Object_B__c (after insert) {

    Map<String, Custom_Object_B__c> cobMap = new Map<String, Custom_Object_B__c>();

    for (Custom_Object_B__c cob : System.Trigger.new) {
        if (cob.ID_Field__c == null) {
            cob.ID_Field__c.addError('A valid ID is required.');
        } 
        else {
            skcMap.put(cob.ID_Field__c, cob);
            }
    }

    for (Custom_Object_A__c coa : [SELECT Id, ID_Field__c FROM Custom_Object_A__c WHERE SKID__c IN :cobMap.KeySet()]) {
            Custom_Object_B__c.Look_Up_Field__c = coa.Id;
    }
}

 Anyone know what my problem is?  I have searched on the error, but have not found anyone with that same error.

 

  • April 30, 2010
  • Like
  • 0

When I try to display a Rich Text Field on a Visualforce Page on a Public Site, it does not show.  How can I get it to show?

  • April 29, 2010
  • Like
  • 0
Hi everyone -

I'm trying to use the example of a VisualForce Email Template on Accounts with related Cases to create an email for one custom object and its related list items.  Referencing the first object is straightforward, but I haven't been able to figure out how to reference the related list.

Code:
<messaging:emailTemplate subject="A foo is required for this case; Do not reply to this email." recipientType="User" relatedToType="foo__c">
<messaging:plainTextEmailBody >

   Case/foo Number: {!relatedTo.Case_Number__c}
   Subject: {!relatedTo.Subject__c}
   ...
   // Here's where the trouble occurs, where foo_item__c is an individual
   // item in a related list
   <apex:repeat var="cx" value="{!relatedTo.foo_Line_Item}">
       {!cx.Detail_Number__c} - {!cx.Replacement_Component__c}
   </apex:repeat>

   // whether I use foo_Line_Item__c, foo_Line_Items, foo_Line_Item__cs - nothing seems to apply


Looking at the schema, the foo__c child object name is foo_Line_Item__c.

Thoughts?
 

I've gotten the Sforce Explorer and it works just fine from my home. We use a proxy server at work. I know the syntax for the proxy when using DataJunction but I don't know what I need to put in as the Client Id in options page. For DataJunction its dominnNamea\username:password.

A second question, I'm looking for more documentation for the Explorer also. I did a quick look in the source code but didn't see any. I'm most likely just not looking in the right place.

Thanks