shariq
IndividualForum Replies Created
-
shariq
MemberSeptember 22, 2018 at 6:05 PM in reply to: How we can check API limits already used in any organization by using REST or SOAP API in Salesforce?SOAP API and REST API always returns header after making successful call to Salesforce.
Sample Responses:
SOAP:
<soapenv:Header>
<LimitInfoHeader>
<limitInfo>
<current>45</current>
<limit>5000</limit>
<type>API REQUESTS</type>
</limitInfo>
</LimitInfoHeader>
</soapenv:Header>REST:
Sforce-Limit-Info: api-usage=45/5000
-
shariq
MemberSeptember 22, 2018 at 6:04 PM in reply to: How to display more than 1000 records in repeater or PageBlockTable component of Salesforce Visualforce ?If circumstances permits, we can use readOnly attribute available at apex page level
-
shariq
MemberSeptember 22, 2018 at 6:03 PM in reply to: How many record can be displayed in repeater or PageBlockTable in Salesforce Visualforce?current limit is 1000 records.
-
shariq
MemberSeptember 22, 2018 at 6:03 PM in reply to: How to disable Header ribbon in Salesforce Organization where Community is enabled ?In Profile “View Global Header” controls the visibility of Black ribbon which is used to switch between the community.
-
shariq
MemberSeptember 22, 2018 at 6:02 PM in reply to: How can you update Salesforce record using Apex, when you don’t know Object API name, but you know record Id?Using Dynamic Apex we can achieve this :
//Lets assume this is record Id
Id recId = 'a0P9000000ESXcV';
Schema.SObjectType token = recId.getSObjectType();
Sobject s = token.newSobject();
s.put('Id',recId );
s.put('Name', 'om');
update s; -
shariq
MemberSeptember 22, 2018 at 6:01 PM in reply to: What is best practice to refer dynamic custom messages in Salesforce Visualforce with multi-language support?Using Custom Label or OutputField or InputField tag, Platform itself will take care of internationalization. However in some cases, Message needs to be dynamic at the same time it should also support muti-language. In Custom Label, we cannot save dynamic String.
Let’s assume we want to show message something like “DEVELOPERNAME is not authorized to access this page”.
Here, Developername should be dynamically changed in visualforce which supports multilanguage. For each developername, it is not feasible to create custom labels. So below workaround can be used :Step 1 : Create a Custom Label with text “{0} is not authorized to access this page“. In every language, dynamic value should represented by {0}.
Step 2 : In Controller of Visualforce write something like this :
1
String developerName = 'Some DeveloperName';
2
String message = String.format(Label.DEVELOPERNA, new String[] { developerName }); -
shariq
MemberSeptember 22, 2018 at 6:01 PM in reply to: A Custom Object named “Training__c” has field “Trainer__c”. You have set some default value in that field. Will that default value apply to new record created by Salesforce apex code ?After API 20, it should automatically populate However there is known issue for same here, click here if it impacts you.
Workaround :
If Default value of field is not getting populated by Apex then we have to use “Dynamic Apex”. Create instance of object from sObjectType like shown below:view source
print?
1
Training__c tr= (Training__c) Training__c.sObjectType.newSObject(null, true);
23
//Check if Value in field "Trainer__c" is default value
4
System.assertEquals('Jitendra', tr.Trainer__c); -
shariq
MemberSeptember 22, 2018 at 5:09 PM in reply to: Is it possible to use other frameworks like AngularJs or KendoUI with Salesforce Lightning Components?Yes
-
They’re a mechanism for using custom-built components to replace existing components in the Salesforce1 Mobile App. This functionality is currently in Pilot.
-
shariq
MemberSeptember 22, 2018 at 5:08 PM in reply to: Can you show Salesforce Lightning components tab in Mobile as well in desktop?Currently you can only use Lightning Components in the Salesforce1 Mobile App or a standalone app.
-
shariq
MemberSeptember 22, 2018 at 5:06 PM in reply to: How to create Chatter post from Salesforce Apex?//Adding a Text post
FeedItem post = new FeedItem();
post.ParentId = oId; //eg. Opportunity id, custom object id..
post.Body = 'Enter post text here';
insert post;//Adding a Link post
FeedItem post = new FeedItem();
post.ParentId = oId; //eg. Opportunity id, custom object id..
post.Body = 'Enter post text here';
post.LinkUrl = 'http://www.someurl.com';
insert post;//Adding a Content post
FeedItem post = new FeedItem();
post.ParentId = oId; //eg. Opportunity id, custom object id..
post.Body = 'Enter post text here';
post.ContentData = base64EncodedFileData;
post.ContentFileName = 'sample.pdf';
insert post; -
shariq
MemberSeptember 22, 2018 at 5:05 PM in reply to: How to use standard Salesforce REST API from Salesforce Visualforce Page?Befor any Ajax call, make sure to add ‘Bearer’ token in header. If using JQuery use below code snippet.
$.ajax({
type: reqType,
beforeSend: function (xhr)
{
xhr.setRequestHeader("Authorization", 'Bearer {!$API.Session_ID}');},
headers : {'Content-Type' : 'application/json; charset=utf-8'},
url: postUrl,
data: postData,
dataType: 'text'
})
.done(function( data ) {
//Code if success
})
.fail(function(xhr,textstatus,error){
//Code if fail
}); -
shariq
MemberSeptember 22, 2018 at 5:04 PM in reply to: How to query and abort scheduled job using Salesforce Apex?While updating class on Sandboxes, chances are high that it is being used in any scheduler, so below code will abort all scheduled job. If there are 150+ scheduled job, then you might want to use below code again and again in developer console until all jobs are removed from system.
//Limit is 150 because System.abortJob counted against DML
List<CronTrigger> abort_job = [SELECT Id FROM CronTrigger WHERE State != 'Deleted' limit 150];
for (CronTrigger t : abort_job) { //for each record
//try catch - to make sure one fail should not impact other jobs which needs to be cancelled
try{
System.abortJob(t.Id); //abort the job
}catch(Exception e){}}
-
shariq
MemberSeptember 22, 2018 at 5:03 PM in reply to: How to return Map result from SOQL query in Salesforce Apex?Map<ID, Contact> m = new Map<ID, Contact>([SELECT Id, LastName FROM Contact]);
-
shariq
MemberSeptember 22, 2018 at 5:03 PM in reply to: Autogenerated Salesforce Id consist of colon, how to handle it in JQuery ?var ele = $('[id="abc:xyz"]');
-
shariq
MemberSeptember 22, 2018 at 5:02 PM in reply to: How to get element id of Salesforce Visualforce Components to be used in Javascript?{!$Component.Parent1.Parent2.fieldId}
-
shariq
MemberSeptember 22, 2018 at 5:02 PM in reply to: How to refer static resources in Salesforce Visualforce?CSS file
<apex:stylesheet value="{!URLFOR($Resource.style_resources, 'styles.css')}"/>
-
shariq
MemberSeptember 22, 2018 at 5:01 PM in reply to: How to get Salesforce Visualforce page output as JSON?<apex:page controller="ControllerName" contentType="application/x-JavaScript; charset=utf-8" showHeader="false" standardStylesheets="false" sidebar="false">
{!jsonString}
</apex:page> -
shariq
MemberSeptember 22, 2018 at 5:00 PM in reply to: How to declare Salesforce Visualforce Page as HTML5?<apex:page docType="html-5.0" />
-
shariq
MemberSeptember 22, 2018 at 5:00 PM in reply to: What are Common Salesforce Apex Page Attributes?<apex:page sidebar="false" standardStylesheets="false" showHeader="false">
-
shariq
MemberSeptember 22, 2018 at 4:59 PM in reply to: Which component in Salesforce ends with “__mdt” and “__s”?Custom metadata types ends with “__mdt” (meta data type), just like custom object or custom fields ends with “__c”.
-
shariq
MemberSeptember 22, 2018 at 4:58 PM in reply to: What is custom metadata type in Salesforce?Custom metadata was introduced generally in Summer 15 release. Before Custom metadata type, we were using Custom settings of List type. Problem with custom setting was that, during migration or in packages, data were not migrated. We had to either use data loader or some API to create initial data. However, if we package custom metadata type or migrate it, data will also be migrated along with it
-
shariq
MemberSeptember 22, 2018 at 4:58 PM in reply to: What causes Concurrent Apex limit error in Salesforce?If Synchronous Apex runs more than 5 sec it considered as long running job. And we have limit that only 10 long running job can execute at a time. So, whenever 11th Synchronous apex tries to execute, it gets Concurrent Apex limit error
-
shariq
MemberSeptember 22, 2018 at 4:57 PM in reply to: How to capture errors after using Database DML methods in Salesforce?List<Contact> lstContact = new List<Contact>();
Contact con = new Contact (lastName = 'Zaa', SQL_Server_Id__c='3',firstName='Jitendra');
lstContact.add(con);
//.. Other Contact records added in List
Database.UpsertResult[] results = Database.upsert( lstSGAccOppInsert, Contact.SQL_Server_Id__c.getDescribe().getSObjectField() ,false ) ;for(Integer i=0;i<results.size();i++){
if (!results.get(i).isSuccess()){
Database.Error err = results.get(i).getErrors().get(0);
System.debug('Error - '+err.getMessage() + '\nStatus Code : '+err.getStatusCode()+'\n Fields : '+err.getFields());
}
} -
shariq
MemberSeptember 22, 2018 at 4:57 PM in reply to: Difference between Chatter API and Connect API in Salesforce?Chatter API is REST API for Chatter to display Salesforce data, especially in mobile applications. Responses are localized, structured for presentation, and can be filtered to contain only what the app needs.
Connect API provides apex classes for accessing the same data available in Chatter REST API. Use Chatter in Apex to create custom Chatter experiences in Salesforce.