shariq
IndividualForum Replies Created
-
shariq
MemberSeptember 17, 2018 at 10:09 PM in reply to: How to remove single and multi-line comments from a string in Salesforce apex?Hi,
I think you need this -
string str = 'this is test for newline \n this is actual newline.';
system.debug(str.replace('\n',''));or
string str = 'this is test for newline \r this is actual newline.';
system.debug(str.replace('\r',''));Hope this helps.
-
shariq
MemberSeptember 17, 2018 at 10:07 PM in reply to: How to Invoke Rest Service from Visualforce page?Hi,
Usually we make Rest API calls from Salesforce to External systems to get the data or to pass the updates to External Systems, using Apex class. But sometimes we can have a situation, like where we need to make a call to external systems from the visual force page.
Salesforce has introduced a concept called AJAX ToolKit, which help us to make REST API call from the JavaScript in Visualforce Page. Here is an example to invoke REST API from Visualforce Page. In below example I’m using http://fixer.io/ web service HTTP callout and send a GET request to get the foreign exchange rates. The foreign exchange rates service sends the response in JSON format.
<apex:page>
<apex:includeScript value="//code.jquery.com/jquery-1.11.1.min.js" />
<script>
function apiCall() {
//Get a reference to jQuery that we can work with
$j = jQuery.noConflict();
//endpoint URL
var weblink = "https://api.fixer.io/latest?base=USD";$j.ajax({
url: weblink,
type: 'GET', //Type POST or GET
dataType: 'json',
beforeSend: function(request) {
//Add all API Headers here if any
//request.setRequestHeader('Type','Value');
},crossDomain: true,
//If Successfully executed
success: function(result) {
//Response will be stored in result variable in the form of Object.
console.log('Response Result' + result);//Convert JSResponse Object to JSON response
var jsonResp = JSON.stringify(result);
document.getElementById("apiData").innerHTML = jsonResp;
},//If any Error occured
error: function(jqXHR, textStatus, errorThrown) {
//alert('ErrorThrown: ' + errorThrown);
}
});
}
</script>
<apex:form>
<!--call javaScript-->
<input type="button" value="Call API" onclick="apiCall()" />
<div id="apiData">
</div>
</apex:form>
</apex:page>Hope this helps.
-
shariq
MemberSeptember 17, 2018 at 10:02 PM in reply to: What to do when I am getting error while updating debug log trace flag in Salesforce?Hi,
For Longer term, the problem comes back to the Summer'18 update Store Larger Debug Logs with Changed Log Limits:
We increased the size limit for debug logs from 2 MB per log to 5 MB. You can store up to 250 MB of debug logs at a time. System logs are now deleted automatically after 24 hours instead of after seven days. Monitoring logs are still saved for seven days.
This is also compounded with the Winter '18 update Retain More Debug Logs for Longer:We changed the way that we delete old debug logs. We now retain debug logs for 7 days. You can generate a total of 250 MB of debug logs in a 15-minute window. When your org is upgraded to Winter ’18, all logs that are at least 7 days old are deleted. This change applies to both Lightning Experience and Salesforce Classic.
Hope this helps.
-
shariq
MemberSeptember 17, 2018 at 10:00 PM in reply to: What is the difference between apex:pageBlockTable and apex:dataTable in Salesforce?Hi,
Added few points more -
PageBlockTable:
- PageBlockTable should be define inside pageblock or pageblocksection.
- PageBlockTable uses standard styles sheets to design a visualpage.
- It has the required attribute "value".
- Column headers will be displayed automatically.
DataTable:
- No need to write inside pageblock or pageblocksection.
- There is no required value.
- The data can be displayed using custom style sheets.
- we need to specify column headers explicitly.
Hope this helps.
-
shariq
MemberSeptember 17, 2018 at 9:54 PM in reply to: How can you create partial page refreshes in Visualforce?Hi,
You need to use reRender attribute -
Try this -
<apex:actionSupport event=”onclick” reRender=”PageBlockYouWantRefresh”/>
Hope this helps.
-
Hi,
TestVisible - Use the TestVisible annotation to allow test methods to access private or protected members of another class outside the test class. These members include methods, member variables, and inner classes. This annotation enables a more permissive access level for running tests only. This annotation doesn’t change the visibility of members if accessed by non-test classes.
With this annotation, you don’t have to change the access modifiers of your methods and member variables to public if you want to access them in a test method. For example, if a private member variable isn’t supposed to be exposed to external classes but it should be accessible by a test method, you can add the TestVisible annotation to the variable definition.
testSetup - Methods defined with the @testSetup annotation are used for creating common test records that are available for all test methods in the class.
Syntax
Test setup methods are defined in a test class, take no arguments, and return no value. The following is the syntax of a test setup method.@testSetup static void methodName() {
}
Hope this helps.
-
Hi,
I think you need this -
Overloading Web Service Methods. SOAP and WSDL do not provide good support for overloading methods. Consequently, Apex does not allow two methods marked with the webservice keyword to have the same name. Web service methods that have the same name in the same class generate a compile-time error.
Hope this helps. -
Hi,
Try this -
Class code
public class checkRecursive {
public static Set<Id> SetOfIDs = new Set<Id>();
}In order to avoid the situation of recursive call, make sure your trigger is getting executed only one time. To do so, you can create a class with a Static Set
Check if the record exists in the set, if so do not execute the trigger, else execute the trigger.
NOTE: Before deploying into production, we recommend testing in sandbox.
This is a sample code written for Account object Class code
public class checkRecursive {
public static Set<Id> SetOfIDs = new Set<Id>();
}
Trigger code
trigger TestTrigger on Account (before insert) {
if (Trigger.isAfter && Trigger.isInsert) {
List<Account> accList = new List<Account>();
for (Account test: Trigger.new) {
If(!checkRecursive.SetOfIDs.contains(test.Id)){
test.Name = 'helloworld';
accList.add(test);
checkRecursive.SetOfIDs.add(test.Id);
}
}
insert accList;
}
}Hope this helps.
-
shariq
MemberSeptember 17, 2018 at 9:45 PM in reply to: Operation types response in WSDL in salesforceHi,
Each WSDL-based Service exposes a number of operations (conveniently named “operation” in the WSDL) that each have a request and response message format (both optional). In soapUI, the operations for a Service are shown as nodes under the Service node in the project navigator:
For invoking an operation you can add any number of request objects to an operation in the navigator tree. soapUI by default creates a sample request for each operation when importing, as can be seen below:
Hope this helps.
-
Hi,
To get into Basics -
You can expose your Apex classes and methods so that external applications can access your code and your application through the REST architecture.
Hope this helps.
-
shariq
MemberSeptember 17, 2018 at 9:39 PM in reply to: How to get a beep sound in Salesforce Visualforce Page?Hi,
To add more -
There is an App I saw recently, I think its called 'Ring my Bell', which sounds a bell every time an Opportunity is closed. You need to look into the app and see what they use.
Hope this helps.
-
Hi,
To add more -
There is an App I saw recently, I think its called 'Ring my Bell', which sounds a bell every time an Opportunity is closed. You need to look into the app and see what they use.
Hope this helps.
-
Hi,
An On Demand process is special type of application process which has aProcess Point of On Demand and executes when called from a page-level On Demand process or from an Ajax call from the browser
Hope this helps.
-
Hi,
To add more into this -
- AMPscript simply and efficiently handles inline personalization or simple IF ELSE statements.
- AMPscript better handles use cases, where each subscriber needs to see unique content, than SSJS.
- AMPscript has a shorter learning curve than SSJS for users new to scripting languages in general.
- A great deal of people already know JavaScript and can immediately apply that knowledge to Marketing Cloud
- In general, the vast majority of users can handle the tasks they need to perform using AMPscript. Use Core library SSJS functions only to accomplish tasks on landing pages where AMPscript does not provide appropriate functions. Platform SSJS functions can handle messaging tasks as well as landing pages and applications.
Hope this helps.
-
shariq
MemberSeptember 17, 2018 at 9:20 PM in reply to: display more records beyond the supported limit on the VF page in salesforceHi,
Pagination is the best option -
Try this -
Visual Force Page:
<apex:outputLabel ><B>Showing {!pageNum} page out of {!totPages} pages and your viewing from {!index} record to {!pagevalue} out of Total {!totalRecs} </B></apex:outputLabel>
<c:PageBlockTableEnhancerADV targetPbTableIds="mid,mid2" paginate="true" defaultPageSize="600" pageSizeOptions="100,400,600,700,900,1000"/>
<apex:pageblockTable value="{!tempMemb}" var="m" id="mid"><apex:column > <apex:inputText value="{!m.Name}"> </apex:inputText> </apex:column>
<apex:column value="{!m.id}"/>
<apex:column value="{!m.Name}"/></apex:pageblockTable>
<apex:pageblockButtons >
<apex:commandButton value="First" rerender="details" action="{!beginning}" disabled="{!prev}" oncomplete="initPageBlockTableEnhancerADV()"/>
<apex:commandButton value="Prev" rerender="details" action="{!previous}" disabled="{!prev}" oncomplete="initPageBlockTableEnhancerADV()"/>
<apex:commandButton value="Next" rerender="details" action="{!next}" disabled="{!nxt}" oncomplete="initPageBlockTableEnhancerADV()"/>
<apex:commandButton value="Last" rerender="details" action="{!end}" disabled="{!nxt}" oncomplete="initPageBlockTableEnhancerADV()"/>
<apex:commandButton value="Mass Update" reRender="details" action="{!massUpdate}" status="Load" oncomplete="initPageBlockTableEnhancerADV()"/>
</apex:pageblockButtons><apex:actionStatus id="Load"> Loading........</apex:actionStatus>
</apex:pageBlock>
Controller:
public class PaginationCtrl2
{
public integer totalRecs{get;set;}
public integer index {get;set;}
public integer blockSize{get;set;}
public integer pagevalue{get;set;}
public integer pageNum{get;set;}
public integer totPages{get;set;}
public list<review__c> tempMemb{get;set;}public PaginationCtrl2()
{
tempMemb=new List<review__c>();
totalRecs = 0;
index = 0;
pageNum =1;
blockSize = 1000;
pagevalue = 1000;
totalRecs = [select count() from review__c];
totPages = (totalRecs /1000)+1;
gettempMemb();
}public List<review__c> gettempMemb()
{
tempMemb=Database.Query('SELECT id,Name FROM review__c LIMIT :blockSize OFFSET :index');
return tempMemb;
}public void beginning()
{
index = 0;
pagevalue = index +1000;
pageNum =0;gettempMemb();
}public void previous()
{
pagevalue = index;
index = index - blockSize;
pageNum = (pageNum -1)==-1?0:pageNum-1;gettempMemb();
}public void next()
{
index = index + blockSize;
pagevalue = (index +1000)>totalRecs ?totalRecs :(index +1000);
pageNum = (pageNum == totPages || pageNum+1>totPages) ?totPages :pageNum+1;
gettempMemb();
}public void end()
{
index = totalrecs - math.mod(totalRecs,blockSize);
pagevalue = totalRecs-1000;
pageNum = totPages;
gettempMemb();
}public boolean getprev()
{
if(index == 0)
return true;
else
return false;
}public boolean getnxt()
{
if((index + blockSize) > totalRecs)
return true;
else
return false;
}public void massUpdate()
{
update tempMemb;
}
}Hope this helps.
-
shariq
MemberSeptember 17, 2018 at 9:16 PM in reply to: How to use My Domain feature to configure a custom domain in Salesforce?Hi,
I think you need this -
Use My Domain to Create Your Own Subdomain Name
Create your own subdomain to better manage login and authentication for your Salesforce org. A subdomain is also a way to brand your org with your company name.
While you’re learning to use My Domain, don’t perform these steps in your production org. For a good introduction, see the Trailhead module, User Authentication. After you deploy your new domain name, you can’t reverse it without contacting Salesforce Support.Creating a My Domain subdomain helps you better manage login and authentication for your org in several key ways. You can:
- Highlight your business identity with your unique domain URL
- Brand your login screen and customize right-frame content
- Block or redirect page requests that don’t use the new domain name
- Work in multiple Salesforce orgs at the same time
- Set custom login policy to determine how users are authenticated
- Let users log in using a social account, like Google and Facebook, from the login page
- Allow users to log in once to access external services
Hope this helps.
-
shariq
MemberSeptember 17, 2018 at 9:13 PM in reply to: Explain use of Junction Object in Salesforce.Hi,
To be more clear -
You can only create many to many relationship between two objects through third one which is called Junction Object.
Like many products have multiple prices and same price is on multiple products.
Hope this helps.
-
shariq
MemberSeptember 17, 2018 at 9:11 PM in reply to: Why sidebar and showheader attribute have no effect in Salesforce Lightning Experience?Hi,
To be more clear -
showHeader Boolean value that specifies whether the Salesforce tab header is included in the page. If true,
the tab header is displayed. If not specified, this value defaults to true.
Note: In Lightning Experience and Salesforce1 the value of this attribute is overridden, and is always false.Hope this helps.
-
Hi,
To be more clear -
You know you get automatically notified when your device or service goes down. ... On the web the term has become a callback URL because it "calls back" a web address rather than a bit of code.
Hope this helps.
-
Hi,
To add more into this -
By using change sets we can deploy our customizations from one environment to other environments in Salesforce.
Change sets available in Enterprise, performance, unlimited and Database.com editions.
Note: In this post organization/environment means it may be sandbox or production. By using change sets we can deploy code from sandbox to sandbox and also we can deploy Sandbox to production.
Prerequisites to deploy by using change sets
1. A deployment connection between two organizations.
2. Overall test class code coverage should be greater than 75%.
3. Create and upload change sets user permission to create or upload change sets.
Hope this helps.
-
Hi,
To add more -
You can filter your report results many different ways using the report builder. Field filters limit results by
the values of fields in the report. But how do you filter results by related objects? Cross filters work like
ordinary filters, but they have some special characteristics of their own.
Add subfilters to further filter by fields on the child object. For example, if you have a cross filter of
Accounts with Opportunities, click Add Opportunity Filter and create the Opportunity
Name equals ACME subfilter to see just those opportunities. You can create up to five subfilters for
each cross filter.
To change a report filter, hover over it and click Edit or Remove. Your filters display when you run your
report; click Edit on that page to make additional changes.Hope this helps.
-
Hi,
To add more -
In other programming languages, the previous flaw is known as SQL injection. Apex does not use SQL, but uses its own database query language, SOQL. SOQL is much simpler and more limited in functionality than SQL. Therefore, the risks are much lower for SOQL injection than for SQL injection, but the attacks are nearly identical to traditional SQL injection. In summary SQL/SOQL injection involves taking user-supplied input and using those values in a dynamic SOQL query. If the input is not validated, it can include SOQL commands that effectively modify the SOQL statement and trick the application into performing unintended commands.
SOQL Injection Vulnerability in Apex
Below is a simple example of Apex and Visualforce code vulnerable to SOQL injection.<apex:page controller="SOQLController" >
<apex:form>
<apex:outputText value="Enter Name" />
<apex:inputText value="{!name}" />
<apex:commandButton value="Query" action="{!query}“ />
</apex:form>
</apex:page>public class SOQLController {
public String name {
get { return name;}
set { name = value;}
}
public PageReference query() {
String qryString = 'SELECT Id FROM Contact WHERE ' +
'(IsDeleted = false and Name like \'%' + name + '%\')';
queryResult = Database.query(qryString);
return null;
}
}Hope this helps.
-
shariq
MemberSeptember 17, 2018 at 8:46 PM in reply to: How to set the Login hours and Login IP ranges to the users in Salesforce?Hi,
To add more into this -
- How you restrict the range of valid IP addresses on a profile depends on your Salesforce edition.
- If you’re using an Enterprise, Unlimited, Performance, or Developer Edition, from Setup, enter Profiles in the Quick Find box, then select Profiles, and select a profile.
- If you’re using a Group, or Personal Edition, from Setup, enter Session Settings in the Quick Find box, then selectSession Settings.
- In a Professional Edition, the location of IP ranges depends on whether you have the "Edit Profiles & Page Layouts" org preference enabled as an add-on feature.With the "Edit Profiles & Page Layouts" org preference enabled, IP ranges are on individual profiles.Without the "Edit Profiles & Page Layouts" org preference enabled, IP ranges are on the Session Settings page.
- Click New in the Login IP Ranges related list.
- Enter a valid IP address in the IP Start Address field and a higher-numbered IP address in the IP End Address field.The start and end addresses define the range of allowable IP addresses from which users can log in. To allow logins from a single IP address, enter the same address in both fields.
- The IP addresses in a range must be either IPv4 or IPv6. In ranges, IPv4 addresses exist in the IPv4-mapped IPv6 address space ::ffff:0:0 to ::ffff:ffff:ffff, where ::ffff:0:0 is 0.0.0.0 and ::ffff:ffff:ffff is 255.255.255.255. A range can’t include IP addresses both inside and outside of the IPv4-mapped IPv6 address space. Ranges like 255.255.255.255 to ::1:0:0:0 or :: to ::1:0:0:0 aren’t allowed.
- Partner User profiles are limited to five IP addresses. To increase this limit, contact Salesforce.
- Optionally enter a description for the range. If you maintain multiple ranges, use the Description field to provide details, such as which part of your network corresponds to this range.
- Click Save
Hope this helps.
- How you restrict the range of valid IP addresses on a profile depends on your Salesforce edition.
-
shariq
MemberSeptember 17, 2018 at 8:41 PM in reply to: How to add javascript remoting to a Salesforce visualforce page?Hi,
Try this -
Apex code -
global with sharing class AccountRemoter {
public String accountName { get; set; }
public static Account account { get; set; }
public AccountRemoter() { } // empty constructor@RemoteAction
global static Account getAccount(String accountName) {
account = [SELECT Id, Name, Phone, Type, NumberOfEmployees
FROM Account WHERE Name = :accountName];
return account;
}
}Visualforce page -
<apex:page controller="AccountRemoter">
<script type="text/javascript">
function getRemoteAccount() {
var accountName = document.getElementById('acctSearch').value;Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.AccountRemoter.getAccount}',
accountName,
function(result, event){
if (event.status) {
// Get DOM IDs for HTML and Visualforce elements like this
document.getElementById('remoteAcctId').innerHTML = result.Id
document.getElementById(
"{!$Component.block.blockSection.secondItem.acctNumEmployees}"
).innerHTML = result.NumberOfEmployees;
} else if (event.type === 'exception') {
document.getElementById("responseErrors").innerHTML =
event.message + "<br/>\n<pre>" + event.where + "</pre>";
} else {
document.getElementById("responseErrors").innerHTML = event.message;
}
},
{escape: true}
);
}
</script><input id="acctSearch" type="text"/>
<button onclick="getRemoteAccount()">Get Account</button>
<div id="responseErrors"></div><apex:pageBlock id="block">
<apex:pageBlockSection id="blockSection" columns="2">
<apex:pageBlockSectionItem id="firstItem">
<span id="remoteAcctId"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem id="secondItem">
<apex:outputText id="acctNumEmployees"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>JavaScript remoting is a tool that front-end developers can use to make an AJAX request from a Visualforce page directly to an Apex controller. JavaScript remoting allows you to run asynchronous actions by decoupling the page from the controller and to perform tasks on the page without having to reload the entire page.
Hope this helps.
-
Hi,
To add more about Process builder -
Using Lightning Process builder you can make the record automatically submit to the approval process whenever it meets the criteria.
- Go to setup->Create->Workflow & Approval->Process builder
- Then select the object to which you want to perform the auto-approval submission
- Enter the criteria for the record
- In the set Action select 'Submit for Approval'
Hope this helps.

