Ajay Prakash
IndividualForum Replies Created
-
Ajay Prakash
MemberFebruary 27, 2020 at 4:51 am in reply to: How to take List of Account into a JavaScript variable on a Salesforce Visualforce page?I found this interesting topic today. Using remote action will open a different thread. I believe, The following approach will help -
In your javascript code parse the get set variable in the following way-
var accListTemp='{!accountList}'; var accList = JSON.parse(accListTemp);
Here in accList you will get a list of objects in javascript. You will get a JSON parsing error if you use the get set variable as a list of sobject. It will be better if you return a JSON from apex code and parse in Javascript.
public list<Account> getaccountList {get;set;} public String accountList {get;set;} public getaccountList(){ getaccountList = [Select Id, Name from Account]; accountList = JSON.serialize(getaccountList); }
Thanks.
-
Ajay Prakash
MemberFebruary 28, 2018 at 5:57 am in reply to: How can I append entire fields at once in query? Like 'SELECT * FROM ACCOUNT' in SQL .Hi Pranav,
In SOQL you cannot use * to retrieve all the field values. You have to mention each and every fields API name in your SOQL query.
Thanks.
-
Ajay Prakash
MemberFebruary 28, 2018 at 5:10 am in reply to: How to grant permission to user through apex code?Hi Pranav,
You can assign permission set to user dynamically using following code in your apex -
PermissionSetAssignment psa = new PermissionSetAssignment
(PermissionSetId = yourPermissionSetId, AssigneeId = yourAssigneeId);
insert psa;Thanks.
-
Ajay Prakash
MemberFebruary 28, 2018 at 5:03 am in reply to: How to create reusable methods in Lightning JS client side controller for reuse within the client side controller itself?I agree with Himanshu. If you write the code in the helper.js then this code will be accessible from the controller.js, renderer.js and helper.js itself. It will improve your code reusability.
-
Ajay Prakash
MemberFebruary 28, 2018 at 4:58 am in reply to: If we declare lightning style in a Salesforce lightning component does it affect lightning application?Hi Pranav,
Only including the style from the static resource in your lightning component will neither affect your lightning component nor your Lightning application. However, it will affect the preview of the lightning application if the component is included in the Lightning application and uses the CSS attributes. The scope of this static resource will be limited to Lightning component.
Thanks.
-
Ajay Prakash
MemberFebruary 28, 2018 at 4:39 am in reply to: Is there any method to limit the maximum number of characters that can be typed into input field in Salesforce?Hi Pranav,
You should use maxlength attribute of the input field instead of calling a method for the validation. If you want to write some custom logic or you want to show a message to the user then you can call a method and follow the approach provided by Abhinav.
Thanks.
-
Ajay Prakash
MemberFebruary 27, 2018 at 4:06 am in reply to: How to get the old value of a field in a Salesforce Apex Controller?The above solution will help you definitely. There can be one more possible approach that you can perform a SOQL query on the object in the current transaction where you want old values of any record.
-
Ajay Prakash
MemberFebruary 22, 2018 at 6:47 pm in reply to: Calling Batch class with Salesforce Apex TriggerHi Anish,
As I can see Stage__c is an custom Object and you are referring object label Stage in your batch class. You should refer API name Stage__c of the Stage object in your batch class as well.
One more mistake I can see in your code that you have defined setQry(string soqlquery) method in your batch class but this method is not called from anywhere in your batch. You can set your query in the constructor rather than defining setQry(string soqlquery) method.
Thanks.
-
Ajay Prakash
MemberFebruary 22, 2018 at 5:23 pm in reply to: Need help in changing Standard Price Book in SalesforceHi Ravi,
Unfortunately it is not possible to change Price Book for existing Order, like on Opportunity. This Feature is not delivered by Salesforce and still is in Idea.
-
Ajay Prakash
MemberFebruary 18, 2018 at 7:27 am in reply to: Is there any method to test a Visualforce page like an apex class?You need to do unit testing for apex classes not for visualforce pages. Yes you will need to write test classes for visualforce page controller before deployment.
-
Ajay Prakash
MemberFebruary 18, 2018 at 7:21 am in reply to: Permission set is assigned to user, how does it assign to a particular profile not user in Salesforce?Hi Pranav,
There is no sense of assigning the permission set to a profile. The permission set is for adding an exception on the profiles means providing additional access. You can add permission set's permission on the profile directly.
-
Ajay Prakash
MemberFebruary 18, 2018 at 7:11 am in reply to: What is the difference between Readable,Visible and Read Only in permission set?Read-Only: If you check the "Read-Only" checkbox, that field will be read-only for the users of that profile. The user can only see that field, he can't edit. The field must be Visible to be Read-Only.
Visible: If you check the "Visible" checkbox, that field will be visible to that profile. User can read & edit that field
Readable: Read permission on an object gives access to view records that are either created by users themselves or any record that is being shared by sharing rules/role/manual sharing
-
Ajay Prakash
MemberFebruary 18, 2018 at 6:45 am in reply to: Can I use Map in dynamic query in Apex?You can not use a map in a dynamic query because you can only use variables and collections in the dynamic query. map.Keyset() and map.Values() are the methods that you can not use directly inside a dynamic query.
-
Ajay Prakash
MemberFebruary 18, 2018 at 6:32 am in reply to: Want to take values as parameters from one page to another but this is working in Salesforce classic but not in lightning.How to overcome this issue?You can get the URL Parameters using window.location in your javascript.
-
Ajay Prakash
MemberFebruary 18, 2018 at 6:10 am in reply to: How can I implement lookup filters for custom objects in lightning experience?Salesforce has released this feature in Lightning as well in Spring '17. You can create lookup filter in lightning in the same way as you create in the Salesforce Classic.
-
Ajay Prakash
MemberFebruary 18, 2018 at 6:05 am in reply to: Update Parent Record from a Salesforce triggerIn this scenario, if criteria are met every time a parent record is updated means you will insert a new child record, it will exceed the maximum depth limit of a trigger and will throw a maximum trigger depth exception.
-
Ajay Prakash
MemberFebruary 18, 2018 at 4:52 am in reply to: How to resolve UNABLE TO LOCK ROW error in salesforce?Reason and Resolution-
When you have multiple jobs running that update the same set of records, it's recommended to lock the records using the FOR UPDATE keyword. It will ensure that the record is locked and no other job can update the same record at that point in time. The conflicting job will then wait until the locking on the record is released and then perform the required operations. This will avoid conflicts between jobs that are running concurrently and will not throw up this exception.
Locking Statements-
In Apex, you can use FOR UPDATE to lock sObject records while they’re being updated in order to prevent race conditions and other thread safety problems.No other client or user is allowed to make updates either through code or the Salesforce user interface if the record is locked.
Ex. Account [] accts = [SELECT Id FROM Account LIMIT 2 FOR UPDATE];
-
Ajay Prakash
MemberFebruary 15, 2018 at 11:52 am in reply to: Can I grant different field-level security based on record ownership?There can be one possible solution. You can hide the field visibility from the profile and create a permission set having field level security based on the requirement and assign this permission set to the desired user.
-
Ajay Prakash
MemberFebruary 12, 2018 at 2:43 pm in reply to: How to enable lightning app builder in Salesforce?Lightning app builder is enabled by default. You need to go to quick search box and search for "lightning app builder" . There you can see a new button. By clicking new you can create new lightning page.
-
Ajay Prakash
MemberFebruary 12, 2018 at 2:34 pm in reply to: How can I fetch the list views columns in Salesforce?We can retrieve list view column or the records based on the list view id using HTTP request. The response contains the query string that contains columns of the list view. Below code is for reference –
public static List<Account> getFilteredAccounts(String filterId){ HttpRequest req = new HttpRequest(); String baseUrl = URL.getSalesforceBaseUrl().toExternalForm(); String endPoinURL = baseUrl+’/services/data/v32.0/sobjects/Account/listviews/’+filterId+’/describe’; req.setEndpoint(endPoinURL); req.setMethod(‘GET’); req.setHeader(‘Authorization’, ‘Bearer ‘ + UserInfo.getSessionId()); Http http = new Http(); HTTPResponse response = http.send(req); Map<String, Object> tokenResponse = (Map<String, Object>) JSON.deserializeUntyped(response.getBody()); String query = (String) tokenResponse.get(‘query’); List<Account> AccountList = new List<Account>(); for(Account accountObj : database.query(query)){ AccountList.add(accountObj); } return AccountList; }
In the above example, I have retrieved accounts based on the selected list view.
-
Ajay Prakash
MemberFebruary 12, 2018 at 2:09 pm in reply to: Can we have look up filter in Salesforce lightning?This feature has been delivered in Spring '17.
-
Ajay Prakash
MemberFebruary 12, 2018 at 9:37 am in reply to: Pre-populating fields at record creation in Salesforce Lightning ExperienceIf you want to fetch the field value dynamically the use -
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
If you want to provide static value then give default values in the attribute.
<aura:attribute name="attributeName" type="AttributeType" default="default value" />
-
Ajay Prakash
MemberFebruary 12, 2018 at 9:17 am in reply to: How can i debug the javascript code in Salesforce Lightning?Lightning component java script can be debug in following manner-
- Use Chrome + built in Dev Tools + Lightning Component Inspector
- Make sure that debug mode is enabled in your org (Setup: Lightning Components).
- Make sure that caching is disabled in your org (Setup: Session Settings -> uncheck "Enable secure and persistent browser caching to improve performance"
- This reply was modified 6 years, 10 months ago by Ajay Prakash.
-
Ajay Prakash
MemberFebruary 11, 2018 at 5:07 pm in reply to: How do I deploy Lightning components to my production org?The lightning component can be deployed to production like any other component like apex,visualforce etc.
Lightning components are available in the Lightning Component Bundle in the drop-down list of the changeset.
-
Ajay Prakash
MemberFebruary 11, 2018 at 5:02 pm in reply to: Where Lightning Components can be displayed?Lightning component can be displayed in the following ways-
- Run Lightning Components Apps Inside Visualforce Pages
- Run Lightning Components Apps on Other Platforms with Lightning Out
- Create Drag-and-Drop Components for Lightning App Builder and Community Builder
- Launch a Lightning Component as a Quick Action
- Add Lightning Components to Lightning Experience Record Pages
- Create a custom tab for the lighting component.