• Hussey
  • NEWBIE
  • 50 Points
  • Member since 2012

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 11
    Replies

Hi,

 

I have a problem about visual force table tag.

I use <apex:datatable> in my visualforce page, and I set a dynamic data set for this table. But now I want to set a fixed value at the first row in this table ,then display other dynamic data.

 

Does anyone know how to achieve this?

 

Thank you!

So, what I'd like to do in my controller is query the current user id, pull the related contactid from that user, and display all Applications related to that Contact ID. (is there an easier way to do this?) Here is my code, but it doesn't seem to be working:

 

public class CurrentApps {
String userid = UserInfo.getUserId();
User firstuser;
    public List<User> getCurrentUser(){
        //Declare a new list
        List<User> CurrentUser = new List<User>();
        //Set the list equal to the results of the SOQL query
        CurrentUser = 
            [SELECT 
                FirstName, LastName, ContactId
            FROM User 
            WHERE Id =:userid ];
firstuser = CurrentUser.get(0);
        //Return the List
        return CurrentUser;
    }
    public List<Application__c> getUserApps(){
        //Declare a new list
        List<Application__c> UserApps = new List<Application__c>();
        //Set the list equal to the results of the SOQL query
        UserApps = 
            [SELECT 
                Name
            FROM Application__c 
            WHERE Contact__c =:firstuser.ContactId ];
        //Return the List
        return UserApps;
}
}

 

Dear Friends,

I have completed 11 Badges and I received two emails one with subject 'High five! Your t-shirt is on its way.' and another with subject 'Confirm your mailing address to receive your Trailhead t-shirt'. When I try to confirm my address the given link navigating to pardot account.But I don't have pardot account.Please help me...

Thanks,
Hussey
  • February 26, 2015
  • Like
  • 0

Actually i want to check whether if a field is of lookup type and do something if yes.

 

i tried the following 

 

String ltype='Lead';

Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Schema.SObjectType leadSchema = schemaMap.get(ltype);

Map<String, Schema.SObjectField> lfieldMap = leadSchema.getDescribe().fields.getMap();

for (String fieldName: lfieldMap.keySet()) {

//It provides to get the object fields label.
String lfieldLabel = lfieldMap.get(fieldName).getDescribe().getLabel();

//It provides to get the object fields data type.
Schema.DisplayType lfielddataType = lfieldMap.get(fieldName).getDescribe().getType();

if(lfielddataType==Schema.DisplayType.ID)
system.debug(':::::::::::lfieldType'+lfielddataType);
system.debug(':::::::::::::::+lfieldLabel'+lfieldLabel);

}

 

but is displaying all types 

 

any suggestions

  • December 14, 2012
  • Like
  • 0

Hi,

 

I have a problem about visual force table tag.

I use <apex:datatable> in my visualforce page, and I set a dynamic data set for this table. But now I want to set a fixed value at the first row in this table ,then display other dynamic data.

 

Does anyone know how to achieve this?

 

Thank you!

So, what I'd like to do in my controller is query the current user id, pull the related contactid from that user, and display all Applications related to that Contact ID. (is there an easier way to do this?) Here is my code, but it doesn't seem to be working:

 

public class CurrentApps {
String userid = UserInfo.getUserId();
User firstuser;
    public List<User> getCurrentUser(){
        //Declare a new list
        List<User> CurrentUser = new List<User>();
        //Set the list equal to the results of the SOQL query
        CurrentUser = 
            [SELECT 
                FirstName, LastName, ContactId
            FROM User 
            WHERE Id =:userid ];
firstuser = CurrentUser.get(0);
        //Return the List
        return CurrentUser;
    }
    public List<Application__c> getUserApps(){
        //Declare a new list
        List<Application__c> UserApps = new List<Application__c>();
        //Set the list equal to the results of the SOQL query
        UserApps = 
            [SELECT 
                Name
            FROM Application__c 
            WHERE Contact__c =:firstuser.ContactId ];
        //Return the List
        return UserApps;
}
}

 

Hi All,

 

I am new to testclasses i dont know how to write test classes Properly ...but i am tried but i am geting 63% code coverage only.. but i need atleast 90% can any one help this please ??

 

Here is my class

 

public with sharing class CallController{

    public Boolean callDetailsFlag{set;get;}
    public Boolean editFlag{set;get;}
    public Account account{set;get;}
    public CallDetail__c callDetail{set;get;}
    public String recordTypeName{set;get;}
    public String action{set;get;}
    public Boolean planEditFlag{set;get;}
    public List<WrapperClass> productList{get;set;}
    private ApexPages.StandardController stdController;
    private Call__c call;
    private String retURL;
    private String accId;
    private String callId;
    private String recordTypeId;
    private String oldProductsChoosen;
    public String selectedProduct{set;get;}
        
    public CallController(ApexPages.StandardController stdController){
        
        system.debug('--- CallController :: CallController() ---');
        this.call = (Call__c)stdController.getRecord();
        accId = ApexPages.currentPage().getParameters().get('accID');//from Account Detail Page
        retURL = ApexPages.currentPage().getParameters().get('retURL');//from overriden standard buttons
        callId = ApexPages.currentPage().getParameters().get('callId');// from Capture Call Details button
        String details = ApexPages.currentPage().getParameters().get('details');// from Capture Call Details button
        recordTypeId = ApexPages.currentPage().getParameters().get('RecordType');// from standard Record Type selection page
        
        if(accId != null)
            account = [select Id, Name from Account where ID=:accId];
            
        if(this.call != null && this.call.Id != null){
            callId = this.call.Id;
            action = 'Update';
        }else
            action = 'Insert';
        
        if(callId != null){
            call = [select Id, Name, Activity_Type__c, Attendee1__c, Attendee2__c, Attendee3__c, RecordTypeId,  
                        Call_Activity__c, Call_Date__c, Start_Time__c, End_Time__c, Call_Feedback__c,
                         Competitor_Product_Feedback__c,Competitor_Products__c, Joint_Field_Work__c, 
                        Next_Call_Objective__c, Next_Call_Objective_Date__c, No_of_Set__c, Number_of_Attendees__c, 
                        Topic__c, Type_of_Procedure__c, Workshop_Type__c, Products_Choosen__c, 
                        Account__c,Remarks__c from Call__c where Id=:callId];
            recordTypeId = call.RecordTypeId;
            oldProductsChoosen = call.Products_Choosen__c;
            if(call.Products_Choosen__c != null){
                if(productList == null)
                    productList = new List<WrapperClass>();
                for(String s : call.Products_Choosen__c.split(';')){
                    WrapperClass wrapper = new WrapperClass(s,false);
                    productList.add(wrapper);
                }
            }
         }
        
        if(details != null && details=='1'){
            callDetailsFlag = true;
            callDetail = getCallDetail();
        }
        else
            callDetailsFlag = false;
            
        if(recordTypeId != null){
            RecordType callRecordType = [SELECT Id, Name, DeveloperName, SobjectType, IsActive FROM RecordType 
                    where SobjectType='Call__c' and IsActive=true and Id= :recordTypeId limit 1];
            if(callRecordType != null){
                recordTypeName = callRecordType.Name;
            }
        }
                
        DateTime callDate = null;
        if(call != null && call.Start_Time__c != null)
            callDate = call.Start_Time__c;
        if(callDate != null){
            Long difference = callDate.addDays(5).getTime()-system.now().getTime();            
            if(difference<=0){
                editFlag = false;
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, Label.Call_Edit_Error));
            }
            else
                editFlag = true;            
        }else{
            editFlag = true;
            planEditFlag = true;
        }
        
        if(editFlag && !callDetailsFlag && callDate != null){
            Long difference1 = callDate.getTime()-system.now().getTime();
            if(difference1<=0){
                planEditFlag = false;
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, Label.Call_Plan_Edit_Error));                
            }
            else
                planEditFlag = true;
        }
        
        if(productList == null)
            productList = new List<WrapperClass>();
            
        system.debug('--- CallController :: CallController() :: editFlag --- '+editFlag);
        system.debug('--- CallController :: CallController() :: callDetailsFlag --- '+callDetailsFlag);
        system.debug('--- CallController :: CallController() :: recordTypeName --- '+recordTypeName);
        system.debug('--- CallController :: CallController() :: action --- '+action);
        system.debug('--- CallController :: CallController() :: planEditFlag --- '+planEditFlag);
    }
    
    public List<SelectOption> getUserProducts(){
    
        system.debug('--- CallController :: getUserProducts() ---');        
        List<MyProduct__Share> userProdShareList = [select Id, Parent.Id, Parent.Name, Parent.Active__c from MyProduct__Share 
                                                    where UserOrGroupId=:UserInfo.getUserId() and Parent.Active__c=true];
        List<SelectOption> options = new List<SelectOption>();           
        options.add(new SelectOption('','--Select--'));         
        for(MyProduct__Share tempShare : userProdShareList){
            options.add(new SelectOption(tempShare.Parent.Name,tempShare.Parent.Name));            
        }        
        return options;    
    }
    
    public PageReference saveDetails(){
    
        system.debug('--- CallController :: saveDetails() ---');
        if(call != null){
            if(recordTypeId != null)
                call.RecordTypeId = recordTypeId;
            else{
                RecordType callRecordType = [SELECT Id, Name, DeveloperName, SobjectType, IsActive FROM RecordType 
                    where SobjectType='Call__c' and IsActive=true and Name= :call.Activity_Type__c limit 1];
                call.RecordTypeId =  callRecordType.Id;
            }
            String productsChoosen = '';//call.Products_Choosen__c;
            for(Integer i=0; i<productList.size(); i++){
                if(i != (productList.size()-1))
                    productsChoosen = productsChoosen+productList.get(i).product+';';
                else
                    productsChoosen = productsChoosen+productList.get(i).product;
            }
            call.Products_Choosen__c = productsChoosen;
            insert call;
            system.debug('--- CallController :: saveDetails() :: call.Id---'+call.Id);
            if(call.Id != null){
                if(productsChoosen != null){ 
                    //productsChoosen = productsChoosen.trim(); 
                    //productsChoosen = productsChoosen.replaceAll('/\r\n|\r|\n/g',';');
                    //productsChoosen = productsChoosen.replaceAll('\n',';');
                    system.debug('--- tempList ---'+productsChoosen);        
                    //List<String> tempList = productsChoosen.split(';;');
                    List<String> tempList = productsChoosen.split(';');
                    //system.debug('--- tempList ---'+tempList);
                    Map<String,ID> productMap = new Map<String,ID>();
                    List<CallDetail__c> callDetailList = new List<CallDetail__c>();
                    for(MyProduct__c tempProduct : [select Id, Name, Active__c from MyProduct__c where Name in :tempList]){
                        if(tempProduct.Active__c)
                            productMap.put(tempProduct.Name,tempProduct.Id);
                    }
                    system.debug('--- productMap ---'+productMap);
                    if(productMap != null && productMap.size()>0){
                        for(String s : tempList){
                            if(productMap.get(s) != null){
                                CallDetail__c callDetail = new CallDetail__c();
                                callDetail.Call__c = call.Id;
                                callDetail.Product__c = productMap.get(s);
                                callDetailList.add(callDetail);
                            }
                        }
                    }
                    if(callDetailList != null && callDetailList.size()>0)
                        insert callDetailList;
                }
                PageReference pageRef = new PageReference('/'+call.Id);
                return pageRef;
            }            
        }
        return null;
    }
    
    public PageReference updateDetails(){
    
        system.debug('--- CallController :: updateDetails() ---');
        if(call != null){
            String productsChoosen = '';//call.Products_Choosen__c;
            for(Integer i=0; i<productList.size(); i++){
                if(i != (productList.size()-1))
                    productsChoosen = productsChoosen+productList.get(i).product+';';
                else
                    productsChoosen = productsChoosen+productList.get(i).product;
            }
            call.Products_Choosen__c = productsChoosen;
            update call;
            system.debug('--- CallController :: updateDetails() :: oldProductsChoosen ---'+oldProductsChoosen);
            system.debug('--- CallController :: updateDetails() :: Products_Choosen__c ---'+call.Products_Choosen__c);
            system.debug('--- CallController :: updateDetails() ---');
            if(oldProductsChoosen == call.Products_Choosen__c){
                system.debug('--- CallController :: updateDetails :: No Modifications to Products ---');
            }else{
                system.debug('--- CallController :: updateDetails :: Products Modified ---');
                // delete all previous product-call association records
                List<CallDetail__c> toDeleteList = [select Id, Name from CallDetail__c where Call__c= :call.Id];
                if(toDeleteList != null && toDeleteList.size()>0)
                    delete toDeleteList;
                // Add modified product-call association records
                if(productsChoosen != null){                    
                    //productsChoosen = productsChoosen.trim(); 
                    //productsChoosen = productsChoosen.replaceAll('/\r\n|\r|\n/g',';');
                    //productsChoosen = productsChoosen.replaceAll('\n',';');
                    //system.debug('--- tempList ---'+productsChoosen);        
                    //List<String> tempList = productsChoosen.split(';;');
                    List<String> tempList = productsChoosen.split(';');
                    system.debug('--- tempList ---'+tempList);
                    Map<String,ID> productMap = new Map<String,ID>();
                    List<CallDetail__c> callDetailList = new List<CallDetail__c>();
                    for(MyProduct__c tempProduct : [select Id, Name, Active__c from MyProduct__c where Name in :tempList]){
                        if(tempProduct.Active__c)
                            productMap.put(tempProduct.Name,tempProduct.Id);
                    }
                    if(productMap != null && productMap.size()>0){
                        for(String s : tempList){
                            if(productMap.get(s) != null){
                                CallDetail__c callDetail = new CallDetail__c();
                                callDetail.Call__c = call.Id;
                                callDetail.Product__c = productMap.get(s);
                                callDetailList.add(callDetail);
                            }
                        }
                    }
                    if(callDetailList != null && callDetailList.size()>0)
                        insert callDetailList;
                }
            }
            PageReference pageRef = new PageReference('/'+call.Id);
            return pageRef;
        }
        return null;
    }
    
    public PageReference submitDetails(){
    
        system.debug('--- CallController :: submitDetails() ---');
        update call;    
        return cancel();
    }
    
    public PageReference cancel(){
        
        system.debug('--- CallController :: cancel() ---');
        if(accId != null){
            PageReference pageRef = new PageReference('/'+accId);
            system.debug('--- CallController :: cancel() :: pageRef ---'+pageRef);        
            return pageRef;
        }
        if(retURL != null){
            PageReference pageRef = new PageReference(retURL);
            system.debug('--- CallController :: cancel() :: pageRef ---'+pageRef);        
            return pageRef;
        }
        if(callId!= null){
            PageReference pageRef = new PageReference('/'+callId);
            system.debug('--- CallController :: cancel() :: pageRef ---'+pageRef);        
            return pageRef;
        }
        return null;
    }
    
    public void getCallType(){
        String test = ApexPages.currentPage().getParameters().get('test');
        system.debug('--- test ---'+test);
        recordTypeName = test;
    }
    
    public void setCallType(){
        recordTypeName = call.Activity_Type__c;
    }
    
    public PageReference addProduct(){
        system.debug('--- selectedProduct ---'+selectedProduct);
        //selectedProduct = 'GUT PLAIN SUTURE 18IN(45CM) 5-0 UND';
        if(productList == null)
            productList = new List<WrapperClass>();
            
            Boolean isAlreadyAdded = false;
            for(WrapperClass wrp: productList)
            {
               if(selectedProduct.equalsignorecase(wrp.product))
               {
                   isAlreadyAdded = true;
               }
            }
            
            if(selectedProduct != null && isAlreadyAdded != true )
            {
               WrapperClass wrapper = new WrapperClass(selectedProduct,false);
               productList.add(wrapper);
            }
            
        /*if(selectedProduct != null)
        {
            WrapperClass wrapper = new WrapperClass(selectedProduct,false);
            productList.add(wrapper);
        }*/
        system.debug('---- productList size ----'+productList.size());
        return null;
    }
    
    public PageReference removeProduct(){
        if(productList != null && productList.size()>0){
            system.debug('---- productList size ----'+productList.size());
            List<WrapperClass> tempList = new List<WrapperClass>();
            for(WrapperClass temp : productList){
                system.debug('---- checkbox selected product name  ----'+temp);
                if(temp.selected == false){
                    system.debug('---- checkbox selected product name  ----'+temp.product);  
                    tempList.add(temp);
                }
            }
            productList = tempList;
        }
        return null;
    }
    
    public void setCall(Call__c call){
        this.call = call;
    }
    
    public Call__c getCall(){
        if(this.call == null)
            call = new Call__c();
        if(account != null )
            call.Account__c = account.Id;
        return call;
    }
    
    public void setCallDetail(CallDetail__c callDetail){
        this.callDetail = callDetail;
    }
    
    public CallDetail__c getCallDetail(){
        if(this.callDetail == null){
            List<CallDetail__c> callDetailList = new List<CallDetail__c>();
            if(this.call != null){
                callDetailList = [select Id, Name, Call_Feedback__c from CallDetail__c where Call__c=:this.call.Id];
                if(callDetailList.size()>0)
                    callDetail = callDetailList.get(0);
            }
            if(callDetail == null)
                callDetail = new CallDetail__c();
        }
        return callDetail;
    }
    
    public class WrapperClass{        
        public String product {get; set;}
        public Boolean selected {get; set;}
        public WrapperClass(String p,Boolean s) {
            product = p;
            selected = s;
        }
    }
}

 

Hi I am fairly new to salesforce so I apologize if this is an obvious question.

 

I am working on a Quote tool. There is both a Quote and Quote Request object. I need to have some of the info from the Quote Request show up as the default text in the quote, the quantity for example. I would do a formula but it doesn't show up when creating a new quote and its read only.

 

I have a master detail setup between the quote and quote request. I tried using the syntax from the formula field type, but it told me it was spelled wrong or didn't exist.

 

Thanks in advanced

 

Tyler

Hi,

 

I want to create standard new button for a custom object. Please tell me how can i do this.

 

Thanks..

Hello,

 

I have a custom object that has a Master-Detail relationship with the Account object.  I have a VF page that gets created using this custom object as the controller.  I would like to be able to list out in this VF page any open Opportunities that are associated with the same Master Account as my custom object record.  Is this possible and if so, can someone point me to somewhere that explains it?  Thanks.

  • November 20, 2012
  • Like
  • 0

Hi guys,

 

  I have a problem to get Edit mode in VF page.

  Here by using apex:Detail we will get inline Edit mode of the Total page.Like this

<apex:page standardController="Event">
<apex:form >
<apex:pageBlock >
<apex:detail inlineEdit="True" relatedList="true"/>
</apex:pageBlock>
</apex:form>
</apex:page>

 

   Now i want Edit mode with out using apex:inputfield , Is there any way to do it.

   Please let me know.

 

 

Thaks 

Prem