Parul
IndividualForum Replies Created
-
Parul
MemberSeptember 19, 2018 at 11:37 pm in reply to: Move Custom Javascript Buttons to Salesforce1Hi,
Salesforce1 doesn't support custom buttons, but you might consider moving that button's functionality to a Publisher Action, which is supported in both the web GUI and in Salesforce1. (This is assuming your custom button is a detail button.)
Hope this helps.
-
Parul
MemberSeptember 19, 2018 at 11:36 pm in reply to: Insufficient Privileges Error - Partially Rendering Visualforce pageHello Ajit,
I replicated this and found out the following:
Instead of:
<apex:param value="{a.ID}" name="aID"/>
You need:<apex:param value="{!a.ID}" name="aID"/>
The line of code is missing a '!', which makes the page parameter be '{a.ID}' instead of the actual Id. Then SFDC reports that you don't have privileges for the Account with Id '{a.ID}', which is confusing but makes sense.Hope this helps.
-
Hi,
// Query the accounts to lock
Account[] accts = [SELECT Id from Account WHERE Name LIKE 'Acme%'];
// Lock the accounts
Approval.LockResult[] lrList = Approval.lock(accts, false);// Iterate through each returned result
for(Approval.LockResult lr : lrList) {
if (lr.isSuccess()) {
// Operation was successful, so get the ID of the record that was processed
System.debug('Successfully locked account with ID: ' + lr.getId());
}
else {
// Operation failed, so get all errors
for(Database.Error err : lr.getErrors()) {
System.debug('The following error has occurred.');
System.debug(err.getStatusCode() + ': ' + err.getMessage());
System.debug('Account fields that affected this error: ' + err.getFields());
}
}
}Hope this helps.
-
Parul
MemberSeptember 19, 2018 at 9:25 pm in reply to: Is it possible to make a cross filter report of Products?Hi,
So you will only be able to create reports with cross filter feature only for objects that are related to product objects.
Now if you find that there is a relationship and you still not able to see the cross filter report, and this most probably be happening in custom reports,
Thanks
-
Parul
MemberSeptember 19, 2018 at 9:24 pm in reply to: “Unexpected token ‘{ “ error on creating a Javascript button on OpportunityHi,
To add suggestion: Javascript is case sensitive.. So make sure the keywords you have used in the logic.
Thanks.
-
Parul
MemberSeptember 19, 2018 at 9:20 pm in reply to: How to execute Apex from Custom button or Javascript?Hi,
global class MyClass
{
webservice static void myMethod() // you can pass parameters
{
// Do something
}
}Now create a custom button:
Goto --> Setup --> Object --> Buttons, links and Actions section-->Click New Button or Link.
Enter the Name of the button
Behaviour : Execute Javascript
Content source : On-Click Javascriptuse below JS:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}if({!Account__c.Name}!=Null)
{
sforce.apex.execute("SampleClass","sampleMethod",{}"});
alert("This is {!Account__c.Name}");
}Thanks
-
Hello Shubham,
You can Try adding this code to your trigger.
trigger checkEmail on Contact (before insert,after insert,before update) {
List<Contact> conList = [select Email,Type__c from contact];
Integer counter = 0;
for(Contact conToInsert : Trigger.New)
for(Contact conToInsert1 : Trigger.New){
if(conToInsert.Email == conToInsert1.Email)
conToDelete.add(conToInsert);
counter++;
if(counter>1)
conToInsert.addError(‘Same Email Found Cannot Insert’);
}for(Contact conToInsert : Trigger.New){
for(Contact conToCompare : conList){
if(conToInsert.Type__c == ‘Type 4’ ){
conToInsert.addError(‘Contact Cannot be Type 4’);
}
else{
if(conToInsert.Email != null){
if(conToInsert.Email == conToCompare.Email){
conToInsert.addError(‘Same Email Found Cannot Insert’);
}
}}
}
}}
I hope this will help you.
-
Hi,
I used below logic for my same requirement:
public class Wrapper
{
public String FirstName {get; set;}
public String MiddleName {get; set;}
public String LastName {get; set;}
public String Email {get; set;}public String FirstNameError {get; set;}
public String MiddleNameError {get; set;}
public String LastNameError {get; set;}
public String EmailError {get; set;}public Wrapper()
{
FirstNameError='';
MiddleNameError='';
LastNameError='';
EmailError='';
}
}Validation in save method is:-
for (Wrapper wrap : wrappers)
{
if ( ((null==wrap.FirstName) || (wrap.FirstName.trim().length()==0)) &&
((null==wrap.MiddleName) || (wrap.MiddleName.trim().length()==0)) )
{
wrap.FirstNameError='Either first name or middle name must be defined';
wrap.MiddleNameError='Either first name or middle name must be defined';
}
}And in visualforce page:-
<apex:column headerValue="First Name">
<apex:inputText value="{!wrapper.FirstName}" rendered="{!LEN(wrapper.FirstNameError)==0}"/>
<apex:outputPanel rendered="{!LEN(wrapper.FirstNameError)!=0}">
<apex:inputText styleClass="error" value="{!wrapper.FirstName}"/>
<div class="errorMsg"><strong>Error:</strong> {!wrapper.FirstNameError}</div>
</apex:outputPanel>
</apex:column>Hope this helps.
Thanks.
-
Parul
MemberSeptember 19, 2018 at 9:11 pm in reply to: Refresh parent after child action on inline Visualforce PageHi Abhinav,
Apex Class:-
public class Opp_Ext {
private ApexPages.StandardController stdController;
public String redirectUrl {public get; private set;}
public Boolean shouldRedirect {public get; private set;}public Opp_Ext(ApexPages.StandardController stdController) {
this.stdController = stdController;
shouldRedirect = false;
}public PageReference doStuffAndRedirect() {
shouldRedirect = true;
redirectUrl = stdController.view().getUrl();
return null;
}
}Visualforce Page:-
<apex:page standardController="Opportunity" extensions="Opp_Ext" >
<apex:form >
<apex:commandButton value="Do Stuff" action="{!doStuffAndRedirect}" rerender="redirectPanel" />
<apex:outputPanel id="redirectPanel" >
<apex:outputText rendered="{!shouldRedirect}">
<script type="text/javascript">
window.top.location.href = '{!redirectUrl}';
</script>
</apex:outputText>
</apex:outputPanel>
</apex:form>
</apex:page>Hope this helps.
-
Parul
MemberSeptember 19, 2018 at 9:08 pm in reply to: Is it possible to call javascript function in an apex controller?Hi,
Try it
<apex:page controller="calljavascript_cls" >
<script>
function func()
{
alert('function calling');
}
</script>
<apex:outputText value="{!callfunc}" escape="false"></apex:outputText>
</apex:page>
-------- apex class --------------
public class calljavascript_cls
{
public string callfunc{get;set;}
public calljavascript_cls()
{
callfunc='<script> func(); </script>';
}
}
Hope this helps.
Thanks.
-
Parul
MemberSeptember 19, 2018 at 9:07 pm in reply to: Exporting records from Dataloader using like operatorHi,
You can use like this:
SELECT Id
FROM Tasks
WHERE (Subject LIKE '%Rocket%') OR (Subject LIKE '%Genius%')Thanks.
-
Parul
MemberSeptember 19, 2018 at 9:04 pm in reply to: What is the best way to pass parameters from one visualforce page to another?Hi,
When you want to pass parameters between visualforce pages use the <apex:param> tag.
Be careful with the values you pass in the URL.. Special Characters will cause problems
when passed in the URL.. For ex if you pass the Account Name "Shah & shah".. this would'nt
pass properly as the special character "&" can't get into the URL..
So as a best practice always pass ID's.. you could write a query and retrieve any other field
in the APEX Class.Thanks.
-
Parul
MemberSeptember 19, 2018 at 7:06 pm in reply to: Difference between lightning component and visualforce component in Salesforce?Adding some points:
Visualforce components are page-centric and most of the work is done on the server.
Lightning is designed from the component up, rather than having the concept of a page as its fundamental unit. Lightning Components are client-side centric, which makes them more dynamic and mobile friendly.
Thanks
-
Parul
MemberSeptember 19, 2018 at 7:01 pm in reply to: How to lock record using SOQL in Salesforce?use this trigger to lock the record:
Ex:
trigger OppTrigger on Opportunity (after insert, before update) {
Map<String, Id> typeMap = New Map<ID,RecordType>();
for(RecordType rt: [Select ID, DeveloperName From RecordType Where sObjectType = 'Opportunity']) {
typeMap.put(rt.DeveloperName, rt.id);
}
for (Opportunity opp : trigger.new) {
// And the Agreement Category on the record = TEST
if (opp.Stage__c == 'Negotiation/Review') {
// Then automatically change the Record Type to ReadOnly RecordType
opp.RecordTypeID = typeMap.get('ReadOnly}
}
}
Thanks
-
Parul
MemberSeptember 19, 2018 at 6:30 pm in reply to: What is the governor limits of sub query in SOQL?Adding some points:
In a SOQL query with parent-child relationship sub-queries, each parent-child relationship counts as an additional query. These types of queries have a limit of three times the number for top-level queries.
The row counts from these relationship queries contribute to the row counts of the overall code execution.
In addition to static SOQL statements, calls to the following methods count against the number of SOQL statements issued in a request.
Database.countQuery
Database.getQueryLocator
Database.query
From above statement i can clarify one point:For example your org contain only 2 Account and each have 10 Contacts.
If you execute this with sub Query like below
Select Id, Name, (Select Id, Name from Contacts) From Account
Then the total number of Query rows will be 22 (2+10+10).
From above analogy we can understand like this
If your org contain 40M accounts and each have 1 contact.
Then in this scenario you can use sub query up to 25M only.
Like this Select Id, Name, (Select Id, Name from Contacts) From Account limit 25M
Thanks
-
Adding some points:
If you go thru the Lightning base components release notes, you will notice that the Base components are more of an extended implementation of the existing UI components.
here’s an extract of the related section
You can find base Lightning components in the lightning namespace to complement the existing ui namespace components. In instances where there are matching ui and lightning namespace components, we recommend that you use the lightning namespace component. The lightning namespace components are optimized for common use cases. Beyond being equipped with the Lightning Design System styling, they handle accessibility, real-time interaction, and enhanced error messages.
Thanks
-
Parul
MemberSeptember 19, 2018 at 6:28 pm in reply to: What is difference between Lightning button () and ui button()Hi
Lightning button
A lightning:button component represents a button element that executes an action in a controller. Clicking the button triggers the client-side controller method set for on click. Buttons can be either a label only, label and icon, body only, or body and icon. Use lightning:button Icon if you need an icon-only button.
UI button
A ui:button component represents a button element that executes an action defined by a controller. Clicking the button triggers the client-side controller method set for the press event
-
Hi
1.If we use the DML statement (insert), then in bulk operation if error occurs, the execution will stop .and Apex code throws an error which can be handled in try catch block.
2.If DML database methods (Database.insert) used, then if error occurs the remaining records will be inserted / updated means partial DML operation will be done.
-
Parul
MemberSeptember 19, 2018 at 6:24 pm in reply to: what is the use of Database.Stateful in Salesforce Batch Class?Adding some more point:
Hi
Implementing database.stateful will maintain your state so the map that you are using in execute method will contain all the error messages after the completion of execute method.In finish method you will have aggregate of all errors that can be finally used .
Thanks
-
May be you can use this:
Try TEXT(Account__r.Operational_Status__c)
Thanks
-
Parul
MemberSeptember 19, 2018 at 5:59 pm in reply to: How can we hard delete a record using a Apex class/by code in salesforce?Hi
Apex:
1. Delete your record using Standard DML for delete:
Database.DeleteResult[] delete(SObject[] recordsToDelete, Boolean opt_allOrNone)2. Empty recycle bin for the records you have just deleted using :
Database.EmptyRecycleBinResult[] emptyRecycleBin(ID [] recordIds)API
1. Delete your record using Standard DML for delete:
DeleteResult[] = connection.delete(ID[] ids);2. Empty recycle bin for the records you have just deleted using :
EmptyRecycleBinResult[] = connection.emptyRecycleBin(ID[] ids);Thanks
-
Parul
MemberSeptember 19, 2018 at 5:52 pm in reply to: How can you edit your record from within the lightning:dataTable itself?Hi
Summer’18 offers a wide range of additions and enhancements to Lightning Components, including the ever-useful Base Components. Let’s walk through two examples: one is a brand new component which makes it easy to create a form related to a record and the other is an update to dataTable for editing data. Because Summer18 release was a power-packed release and has a lot to offer. One of the features introduced is lightning is the editable lightning data table.
Thanks
-
Adding some points:
SOAP :The Force.com SOAP API (formerly known as the Force.com Web Services API) lets you integrate Force.com applications that can create, retrieve, update, or delete records managed by Salesforce, Force.com, and Database.com, records such as accounts, leads, and custom objects. With more than 20 different calls, SOAP API also lets you maintain passwords, perform searches, and much more. You can use the SOAP API with any programming language that supports Web services.
Thanks
-
Parul
MemberSeptember 19, 2018 at 5:33 pm in reply to: How to generate the random string or random password using Apex?Hi,
Adding some code snippet
Here is a static method that accepts a desired string length as an argument. It takes a full string of ASCII numbers and letters and loops through the index of your desired string length, randomly choosing an index in the full character string.
public static String generateRandomString(Integer len) {
final String chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
String randStr = '';
while (randStr.length() < len) {
Integer idx = Math.mod(Math.abs(Crypto.getRandomInteger()), chars.length());
randStr += chars.substring(idx, idx+1);
}
return randStr;
}Thanks
-
Parul
MemberSeptember 19, 2018 at 5:31 pm in reply to: Can we generate the random string or random password using Apex?Hi,
public String testGenerate(Integer getLength)
{
String charString = ‘!@#$%^&*()nopqrstuvwABCDPQRSTUVWXYZ0123456789abcdefghijkEFGHIJKLMNOlmxyz’;
String randomNew = ”;
while (randomNew .length() < getLength){
Integer changeInt = Math.mod(Math.abs(Crypto.getRandomInteger()), charString.length());
randomNew += charString.substring(changeInt , changeInt +1);
}
return randomNew ;
}Hope this helps.