shariq
IndividualForum Replies Created
-
shariq
MemberSeptember 22, 2018 at 9:39 PM in reply to: How to restrict the controller action for users which are logged in using “Grant Login Access” in Salesforce?When System admin logged in on the behalf of any other user. On upper right corner message is displayed that user is logged-in on behalf of some other user. In Visualforce page we can search for the element with class name present or not? If the element with that Class name exist means logged-in user is not a actual user.
-
shariq
MemberSeptember 22, 2018 at 9:38 PM in reply to: Write Salesforce Apex Code to take RecordID as input and print Object name and field names of sObject.List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();
Map<String,String> objectMap = new Map<String,String>();
for(Schema.SObjectType f : gd)
{
objectMap.put(f.getDescribe().getKeyPrefix(), f.getDescribe().getName());
}String sampleId ='00390000003LIVw';
String prefix = sampleId.substring(0,3);
String objectName = objectMap.get(prefix);
System.debug('** SObject Name ** '+objectName);Map<String, Schema.SObjectField> desResult = Schema.getGlobalDescribe().get(objectName).getDescribe().Fields.getMap();
List<String> fieldList = new List<String>();
fieldList.addAll(desResult.keySet());
for(integer i =0;i<fieldList.size();i++)
{
System.debug('** Field Name ** '+fieldList[i]);
} -
shariq
MemberSeptember 22, 2018 at 9:38 PM in reply to: How to get the Recordtype Id using Dynamic Apex in Salesforce?Normally to get the RecordtypeId for any sObject we use SOQL and it will count against your limit. So below method will bypass the need of SOQL Query.
Map<String, Schema.SObjectType> m = Schema.getGlobalDescribe() ;
Schema.SObjectType s = m.get('API_Name_Of_SObject') ;
Schema.DescribeSObjectResult cfrSchema = s.getDescribe() ;
Map<String,Schema.RecordTypeInfo> RecordTypeInfo = cfrSchema.getRecordTypeInfosByName();
Id rtId = RecordTypeInfo.get('Record Type Name').getRecordTypeId(); -
shariq
MemberSeptember 22, 2018 at 9:37 PM in reply to: Will system.debug() statement get executed in Trigger after adderror() method in Salesforce?adderror() method is not error statement rather its normal execution flow and all the statements written after adderror() will be executed normally.
-
shariq
MemberSeptember 22, 2018 at 9:36 PM in reply to: How to clear the Time based workflow action queue in Salesforce?Two ways to achieve this : 1. Make criteria false for all those records. 2. Navigate to “Set up | Monitoring | Time Based Workflow”, search for scheduled actions and remove from queue.
-
shariq
MemberSeptember 22, 2018 at 9:35 PM in reply to: Can you reuse same Changeset to deploy changed component in Salesforce?Once changeset is created it cannot be modified. After creation of changset, if we modify any component it will not reflected and we need to clone the changeset to reflect changes
-
shariq
MemberSeptember 22, 2018 at 9:34 PM in reply to: In Custom Component, how we can return value to Custom Controller or Controller Extension in Salesforce?In Apex, Objects are passed by reference, So supply an argument of wrapper class (object) type to custom component. If its value is changed in Custom component we will get updated value in controller also.
-
shariq
MemberSeptember 22, 2018 at 6:42 PM in reply to: Anyone logged in to API can see the javascript code, your username and password - how to avoid this in Salesforce?We can create a visualforce page with output type as JavaScript. Global session variable is available in VF page. Initialize the global javascript variable in that VF page. include VF page as a javascript file and we are done!
-
shariq
MemberSeptember 22, 2018 at 6:41 PM in reply to: How to get selected records ID from List View using Javascript / Ajax Toolkit in Salesforce?Create a new Button on Lead of type List Button. Add the button on Lead List View Layout and write below Javascript code:
{!RequireScript("/js/functions.js")}
var recordsSelected = {!GetRecordIds($ObjectType.Lead)}
for(var i=0; i < recordsSelected .length ; i++) {
alert('Selected ID '+recordsSelected[i]);
} -
shariq
MemberSeptember 22, 2018 at 6:41 PM in reply to: One class has 0% code coverage. Can we still deploy that class on production in Salesforce?Yes. Minimum 1% required for every trigger and there is no such restriction for Apex class.
-
shariq
MemberSeptember 22, 2018 at 6:40 PM in reply to: Why is user unable to see dashboard sometimes even with all permissions in Salesforce?It is possible that Salesforce User license for Dashbaord running user is different than User wants to access Dashboard. Example – Running User license is “Salesforce” and user trying to access Dashboard is “Salesforce Plateform”.
-
shariq
MemberSeptember 22, 2018 at 6:39 PM in reply to: What is the difference between “apex:dataTable” and “apex:pageBlockTable” components in Salesforce Visualforce?Both component is used to render data in tabular format. dataTable will render records in simple HTML table format whereas the “pageBlockTable” possess default look and feel of salesforce standard CSS and must be written inside “apex:pageBlock” componet.
-
shariq
MemberSeptember 22, 2018 at 6:38 PM in reply to: In how many ways you can invoke Controllers / Controller Extensions method from Salesforce Visualforce?Javascript Remoting, ActionFunction, ActionSupport, ActionPoller.
-
shariq
MemberSeptember 22, 2018 at 6:38 PM in reply to: Explain ActionFunction, ActionSupport and ActionPoller in Salesforce Visualforce.apex:ActionFunction: This component helps to envoke AJAX request (Call Controllers method) directly from Javascript method. It must be child of apex:form. Read here – http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionFunction.htm
apex:ActionSupport: This component adds Ajax request to any other Visualforce component. Example : Commandlink button has inbuilt AJAX functionality however few components like OutputPanel does not have inbuilt AJAX capabilities. So with the help of this component, we can enable AJAX. Read more here.
apex:ActionPoller: This is timer component which can send AJAX request on pre-defined interval. Minimum interval is 5 sec and default is 60 sec
-
shariq
MemberSeptember 22, 2018 at 6:36 PM in reply to: System.debug() statements are included against script count in Salesforce?Any statement ending with semi-colon will be included against script count
-
shariq
MemberSeptember 22, 2018 at 6:36 PM in reply to: Date field value uploaded using Data Loader is sometimes one day before the date in the file in Salesforce?The reason for this is that fields such as Close Date are actually date/time fields. When a date is loaded without specifying the time, the time is defaulted to 00:00 – midnight. When another user is in a time zone which is behind the current user’s time zone, the date will show on the previous day. For example:
20 August 2008 00:00 in Paris is 19 August 2008 23:00 in London
Similar issues can arise when daylight savings time begins or ends.
Two simple solutions to this are:
1) Specify a time as well as a date when loading dates using the Data Loader.
or
2) Switch your PC’s time zone to Hawaiian time before starting up the Data Loader. -
shariq
MemberSeptember 22, 2018 at 6:35 PM in reply to: How to update the Same Record in After Trigger context in Salesforce?If we create a new instance of an SObject in the Apex Trigger in memory using the Id of the newly created record as provided in the After Trigger context, we can perform an Update DML statement and not get a read only error. This is because in Apex, the SObject is seen as a new reference (even though the records have the same SFDC ID) and therefore is eligible for DML operations. The below snippet of code illustrated this working and not working.
List<Contact> originals = new List<Contact>();
if(mirrorResultMap.values().size() > 0)
{
for(Contact origContact : contactRecs.values())
{
Contact mirrorContact = mirrorResultMap.get(origContact.Id);
//origContact.Linked_Contact__c = mirrorContact.Id; //Link the Original Record tot he Mirror Record WILL FAIL
Contact origContactUpdate = new Contact(Id=origContact.Id, Linked_Contact__c = mirrorContact.Id); //This will WORK
originals.add(origContactUpdate);
}
//update contactRecs.values(); //Update the Records -> THIS WILL FAIL AS ITS ORIGINAL RECORDS IN MEMORY
update originals;
} -
shariq
MemberSeptember 22, 2018 at 6:33 PM in reply to: While creating a record for detail object, select parent record not created by the user. What will happen to Salesforce Master-Detail Relationship?He will get an error, because in order to add child record user must have edit permission in parent master record.
-
shariq
MemberSeptember 22, 2018 at 6:33 PM in reply to: How to convert carriage returns in Textarea to Line Breaks in Salesforce Visualforce?Data Loader cannot handle this implicitly because there is no logical path to follow. In case your Data Loader CSV file for import will contain commas for any of the field content, you will have to enclose the contents within double quotation marks ” “. Data Loader will be able to handle this.
For example :
1
Column_1__c,Column_2__c,Column_3__c
2
Shiva,"Jitendra, Minal",Soft
If you are creating the import CSV in Excel, the quotation marks will be inserted automatically by Excel whenever a comma is detected in any cell – Saving the CSV in Excel and opening the same in Notepad reveals the enclosing quotation marks for cells containing commas. -
shariq
MemberSeptember 22, 2018 at 6:32 PM in reply to: Field reset on Convert Lead so SOQL cannot query sensitive information in SalesforceOnce lead is converted, its READ ONLY. we cannot update it using Apex or Trigger. However we can use “Before Update” trigger on lead and check for fiels “IsConverted“. If its true means lead is going to be converted so reset all fields in that case.
-
shariq
MemberSeptember 22, 2018 at 6:32 PM in reply to: Code Visualforce so that if a field is added or deleted, It should reflect in Salesforce Visualforce?It can be done with help of Field Sets.
-
shariq
MemberSeptember 22, 2018 at 6:31 PM in reply to: How to get total number of Child records in Salesforce Lookup relationship?As Rollup Summary field is only supported in Master detail, we cannot use it for Lookup. There are following two ways (If anyone has any other idea please comment).
Inline Visualforce page
Trigger on Child Object, which will update field in Parent record if child record is inserted, deleted or undeleted. -
shariq
MemberSeptember 22, 2018 at 6:29 PM in reply to: How to set starting day in Calendar as “Monday” instead of “Sunday” in Salesforce?- Change the user locale to “English ( United Kingdom ) ” in Personal information or User record.
-
shariq
MemberSeptember 22, 2018 at 6:29 PM in reply to: Explain few considerations for @Future annotation in Salesforce Apex.Method must be static
Cannot return anything ( Only Void )
To test @future methods, you should use startTest and stopTest to make it synchromouse inside Test class.
Parameter to @future method can only be primitive or collection of primitive data type.
Cannot be used inside VF in Constructor, Set or Get methods.
@future method cannot call other @future method. -
shariq
MemberSeptember 22, 2018 at 6:28 PM in reply to: Explain Considerations for Static keyword in Salesforce Apex.Apex classes cannot be static.
Static allowed only in outer class.
Static variables not transferred as a part of View State.
Static variables and static block runs in order in which they are written in class.
Static variables are static only in scope of request.