• mriz
  • NEWBIE
  • 20 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 8
    Replies
I have two custom objects Project__c & task__c (custom task, so that same task can be allocated to multiple people). one project can have multiple tasks, but task is uniquely associated with project.
I can't use lookup field in task for Project due to my design constraint. I am rather having a field project_id__c holding ID of project in task.

Apex Code:
public class TestClass1{
	public List<Id> tasks{get;set;}
	public Map<Id,String> taskMap{get;set;} //  to hold task id and project name
	
	public TestClass1(){
		try{
			tasks = [SELECT id,name,project_id__c FROM Task__c];
			projectNames();
		}catch(Exception e){
			System.debug(e);
		}
	}
	
	public void projectNames(){
		List<Id> projectIds = new List<Id>;
		for(Task__c t:tasks)
			projectIds.add(t.project_id__c);
			
		System.debug('Size of tasks: '+tasks.size());
		
		List<Project__c> projects = [SELECT name FROM Project__c WHERE id IN:projectIds]
		System.debug('Size of projects: '+projects.size());
		
		/*
		this section fails when, say 3 out of 5 tasks are part of one project
		for(Integer i=0;i<tasks.size();i++)
			taskMap.put(t[i].id,projects[i].name);
		*/
	}
}
I am facing problem in handling bulkified query.

one quickFix is to query project object inside for loop, but that is extrememly poor approach in SFDC.

Whats solution for this?
 
  • March 05, 2016
  • Like
  • 0
I want to add multiple SelectLists in new row on each button click using jQuery.

Following code is not working for me

VF Code:
<apex:page controller="TestClass" id="pg" sidebar="false" showHeader="false" doctype="html-5.0" standardStylesheets="false">
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
        <style>
            body{font-family:Arial,Sans;}
            a{text-decoration:none;}
            
        </style>
    </head>
    <body>
       
        <div>
            <apex:form >
                <apex:selectList size="1" multiselect="false" value="{!str}">
                    <apex:selectoptions value="{!Roles}"/>  
                </apex:selectList><br/>
                
            </apex:form>
            <button id="addRow" type="button">Add Row</button>
        </div>
        
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        
        <script>
            $(document).ready(function(){
                $("#addRow").click(function(){
                   // alert('hi');
                   $("#addRow").before('<apex:form ><apex:selectList value="{!str}"><apex:selectOptions value="{!Roles}"/></apex:SelectList></apex:form>');
                });
            });
        </script>
        
    </body>
</apex:page>


Apex Class
public class TestClass{
    public string str{get;set;}
    
    public TestClass(){
           
    }
    public List<selectOption> getRoles(){
        List<SelectOption> myList=new List<selectOption>();
        
        myList.add(new SelectOption('0','--Select--'));
        myList.add(new SelectOption('val1','Val1'));
        myList.add(new SelectOption('val2','Val2'));
        myList.add(new SelectOption('val3','Val3'));
        
        return myList;
    }
}

I have even tried this variation, but with no success:
 
<apex:page controller="TestClass" id="pg" sidebar="false" showHeader="false" doctype="html-5.0" standardStylesheets="false">
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
        <style>
            body{font-family:Arial,Sans;}
            a{text-decoration:none;}
            
        </style>
    </head>
    <body>
       
        <div>
            <apex:form >
                <apex:selectList size="1" multiselect="false" value="{!str}">
                    <apex:selectoptions value="{!Roles}"/>  
                </apex:selectList><br/>
                <!-- changed part -->
                <button id="addRow" type="button">Add Row</button>
            </apex:form>
            
        </div>
        
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        
        <script>
            $(document).ready(function(){
                $("#addRow").click(function(){
                   // alert('hi');
                   $("#addRow").before('<apex:selectList value="{!str}"><apex:selectOptions value="{!Roles}"/></apex:SelectList>');
                });
            });
        </script>
        
    </body>
</apex:page>

 
  • February 25, 2016
  • Like
  • 0
I have a requirement wherein i want to pass values from Apex to Javascript/jQuery. I want to add some properties to the values received in jQuery and then add those values on VF page.

(I want to create hierarchy of a custom object record which can be related to different objects and the level of depth and width is n).
  • February 16, 2016
  • Like
  • 0
I want to fetch id of contact person associated with an Account. And then use it in VF page.

SOQL
Account ac=[Select id,name,(select id,phone from Contact) where name='xyz' limit 1];
public ID cId;

This line compiles well.
But i don't how to use store contact Id from "ac" to "cId".

Any help would be highly appreciated.
Query:
  • January 27, 2016
  • Like
  • 0
I am trying to use HTML5 & bootstrap from CDN on a VF page, with standaStyling set to false. I want to bind apex action on button tag.
VF Code
<apex:page controller="OutcomeClass" sidebar="false" showheader="false" doctype="html-5.0" standardStylesheets="false">
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"/>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  <style>
      body{font-family:Consolas,Arial,sans;}
  </style>
  <apex:pageBlock >
      <apex:form>
          Your Name: {!$User.FirstName}<br/><br/>
          
          <button type="button" class="btn btn-success">Click</button>
          <!--    i want to add action="{!updateOutcomes}"   in the button tag    -->
      </apex:form>
  </apex:pageBlock>
</apex:page>

Apex Code
public class OutcomeClass{
    public OutcomeClass(){
        //do something here
    }
    public void updateOutcomes(){
        // do something else here
    }
}

 
  • January 20, 2016
  • Like
  • 0
Hi,
I have two objects A and B, A is the parent to B, both objacts have status fields, when ever Aobject Status is changed from "Inprogress" to "Complete"then all child B object status changed to "Complete".
Please send me the sample trigger.
I want to add multiple SelectLists in new row on each button click using jQuery.

Following code is not working for me

VF Code:
<apex:page controller="TestClass" id="pg" sidebar="false" showHeader="false" doctype="html-5.0" standardStylesheets="false">
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
        <style>
            body{font-family:Arial,Sans;}
            a{text-decoration:none;}
            
        </style>
    </head>
    <body>
       
        <div>
            <apex:form >
                <apex:selectList size="1" multiselect="false" value="{!str}">
                    <apex:selectoptions value="{!Roles}"/>  
                </apex:selectList><br/>
                
            </apex:form>
            <button id="addRow" type="button">Add Row</button>
        </div>
        
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        
        <script>
            $(document).ready(function(){
                $("#addRow").click(function(){
                   // alert('hi');
                   $("#addRow").before('<apex:form ><apex:selectList value="{!str}"><apex:selectOptions value="{!Roles}"/></apex:SelectList></apex:form>');
                });
            });
        </script>
        
    </body>
</apex:page>


Apex Class
public class TestClass{
    public string str{get;set;}
    
    public TestClass(){
           
    }
    public List<selectOption> getRoles(){
        List<SelectOption> myList=new List<selectOption>();
        
        myList.add(new SelectOption('0','--Select--'));
        myList.add(new SelectOption('val1','Val1'));
        myList.add(new SelectOption('val2','Val2'));
        myList.add(new SelectOption('val3','Val3'));
        
        return myList;
    }
}

I have even tried this variation, but with no success:
 
<apex:page controller="TestClass" id="pg" sidebar="false" showHeader="false" doctype="html-5.0" standardStylesheets="false">
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
        <style>
            body{font-family:Arial,Sans;}
            a{text-decoration:none;}
            
        </style>
    </head>
    <body>
       
        <div>
            <apex:form >
                <apex:selectList size="1" multiselect="false" value="{!str}">
                    <apex:selectoptions value="{!Roles}"/>  
                </apex:selectList><br/>
                <!-- changed part -->
                <button id="addRow" type="button">Add Row</button>
            </apex:form>
            
        </div>
        
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        
        <script>
            $(document).ready(function(){
                $("#addRow").click(function(){
                   // alert('hi');
                   $("#addRow").before('<apex:selectList value="{!str}"><apex:selectOptions value="{!Roles}"/></apex:SelectList>');
                });
            });
        </script>
        
    </body>
</apex:page>

 
  • February 25, 2016
  • Like
  • 0
I have a requirement wherein i want to pass values from Apex to Javascript/jQuery. I want to add some properties to the values received in jQuery and then add those values on VF page.

(I want to create hierarchy of a custom object record which can be related to different objects and the level of depth and width is n).
  • February 16, 2016
  • Like
  • 0
I want to fetch id of contact person associated with an Account. And then use it in VF page.

SOQL
Account ac=[Select id,name,(select id,phone from Contact) where name='xyz' limit 1];
public ID cId;

This line compiles well.
But i don't how to use store contact Id from "ac" to "cId".

Any help would be highly appreciated.
Query:
  • January 27, 2016
  • Like
  • 0
I am trying to use HTML5 & bootstrap from CDN on a VF page, with standaStyling set to false. I want to bind apex action on button tag.
VF Code
<apex:page controller="OutcomeClass" sidebar="false" showheader="false" doctype="html-5.0" standardStylesheets="false">
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"/>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  <style>
      body{font-family:Consolas,Arial,sans;}
  </style>
  <apex:pageBlock >
      <apex:form>
          Your Name: {!$User.FirstName}<br/><br/>
          
          <button type="button" class="btn btn-success">Click</button>
          <!--    i want to add action="{!updateOutcomes}"   in the button tag    -->
      </apex:form>
  </apex:pageBlock>
</apex:page>

Apex Code
public class OutcomeClass{
    public OutcomeClass(){
        //do something here
    }
    public void updateOutcomes(){
        // do something else here
    }
}

 
  • January 20, 2016
  • Like
  • 0

is it possible to access login history details of a user through API ? please do mention the api version too

  • September 09, 2010
  • Like
  • 0
hi,
Does the salesforce store the login histroy of a user??
For example, when i log in, i need to see what was the last time i logged in. Although a method is provided with the User class getLastLoginDate(). But wen i log in, my last login date changes to the current loggin time. In short, i want to access my previous loggin date/time.
kindly help me in this regrd.
thanks
Omar Altaf
  • February 06, 2006
  • Like
  • 0