Tanu Rajput
IndividualForum Replies Created
-
Tanu
MemberOctober 16, 2017 at 2:56 pm in reply to: How to convert a timestamp value to datetime in apex?I am getting wrong value of timestamp "201708161100" by this way, so please help me to get right answer.
You can validate your answer here Convert Timestamp to date. -
Tanu
MemberDecember 8, 2016 at 1:42 pm in reply to: Finding Sobject type when Id is given in Salesforce?Hi Kumar,
Try this,
Schema.SObjectType sobjectType = Id.getSObjectType();
sobjectName = sobjectType.getDescribe().getName(); -
Tanu
MemberOctober 18, 2016 at 6:46 am in reply to: How to get the Label Names for Object's fields in Salesforce?Hello Pranav,
try this
String type='Account';
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Schema.SObjectType leadSchema = schemaMap.get(type);
Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap();
for (String fieldName: fieldMap.keySet()) {System.debug('##Field API Name='+fieldName);// list of all field API name
fieldMap.get(fieldName).getDescribe().getLabel();//It provides to get the object fields label.
} -
Tanu
MemberOctober 18, 2016 at 6:27 am in reply to: How to skip the first item while iteration through list in salesforce?Hello Pranav,
You can do this by using the regular loop like this
int size = myList.size();
for (int i = 1; i < size; i++) {
myList.get(i).doSomething();
}for example-
list<Contact> con = new list<Contact>();
for(Integer i=0;i<10;i++){
Contact c = new Contact(lastname='tt'+i);
con.add(c);
}
insert con;
for(Integer i=1;i<10;i++){
System.debug(con.get(i).lastname);
} -
Tanu
MemberSeptember 28, 2016 at 2:57 pm in reply to: How can we make the force logout from the force.com site by the use of apex in salesforce?Hello Mohit,
There is no class for the logout. when you are logged in you are authenticated as portal user, and portal has a page for logout.
-
Tanu
MemberSeptember 28, 2016 at 2:53 pm in reply to: Does Salesforce apex transpiled into java or not ?Hello Mohit,
In one embodiment, the Apex interpreter serves as a level of isolation between customer code and the host virtual machine (VM). The Apex interpreter may enforce governor limits and brokers requests to the underlying platform on behalf of customer code. In one embodiment, the Apex interpreter is not a full-fledged Java virtual machine. The Apex interpeter may delegate to a Java virtual machine (JVM) for various services. Garbage collection is an example of this. In one embodiment, the Apex interpreter is also able to delegate to the VM on a per type basis.
Apex Code runs in Java, but it is not a full VM, and will delegate various tasks such as garbage collection to the underlying Java VM
-
Tanu
MemberSeptember 27, 2016 at 1:12 pm in reply to: Which action methods do standard controllers contains in Salesforce visualforce page?Hello Pranav,
Standard controllers contains following action methods in visualforce page are
- save - Inserts a new record or updates an existing record if it is currently in context. After this operation is finished, the save action returns the user to the original page (if known), or navigates the user to the detail page for the saved record.
- quicksave - Inserts a new record or updates an existing record if it is currently in context. Unlike the save action, this page does not redirect the user to another page.
- edit - Navigates the user to the edit page for the record that is currently in context. After this operation is finished, the edit action returns the user to the page where the user originally invoked the action.
- delete - Deletes the record that is currently in content. After this operation is finished, the delete action either refreshes the page or sends the user to tab for the associated object.
- cancel - Aborts an edit operation. After this operation is finished, the cancel action returns the user to the page where the user originally invoked the edit.
- list - Returns a PageReference object of the standard list page, based on the most recently used list filter for that object. For-example, if the standard controller is contact, and the last filtered list that the user viewed is New Last Week, the contacts created in the last week are displayed.
-
Tanu
MemberSeptember 26, 2016 at 1:48 pm in reply to: Is it feasible to use anguarJS in Salesforce visualforce page?Hello Mohit,
Yes it's feasible to use anguarJs in visualforce page.
Advantage
1. Two way Data Binding.
2. It support SPA(Single Page Application).
3. MVC(Model View Controller) pattern supported.
4. Less code
Disadvantages
1.AngularJS Its have some limitation when we handling huge amount of data.
-
Tanu
MemberSeptember 26, 2016 at 1:20 pm in reply to: How can I check if a record is locked or not through Salesforce Apex ?Hi Pranav,
Yes,You can check the record is locked or not through apex with the help of approval class by using this piece of code
Approval.isLocked(recordId)
This method can also accept List<Id>, SObject, or List<SObject>.
-
Tanu
MemberSeptember 23, 2016 at 6:22 am in reply to: What real happen when the re-render is execute in visualforce page in salesforce?Hello Mohit,
When a re-render occurs, only the portion of the DOM that is set to rerender is actually re-rendered. If any jQuery event bindings that you create are essentially lost for the portion of the DOM that was re-rendered. If you wrap these event binding calls in a function, it's easy to re-bind.
-
Tanu
MemberSeptember 23, 2016 at 6:08 am in reply to: Can trigger is able to modify the record locked by the approval process in Salesforce?Hello Mohit,
It's depends on your code.If you have your code written directly in the trigger or in a class designated without sharing, then the apex code can update records that are locked, regardless of the user who caused the trigger to fire. I tested by creating a trigger on Contact that updates a field on the Contact's Account. When the Account is locked, I can edit the contact record with a non admin user and the field on the Account gets updated.
If you use code in a class marked with sharing that is called by the trigger, then you will get an exception. If the trigger was executed by an Administrator, then the code will always run.
-
Tanu
MemberSeptember 22, 2016 at 5:53 am in reply to: How can we access the custom setting in test class without using the seeAllData = true in Salesforce?Hi Mohit,
Custom settings are nothing but an object .All you need in Test Class is instantiate the custom settings object and create the records of the custom settings and insert it in Test class itself.Make sure you bulkify your insert call.
For example-
list<SFA_ContactFields__c> lstContacts=new list<SFA_ContactFields__c>();//bulk List of custom setting object for bulk insert
SFA_ContactFields__c csContactFields=new SFA_ContactFields__c(); //Custom Setting for Contact Fields
csContactFields.Name='CreatedDate';//Static record 1 of custom setting
lstContacts.add(csContactFields);SFA_ContactFields__c csContactFields1=new SFA_ContactFields__c();
csContactFields1.name='IsDeleted';//Static Record 2 of custom settings
lstContacts.add(csContactFields1);insert lstContacts;
I think this help you.
Thanks
-
Tanu
MemberSeptember 21, 2016 at 7:46 am in reply to: How to convert the String format decimal into a currency format in Salesforce Apex?Hello Mohit,
Currency format of different countries are different,so we assume here "1,000.00" as currency format because in most of English countries this currency format is used.Let's try this code-
String i='2050066.50';
String s = ( Decimal.valueOf(i==null||i.trim()==''?'0':i).setScale(2) + 0.001 ).format();
String p = s.substring(0,s.length()-1);
System.debug(p); -
Tanu
MemberSeptember 21, 2016 at 7:03 am in reply to: How can we convert the large digit decimal number to certain digit decimal number in Salesforce?Hello Mohit,
Try this,
Decimal toround = 3.14159265;
Decimal rounded = toround.setScale(2);
system.debug(rounded); -
Tanu
MemberSeptember 20, 2016 at 10:22 am in reply to: In Salesforce, How will you differentiate DML and SOQL?Hello Mohit,
SOQL(Salesforce Object Query Language) is the query language that allows you to retrieve data from the database.
for example-
Account a = [Select Name from Account where Name = 'My Account'];
DML allows you to manipulate that data via inserts, updates etc.
for example-
Account a = new Account(Name = 'New Account');
insert a; // This will insert a account
a.Name = 'Updated Name';
update a;//Update the account record
Delete a;
//delete theaccount record
They relate to Apex in that they form part of the language. SOQL queries can be executed from Apex to retrieve information for further processing, DML allows Apex code to change the data.
-
Tanu
MemberSeptember 20, 2016 at 9:31 am in reply to: How to use custom label inside the Salesforce component?Hello Mohit,
Use this syntax to access custom labels in Lightning components:
- $Label.c.labelName for the default namespace
- $Label.namespace.labelName if your org has a namespace, or to access a label in a managed package
Here are some examples.
- Label in a markup expression using the default namespace
{!$Label.c.labelName} - Label in JavaScript code if your org has a namespace
$A.get("$Label.namespace.labelName")
-
Tanu
MemberSeptember 20, 2016 at 6:37 am in reply to: How can we call the javascript function from the Salesforce Apex class?Hello Mohit,
Try this,
<apex:page controller="calljavascript_cls" >
<script>
function func()
{
alert('function calling');
}
</script>
<apex:outputText value="{!callfunc}" escape="false"></apex:outputText>
<apex:outputText value="{JavaScript}" ></apex:outputText>
</apex:page>-------------------------------
apex controller
public class calljavascript_cls
{
public string callfunc{get;set;}
public calljavascript_cls()
{
callfunc='<script> func(); </script>';
}
}
-
Tanu
MemberSeptember 9, 2016 at 6:30 am in reply to: Why recalculateFormulas is not working on the relationship fields?Hi Mohit,
recalculateFormulas()
Recalculates all formula fields on an sObject, and sets updated field values. Rather than inserting or updating objects each time you want to test changes to your formula logic, call this method and inspect your new field values. Then make further logic changes as needed.
NOTE: This method doesn’t recalculate cross-object formulas. If you call this method on objects that have both cross-object and non-cross-object formula fields, only the non-cross-object formula fields are recalculated.
Cross-object formulas are formulas that span two related objects and reference merge fields on those objects. Cross-object formulas can reference merge fields from a master (“parent”) object if an object is on the detail side of a master-detail relationship. Cross-object formulas also work with lookup relationships.
Hope this helps you.
Thanks
-
Tanu
MemberSeptember 8, 2016 at 5:19 am in reply to: How can I show my IP Address in Salesforce Visualforce Page?Hello Pranav,
Try this code
Apex controller :
public class IPAddress
{
public string myIPAddress{get;set;}
public IPAddress()
{
myIPAddress = ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');
}
}VisualforcePage :
<apex:page controller="IPAddress" >
Your Login IP Address : {!myIPAddress}
</apex:page> -
Tanu
MemberSeptember 8, 2016 at 5:04 am in reply to: Is Finish method in Salesforce batch class is called when batch is manually aborted?Hello Mohit,
No,The finish method is called after all batches are processed. Use this method to send confirmation emails or execute post-processing operations.
That means that if at least one batch wasn't executed we will not enter finish() method.
-
Tanu
MemberSeptember 7, 2016 at 6:29 am in reply to: In Salesforce, how can I tell the day of the week on a date?Hello Mohit,
Date daytofind = Date.newInstance(Year, Month, Day);
Try this example,
Date daytofind = Date.newInstance(2016, 9, 6);
DateTime myDateTime = (DateTime) daytofind;
String dayOfWeek = myDateTime.format('E'); -
Tanu
MemberSeptember 6, 2016 at 6:27 am in reply to: How can we test list size from the Salesforce visualforce page?Hello Mohit,
On visualforce page we can check conditions by:
{!IF(condition,InTrueCondition,IfConditionIsFalse)}
For example :
First you have to make a controller to pass this list
<apex:pageBlockTable ... rendered="{!IF(listInstance.size>0,'true','false')">
-
Tanu
MemberSeptember 2, 2016 at 7:44 am in reply to: How can we define Html pages to Static Resources to available in Salesforce visualforce page?Hello Pranav,
yes you can put the html file in zip file.
The way you have to refer is
<apex:iframe src="{!URLFOR($Resource.Htmlcontent)}"/>
Htmlcontent is the static resource name
Thanks
-
Tanu
MemberSeptember 2, 2016 at 7:35 am in reply to: How person account is different from standard account in salesforce? How can I enable person account in Developer edition ?Hello Pranav,
To enable person account we have to use Customize Application
Before you begin, make sure to:
- Create at least one record type for accounts.
- Grant read permission on contacts for profiles that have read permission on accounts.
- Ensure that the contact sharing organization-wide default is set to “Controlled by Parent.”
Once you complete the preliminary steps, contact Salesforce to enable person accounts and then:
- From the object management settings for person accounts, go to Record Types.
- Assign person account record types to profiles that require person accounts.
-
Tanu
MemberAugust 31, 2016 at 2:24 pm in reply to: Can I update both parent and child records in the same trigger method?You need a few things to update both child + parent records in the same trigger :
1)parent MUST be inserted before child.
2)there MUST be a relation between child and parent before you insert them.
3)some sort of "temporary holder" for the parent ID before it is associated with the child (here he has used external IDs)1)create a parent with an external ID.
2)create a child with same external ID as parent's.
3)insert the parent FIRST and then the child.Try this,i think this may help you.