Manpreet Singh
IndividualForum Replies Created
-
Manpreet
MemberMay 2, 2017 at 1:47 pm in reply to: How to show Images in a Salesforce Visualforce Page by using RichTextField ?Hi suraj,
You can display them on vf Page by using
<apex:repeat value="{!Products}" var="prodLst">
<div id="prodDiv"><div id="textData">
<h1>{!prodLst.Name}</h1>
<div style="margin-top: 12px;">
</div>
<div class="image"><apex:outputField value="{!prodLst.Images__c}" /></div>
</div>
</apex:repeat>Thanks.
-
Manpreet
MemberMay 2, 2017 at 1:45 pm in reply to: How can i access variable in a Salesforce visualforce page defined in wrapper class?Hi suraj,
You can do this by iterating the wrapper list in the visualforce page and then accessing variables using (.) dot notation.Something Like this:
/**WRAPPER**/
public class productsList2_wrapper{
public product2 prdt2{get;set;}
public integer quantity {get;set;}public productsList2_wrapper(product2 product){
prdt2 = product;
quantity = 0;
}
}public List<productsList2_wrapper> getProducts(){
productsWrapperList = new List<productsList2_wrapper>();
for(product2 prdtObj : [SELECT Name,Images__c FROM Product2 LIMIT 10]){
//Addition to List
productsWrapperList.add(new productsList2_wrapper(prdtObj));
}
return productsWrapperList;
}VF Page :
<div class="tableRepeat">
<apex:repeat value="{!productsList}" var="prodLstInCart" >
<div>
<div class="CartProdRecords">
<div style="position: absolute;">{!prodLstInCart.prdt2.Name} </div>
<div class="quantityInCart"> {!prodLstInCart.quantity} </div>
<div class="deleteProdsInCart">
<input type="button" id="deleteProdsInCart" value="x" onclick="deleteProdsInCartCall('{!prodLstInCart.prdt2.Id}')" />
</div>
</div>
</div>
</apex:repeat>Thanks.
-
Manpreet
MemberApril 28, 2017 at 1:28 pm in reply to: Is it possible to write a validation rule on record delete in salesforce?Hi saurabh,
Validation rule is not work for prevents deletion of record. You can use trigger for Prevent deletion record.Validation rules will only work if there is a record to determine if the formula evaluates to true.
Thanks.
-
Manpreet
MemberApril 28, 2017 at 1:26 pm in reply to: What are various standard exceptions that salesforce throws?Hi saurabh,
Standard exceptions that salesforce throws :
DmlException
ListException
NullPointerException
QueryException
SObjectException
You can use common exception methods to get more information about an exception, such as the exception error message or the stack trace. The previous example calls the getMessage method, which returns the error message associated with the exception. There are other exception methods that are also available. Here are descriptions of some useful methods:
getCause: Returns the cause of the exception as an exception object.
getLineNumber: Returns the line number from where the exception was thrown.
getMessage: Returns the error message that displays for the user.
getStackTraceString: Returns the stack trace as a string.
getTypeName: Returns the type of exception, such as DmlException, ListException, MathException, and so on.Thanks
-
Manpreet
MemberApril 28, 2017 at 1:23 pm in reply to: What is the use of Test.setPage() in Salesforce?Hi Saurabh,
Test.setPage() method in Salesforce is used to set the context to current page, normally used for testing the Visualforce controller in test classes.
Thanks.
-
Manpreet
MemberApril 28, 2017 at 1:22 pm in reply to: What are differences between custom settings and custom objects in Salesforce?Hi saurabh,
Custom object is a record table and Custom setting is a configurations table. Custom object is like any Database table that we used to have in SQL or in any other database. CustomSetting is like configuration file that we used to have. Even though List type of custom setting looks like that it is also a custom object but there are differences. LIke in custom settings there is a limit on no of records, you can not write trigger, workflow etc on custom setting.
I hope this will help you.
for more information Click here
Thanks.
-
Manpreet
MemberApril 28, 2017 at 1:20 pm in reply to: How to get all the required fields of sObject dynamically in Salesforce?Hi saurabh,
There is no direct property available in Apex dynamic API to represent the required field. However there is another way to know about it.
If any field have below three properties then it is mandatory field.
If it is Creatable
If it is not nillable and
If it does not have any default value
Map<String, Schema.SObjectType> m = Schema.getGlobalDescribe() ;
Schema.SObjectType s = m.get(so.apiName) ;
Schema.DescribeSObjectResult r = s.getDescribe() ;
Map<String,Schema.SObjectField> fields = r.fields.getMap() ;
List<String> lstrequiredfields=new List<String>();for(String f : fields.keyset())
{
Schema.DescribeFieldResult desribeResult = fields.get(f).getDescribe();
if( desribeResult.isCreateable() && !desribeResult.isNillable() && !desribeResult.isDefaultedOnCreate() )
{
//This is mandatory / required field
lstrequiredfields.add(f);}
}Thanks.
-
Manpreet
MemberApril 27, 2017 at 1:45 pm in reply to: What is the order of execution of automation processes that are available in Salesforce?Hi Suraj,
Below is the order of execution of automation processes:
# System Validation Rules.
# Before triggers.
# Custom Validation rules.
# After triggers.
# Assignment rules.
# Auto-response rules.
# Workflow rules.
# Escalation rules.
# Roll-up summary
# Executes Criteria Based Sharing evaluation.
# Commits all DML operations to the database.
# Executes post-commit logic. Ex: Sending email.
Thanks.
-
Hi Suraj,
Put the call to the future method inside startTest/stopTest:
Test.startTest();myClass.futuremethod( someID );
Test.stopTest();
Test.stopTest() does not return until your future method has completed.Thanks!
-
Manpreet
MemberApril 27, 2017 at 1:40 pm in reply to: i want to count how many times execute method executed in Batch class?Hi Saurabh,
Hi,
the start method excutes once, at the begining.
For the execute method, it depends on you.
You can launch it through an Apex command :
Database.executeBatch(new nameOfYourBatchClass(optionalParamInConstructor), 1);
Here, the second param in the executeBatch method (the value 1) is the scope ; it means you want the batch to handle the elements 1 by 1.
For instance, if the batch has to deal with 10 elements, the execute method will executes 10 times.Thanks.
-
Hi suraj,
A message digest is a cryptographic hash function containing a string of digits created by a one-way hashing formula.
Message digests are designed to protect the integrity of a piece of data or media to detect changes and alterations to any part of a message. They are a type of cryptography utilizing hash values that can warn the copyright owner of any modifications applied to their work.
Message digest hash numbers represent specific files containing the protected works. One message digest is assigned to particular data content. It can reference a change made deliberately or accidentally, but it prompts the owner to identify the modification as well as the individual(s) making the change. Message digests are algorithmic numbers.
This term is also known as a hash value and sometimes as a checksum.
Thanks.
-
Manpreet
MemberApril 26, 2017 at 1:32 pm in reply to: How to Remove/Delete "Domain Name" from Salesforce org?Hi Suraj,
You can’t delete a domain that is attached to a published site. You’ll need to unpublish all sites attached to the domain before you can delete it. For Force.com sites, the domain is deleted immediately, and users no longer have access to any site connected to that domain. But with Site.com sites, the domain remains active until you republish the site.
To delete a domain from your organization:
From Setup, enter Domains in the Quick Find box, then select Domains.
Click Del next to the domain name.
Click OK.
When you delete a domain with an unpublished site attached, it also deletes the custom URL associated with that site.Thanks.
-
Hi Suraj,
You can use OpportunityLineItem to traverse from Opportunity to PricebookEntry and Product..something like this query :
SELECT Id, Name, Account.Name, (SELECT Quantity, UnitPrice, TotalPrice, PricebookEntry.Name, PricebookEntry.Product2.Family FROM OpportunityLineItems) FROM Opportunity WHERE Id = :YourOppId
Thanks.
-
Hi Suraj,
Callouts cannot be made from triggers as that would hold up the database transaction until the callout completed, which can be up to 120 seconds from a limits perspective. This could obviously cause significant contention with other transactions and impact performance.
The only way that you can execute a callout from a trigger is to schedule it to run asynchronously, for example by executing a method with the @future method as you have found. The key word here is asynchronously - you can't wait for a response from the callout as that would require the transaction to stall until it completes, which is the reason that synchronous callouts aren't allowed.
Thanks.
-
Hi Suraj,
You can write a Batch Class and then Schedule it with the help of a scheduler.Let me explain it to you with the help of an example:
BATCH CLASS :
global class test_BATCH implements Database.Batchable<sObject> {
global (Database.QueryLocator | Iterable<sObject>) start(Database.BatchableContext BC) {String query = 'SELECT Id,Name FROM Account';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope) {
for(Account a : scope){
a.Name = a.Name + 'Updated';
}
update scope;
}
global void finish(Database.BatchableContext BC) {
}
}SCHEDULABLE CLASS :
global class scheduledBatchable implements Schedulable{
global void execute(SchedulableContext sc) {test_BATCH b = new test_BATCH();
//Parameters of ExecuteBatch(context,BatchSize) database.executebatch(b,10);}
}
***Note: if batch size is not mentioned it is 200 by default.
CUSTOM TIMING
String time = '0 0 * * * ?';SheduledBatchable sch = new scheduledBatchable();
system.schedule('Hourly Example Batch Schedule job', time, sch);
*****If you want to run it as frequent as 15,30 or N mins .....
String time = '0 15 * * * ?' ;String time = '0 30 * * * ?' ;
Thanks.
-
Manpreet
MemberApril 26, 2017 at 1:10 pm in reply to: Is there any Payment Gateway which I can use/test free?Hi suraj,
In India PayU Payment Gateway is providing free payment gateway. For PayU Money is zero setup fees and zero annual maintenance cost along with the flat TDR of 2.9% for credit card, debit card and net banking.
Also PayU money is allowing start-ups and small enterprises to get a payment gateway with savings account with minimum documentation and quick activation.
Thanks.
-
Manpreet
MemberApril 25, 2017 at 1:36 pm in reply to: How many method as future annotation can i use in apex?Hi suraj,
The maximum number of future method invocations per a 24-hour period is 250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater.
Thanks.
-
Manpreet
MemberApril 25, 2017 at 1:32 pm in reply to: What is the difference between apex:pageMessages, apex:pageMessage, apex:Message and apex:Messages in salesforce?Hi saurabh,
<apex:message>
A message for a specific component, such as a warning or error. If an or component is not included in a page, most warning and error messages are only shown in the debug log. - http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_message.htm
<apex:messages>
All messages that were generated for all components on the current page. If an or component is not included in a page, most warning and error messages are only shown in the debug log. - http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_messages.htm
<apex:pageMessage>
This component should be used for presenting custom messages in the page using the Salesforce pattern for errors, warnings and other types of messages for a given severity. See also the pageMessages component. - http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_pageMessage.htm
<apex:pageMessages>
This component displays all messages that were generated for all components on the current page, presented using the Salesforce styling. - http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_pageMessages.htm
For understanding more refer to this link : http://sfdchackathon.blogspot.in/2015/06/difference-between-and.html
Thanks.
-
Manpreet
MemberApril 25, 2017 at 1:29 pm in reply to: Unable to change field value of Object in After Update Trigger?Hi suraj,
We cannot use After trigger, if we want to update a record because it causes read only error. This is because after inserting or updating, we cannot update a record.You can not make changes after an update because the record has already been updated.For example : You cannot update the contact fields in After trigger.Instead use before insert,before update.
Thanks.
-
Manpreet
MemberApril 25, 2017 at 1:20 pm in reply to: what is use of ActionRegion in VF page in salesforce??Hi Saurabh,
<apex:actionRegion> is used to achieve AJAX functionality to partial page refresh.
Action region is one of the most important tags which helps in increasing page performance. So we should try to make maximum use of action region in visual force page.
actionRegion component only defines which components the server processes during a request; it does not define which of the page are re-rendered when the request completes. We will still use reRender attribute on action component to decide area which should be rerendered AJAX request completes.One more important point to note is that even when we use <apex:actionRegion> component, the whole form is still submitted, but the only area which is inside actionRegion is processed by the server.
One more important point to note is that by passing the validation rules using Action Region.For further, you can refer to this.
Thanks.
-
Manpreet
MemberApril 25, 2017 at 1:14 pm in reply to: What is Database.AllowsCallouts in Salesforce?Hi saurabh,
Database.AllowCallouts are used to allow Callouts in batch Apex, "Callouts include HTTP requests as well as methods defined with the webService keyword". To use a callout in batch Apex, specify Database.AllowsCallouts in the class definition. For example:
global class SearchAndReplace implements Database.Batchable<sObject>, Database.AllowsCallouts{
}For further details refer to this link :
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htmThanks.
-
Manpreet
MemberApril 24, 2017 at 1:21 pm in reply to: What are the aggregate functions supported by salesforce SOQL?Hi saurabh,
Use aggregate functions in a GROUP BY clause in SOQL queries to generate reports for analysis. Aggregate functions include AVG(), COUNT(), MIN(), MAX(), SUM(), and more.
You can also use aggregate functions without using a GROUP BY clause. For example, you could use the AVG() aggregate function to find the average Amount for all your opportunities.For further Detail Refer to this link.
Thanks.
-
Manpreet
MemberApril 24, 2017 at 1:14 pm in reply to: How to hide the “App Setup” Menu from user’s setup page in salesforce?Hi Saurabh,
Yes you can by User Profile. Navigate to
Manage Users -> Profiles and for each profile you want change, go to System Permissions and uncheck the very last one on the page: View the App Setup and Administrative Settings pages.
Thanks.
-
Manpreet
MemberApril 24, 2017 at 1:13 pm in reply to: How to read the parameter value from the URL in Apex?Hi Suraj,
If you have ID Parameter in URL then try this Apex Code :
public Id oppid{get;set;}
Id id = apexpages.currentpage().getparameters().get('id');Moreover , If you want to read parameter in Visualforce the write in visualforce page :
<apex:inputField value="{!$CurrentPage.parameters.Paramtervalue}"/>Thanks.
-
Hi Suraj,
To schedule an Apex class to run at regular intervals, first write an Apex class that implements the Salesforce-provided interface Schedulable.
The scheduler runs as system: all classes are executed, whether the user has permission to execute the class or not. For more information on setting class permissions, see “Apex Class Security Overview” in the Salesforce online help.
To monitor or stop the execution of a scheduled Apex job using the Salesforce user interface, go to Setup --> Monitoring --> Scheduled Jobs. For more information, see “Monitoring Scheduled Jobs” in the Salesforce online help.
The Schedulable interface contains one method that must be implemented, execute.
global void execute(SchedulableContext sc){}
Example:
global class scheduledAccountUpdate implements Schedulable {
global void execute(SchedulableContext SC) {
AccountUpdate acc = new AccountUpdate('Description','Updated Account');
}
}Thanks.