function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vinay_guptaVinay_gupta 

Scenario of Apex, Triggers and VF pages

Hi All,

I wanted to know solution for below Question.
 
1.    Can we call a @Future method from Trigger?
2.    Can we call a @Future method from the Batch process?
3.    If I want to display the next month date in a custom field on the VF page which approach should we use?
4.    If I want to process 1000 records using Batch apex ,then how much time Batch process will run? How many times will each batch method run?
5.    How to Create one to one relationship?
6.    If i want to share  50 records to 100 users who are at different profile. How we can acheive this ? How we can acheive this using Manual Sharing?
7.    How to find no of time which user has accessed the particular tab ?
8.    What is 101 code error in Appex class?
9.    Can we create Roll up summary in Look up relationship?
10.    How to delete lookup data when Parent record is deleted? How to make it mandatory?
11.    If there is a scenario, where there is one field called status. When this field become CLOSED then process builder should not do any task. 
And if in future if anyone changed the Status field to OPEN of the same record then we don’t want Process builder to fire any task. How we can achieve this?
12.    What is the best practice to write Apex class?
 

Marcelo CostaMarcelo Costa

Hi Varum... this is a LOT of questions :) I'll give you my Opinions (as some things have multiple ways to be achieved)

1.    Can we call a @Future method from Trigger?
YES
2.    Can we call a @Future method from the Batch process?
YES
3.    If I want to display the next month date in a custom field on the VF page which approach should we use?
Some options here. I would use a controller to calculate the value and populate it.
4.    If I want to process 1000 records using Batch apex ,then how much time Batch process will run? How many times will each batch method run?
By default, the batch size is 200, so, for 1000 would run 5 times. But it is actually configurable.
5.    How to Create one to one relationship?
This is a tricky one. The one time I needed, we ended up creating a master detail,. with a validation for the summary to limit it to one.
6.    If i want to share  50 records to 100 users who are at different profile. How we can acheive this ? How we can acheive this using Manual Sharing?
Not really sure I got the question right. you have some option for this, Manual sharing, apex sharing culd be an option too.
7.    How to find no of time which user has accessed the particular tab ?
I do not think there is a standard way to get this... (good question BTW).
8.    What is 101 code error in Appex class?
Too many SOQL! usually if you do a SOQL query inside a loop. basically you reached the context limit for soql. 
9.    Can we create Roll up summary in Look up relationship?
No. Roll Ups are for master detail only. Some 3rd paties implement it. look it up on appExchange.
10.    How to delete lookup data when Parent record is deleted? How to make it mandatory?
Triggers.
11.    If there is a scenario, where there is one field called status. When this field become CLOSED then process builder should not do any task. 
And if in future if anyone changed the Status field to OPEN of the same record then we don’t want Process builder to fire any task. How we can achieve this?
12.    What is the best practice to write Apex class?
Salesforce has a set of best practices https://developer.salesforce.com/page/Apex_Code_Best_Practices we use this as a starting point, and developed owr own coding standards.