Forum Replies Created

Page 6 of 7
  • Hi,

    insert is the DML statement which is same as databse.insert. However, database.insert gives more flexibility like rollback, default assignment rules etc. we can achieve the database.insert behavior in insert by using the method setOptions(Database.DMLOptions)

    Important Difference:

    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.
    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.

    Thanks.

     

  • Prachi

    Member
    August 23, 2019 at 5:17 am in reply to: How we can create lookup fields in Visualforce pages in salesforce ??

    Hi,

    Lets take an Example:
    Suppose you have an Employee Custom Object. In that lets say you have First Name Custom field.

    Now you want the lookup icon to be displayed for the above field in your Visualforce page.
    In your Controller do the following,
    public Employee__c getFirstName()
    {
    return [select FirstName__c from Employee__c limit 1];
    }
    Now, In your Visualforce page do the following.
    <apex:inputField value="{!firstName.FirstName__c}"/>

    where firstName is the method name in the Controller.

    By doing this a lookup icon will be rendered on ur Visualforce page.

    Thanks.

    • This reply was modified 5 years, 3 months ago by  Prachi.
  • Prachi

    Member
    August 22, 2019 at 11:04 am in reply to: What is the use of lightning:recordForm?

    Hi Saddam,

    A lightning:recordForm component enables you to quickly create forms to add, view, or update a record. Using this component to create record forms is easier than building forms manually with lightning:recordEditForm and lightning:recordViewForm.

    Thanks.

  • Prachi

    Member
    August 22, 2019 at 11:01 am in reply to: What is urlMapping in RestResource class?

    Hi,

    The @RestResource annotation is used at the classlevel and enables you to expose an Apex class as a REST resource. These are some considerations when using this annotation: The URL mapping is relative to https:// instance .salesforce.com/services/apexrest/.The URL mapping is case-sensitive. A URL mapping for my_url will only match a REST resource containing my_url and not My_Url.

    URL Guidelines-

    URL path mappings are as follows:

    1. The path must begin with a '/'.
    2. If an '*' appears, it must be preceded by '/' and followed by '/', unless the '*' is the last character, in which case it need not be followed by '/'.

    The rules for mapping URLs are:

    1.An exact match always wins.
    2.If no exact match is found, find all the patterns with wildcards that match, and then select the longest (by string length) of those.
    3.If no wildcard match is found, an HTTP response status code 404 is returned.

    Thanks.

  • Prachi

    Member
    August 22, 2019 at 10:55 am in reply to: How to compare Trigger.new values with Trigger.old values

    Hi Deepak,

    Try this-

    trigger RelatedProduct  on RelatedProduct__c (before insert)
    {
    Set<Id> setProductId = new Set<Id>();
    Set<Id> setOfProductHaveRelation = new Set<Id>();
    for (RelatedProduct__c objRelatedProduct : Trigger.New)
    {
    setProductId.add(objRelatedProduct.Product__c);
    }
    for (RelatedProduct__c objRelatedProduct :[SELECT Id, Product__c FROM RelatedProduct__c WHERE Product__c IN: setProductId])
    {
    setOfProductHaveRelation.add(objRelatedProduct.Product__c);
    }
    for (RelatedProduct__c objRelatedProduct : Trigger.New)
    {
    if(!setOfProductHaveRelation.contains(objRelatedProduct.Product__c )) continue;
    objRelatedProduct.addError('This Product already have the Relation.');
    }

    Thanks.
     

  • Prachi

    Member
    August 22, 2019 at 5:16 am in reply to: What is the use of transfer record in Profile in Salesforce?

    Hi Laveena,

    If user have only Read access on particular record but he wants to change the owner name of that record, then in profile level Transfer Record enables he can able to change the owner.

    Thanks.

  • Hi Hariom,

    Static resources allow you to upload content that you can reference in a Visualforce page, including archives (such as .zip and .jar files), images, style sheets, JavaScript, and other files.
    Using a static resource is preferable to uploading a file to the Documents tab because:

    1.You can package a collection of related files into a directory hierarchy and upload that hierarchy as a .zip or .jar archive.
    2.You can reference a static resource by name in page markup by using the $Resource global variable instead of hard coding document IDs.

    Thanks.

  • Prachi

    Member
    August 22, 2019 at 5:05 am in reply to: How we can  make a VF page available for Salesforce1 ?

    Hi Hariom,

    Add the Page to the Salesforce App Navigation Menu
    1. From Setup, enter Visualforce Pages in the Quick Find box, then select Visualforce Pages.
    2. Click Edit next to the LatestAccounts Visualforce page in the list.
    3. Select Available for Lightning Experience, Lightning Communities, and the mobile app.
    4. Click Save.

    Thanks.

  • Hi Laveena,

    You can create sObjects in memory with arbitrary CreatedDate values by using JSON.deserialize. This doesn’t enforce the normal read-only field attributes that prevent you from setting a createdDate value. However, you can’t commit arbitrary CreatedDate values to the database (or else it would be a serious security issue).
    Detecting governor limits through apex
    First of all, the exception thrown by hitting a limit, System.LimitException is uncatchable and means that your script will be killed, even if it happens inside a try/catch block. There is a class, Limits, that contains a number of static methods that allow you to check your governor limit consumption.

    Thanks.

  • Hi,

    If newly created records are equal to or less than 9000, then it will be indexed in 1 to 3 minutes. However if records are more than 9000, then servers perform bulk indexing at a lower priority, so processing might take longer.

    Thanks.

  • Prachi

    Member
    August 22, 2019 at 4:48 am in reply to: Apex Unit test: why do we need test classes in salesforce?

    Hi,

    Unit Testing in Salesforce
    Testing is a key and critical component to successful long term software development process. Salesforce.com strongly recommends using a test-driven development process which occurs at the same time as code development. Salesforce has very strong set of documentation. When I was learning salesforce unit testing, I realize that it is difficult to understand where to start read. Therefore, I summarized the unit testing for salesforce beginners to understand the basic aspects of unit testing.

    There are few things to consider before you deploy or upload the code or package;75% of your Apex code must be covered by unit tests
    All the tests must complete successfully
    Every trigger has some test coverage (1%)
    All classes and triggers must compile successfully
    When you are writing a test class, you have to write test for Single Action, Bulk Action, Positive Behavior, Negative Behavior, and Restricted User.
    Single Action :Test to verify that a single record produces the correct, expected result.
    Bulk Action :  Test not only the single record case, but the bulk cases as well
    Positive Behavior :  Verify that the expected behavior occurs through every expected permutation
    Negative Behavior :  Verify that the error messages are correctly produced
    Restricted User :Test whether a user with restricted access to the sObjects used in     your code sees the expected behavior
    Test Class can be defined @isTest annotation. Before the Winter 12’ release we had only private test classes, but on Winter 12’ release salesforce has given the chance to write public test classes as well. Salesforce has released the public test classes for expose common methods for data creation. It can be used to setting up data that the tests need to run against. Public test methods can be called from a running test but not from a non-test request.

    When you create a test method,

    1.Use static
    2.Use testMethod keyword
    3.Use void return type
    4.No any arguments
    5.No data changes performed in a test method
    6.Don’t send emails

    Thanks.

  • Prachi

    Member
    August 22, 2019 at 4:43 am in reply to: How to process more than 50000 records in Salesforce?

    Hi Somendra,

    We can process more than 50000 records in Salesforce by SOQL-

    List<Order__c> ord_list = [Select id, source__c from Order__c];

    Thanks.

  • Prachi

    Member
    August 22, 2019 at 4:38 am in reply to: How to add a custom logo for your custom application in Salesforce?

    Hi,

    To make your own logo for free, follow these 6 simple steps:
    1. Enter Your Brand Name. Add the name of your brand, business or organization, and tell us what you do.
    2. Tell Us What Your Logo Is For.
    3. Share Your Design Style.
    4. Customize Your Logo Design.
    5. Download Your Logo.
    6. Print Your Logo.

    Thanks.

    • This reply was modified 5 years, 3 months ago by  Prachi.
  • Prachi

    Member
    August 22, 2019 at 4:30 am in reply to: What is the junction object and what is the use in Salesforce?

    Hi,

    Salesforce supports 2 kinds of relationships like Master Detail and Lookup. They are both one-to-many relationship, and they are both  defined from the many-to-one side, that is from a child to a parent. They can be made one-to-one relationship by adding validation rules, or maybe triggers to enforce the one-to-one nature, i.e. only one child is allowed.

    Junction objects are used to create many to many relationships between objects. If you take the Recruiting application example, you can see that a Position can be linked to many Candidates, and a Candidate can apply for different Positions. To create this data model you need a third object "Job Application" that links the 2.

    Thanks.

  • Prachi

    Member
    August 22, 2019 at 2:12 am in reply to: Difference between Alert Rule and Error Rule in Salesforce CPQ?

    Hi,

    Alert Rules-
    Alert rules provide informational messages during configuration or pricing. Unlike a validation rule, alert rules let you continue and save configurations and quotes without changing anything.

    Use alert rules to provide suggestions for optimal but nonrequired configuration and pricing processes such as best practices.

    Set your product rule’s type to Alert so that alert rules are set up the same as validation rules. When an alert rule fires and finds a configuration value or quote value that matches its error condition, users see an error message. They can revise their configuration or quote or continue without correcting the errors.

    Product Rule-

    You can evaluate a product option, quote, or a quote line against user-made conditions and perform an action in response. Organize your conditions and actions in a product rule object.

    All product rules contain related lists for Error Conditions, Actions, and Configuration Rules.

    An Error Condition contains two sections: Information and Filter Information. Information defines an object, a field on an object, or a variable to test. Filter Information defines a logical operator and a value to test against. When Salesforce CPQ processes a product rule, it tests all the rule’s error conditions and evaluates whether they’re true or false. It then considers the rule’s Conditions Met field when evaluating whether to fire an action. You can set Conditions Met so that the rule fires when:

    -All error conditions are true
    -Any number of error conditions are true
    -The error conditions evaluate to user-determined custom logic.

    All rule types require at least one Error Condition.
    Your use of Actions and Configuration Rules depends on the type of product rule you’re using.

    Thanks.

  • Prachi

    Member
    August 22, 2019 at 1:58 am in reply to: How to automate manually sharing of records?

    Hi Himanshu,

    It is possible to manually share a record to a user or a group using Apex or the SOAP API.

    Thanks.

  • Prachi

    Member
    August 22, 2019 at 1:45 am in reply to: how to create tables in a Salesforce vf page?

    Hi,

    There are various tags like <apex:pageBlockTable>, <apex:DataTable> to create table in VF page.

    Here is an example-

    <apex:page standardController="Account">
    <apex:pageBlock title="Hello {!$User.FirstName}!">
    </apex:pageBlock>
    <apex:pageBlock title="Contacts">
    <apex:pageBlockTable value="{!account.Contacts}" var="contact">
    <apex:column value="{!contact.Name}"/>
    <apex:column value="{!contact.MailingCity}"/>
    <apex:column value="{!contact.Phone}"/>
    </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:page>

    Thanks.

  • Hi Saddam,

    The $Lightning.createComponent() call creates a button with a “Press Me!” label. The button is inserted in a DOM element with the ID “lightning”. After the button is added and active on the page, the callback function is invoked and executes a console.log() statement. The callback receives the component created as its only argument.

    Thanks.

  • Hi Deepak,

    Try this -

    Controller-

    ({
    doInit : function(component, event, helper) {
    var createEvent = $A.get("e.force:createRecord");
    createEvent.setParams({
    "entityApiName": "Test_Object__c",
    "defaultFieldValues": {
    Name : 'Test Record1',
    Description__c :'test description',
    Parent_field__c : 'a',
    Child_Field__c : '1',
    additional_field__c : 'q'
    }
    });
    createEvent.fire();
    }
    })

    Thanks.

  • Hi Laveena,

    Visualforce pages are served from a different domain in salesforce because of Security. Salesforce wants to keep tight control over what is customizable and what is not. Consider an example of a Visual force page running within your standard page-layout. If it runs in the same domain, the scripts in the VF page will be able to access the scripts on the standard page-layout and will be able to manipulate it.

    As a matter of fact there used to be a side-bar hack where users could run scripts from side-bar and manipulate standard pages, which has since been disabled by ensuring all scripts and vf pages run in a different domain.

    Thanks.

  • Hi Hariom,

    Getter Methods-
    Getter methods return values from a controller. Every value that is calculated by a controller and displayed in a page must have a corresponding getter method, including any Boolean variables. For example, in the sample page in Building a Custom Controller, the controller includes a getAccount method. This method allows the page markup to reference theaccount member variable in the controller class with {! } notation. The value parameter of the <apex:inputField> tag uses this notation to access the account, and dot notation to display the account's name. Getter methods must always be named getVariable.

    Setter Methods
    Setter methods pass user-specified values from page markup to a controller. Any setter methods in a controller are automatically executed before any action methods.

    Thanks.

     

    • This reply was modified 5 years, 3 months ago by  Prachi.
  • Prachi

    Member
    August 12, 2019 at 10:18 am in reply to: What are the value providers in Salesforce Lightning?

    Hi Achintya,

    Value providers are a way to access data. Value providers encapsulate related values together, similar to how an object encapsulates properties and methods.
    The value providers for a component are v (view) and c (controller).

    v - A component’s attribute set. This value provider enables you to access the value of a component’s attribute in the component’s markup.

    c - A component’s controller, which enables you to wire up event handlers and actions for the component.

    All components have a v value provider, but aren't required to have a controller. Both value providers are created automatically when defined for a component.

    Thanks.

  • Prachi

    Member
    August 12, 2019 at 9:07 am in reply to: Can we restrict data access using Salesforce Sharing Rules?

    Hi Divya,

    You can use sharing rules to grant wider access to data. You cannot restrict access below your organization-wide default levels. To create sharing rules, your organization-wide defaults must be Public Read Only or Private.

    Thanks.

    • This reply was modified 5 years, 3 months ago by  Prachi.
  • Hi laveena,

    You can use debug log in developer console.

    In the bottom of page it will give you result like this

    11:48:38.109|CUMULATIVE_LIMIT_USAGE
    11:48:38.109|LIMIT_USAGE_FOR_NS|(default)|
    Number of SOQL queries: 8 out of 100
    Number of query rows: 9 out of 50000
    Number of SOSL queries: 0 out of 20
    Number of DML statements: 20 out of 150
    Number of DML rows: 20 out of 10000
    Number of script statements: 583 out of 200000
    Maximum heap size: 0 out of 3000000
    Number of callouts: 0 out of 10
    Number of Email Invocations: 0 out of 10
    Number of fields describes: 0 out of 100
    Number of record type describes: 0 out of 100
    Number of child relationships describes: 0 out of 100
    Number of picklist describes: 0 out of 100
    Number of future calls: 0 out of 10

    11:48:38.109|CUMULATIVE_LIMIT_USAGE_END

    Please check below post to avoid limit
    https://developer.salesforce.com/page/Best_Practice:_Use_of_the_Limits_Apex_Methods_to_avoid_Hitting_Governor_Limits

    LIMITS

    System.debug('Total Number of SOQL Queries allowed in this apex code context: ' + Limits.getLimitQueries());
    System.debug('Total Number of records that can be queried in this apex code context: ' + Limits.getLimitDmlRows());
    System.debug('Total Number of DML statements allowed in this apex code context: ' + Limits.getLimitDmlStatements() );
    System.debug('Total Number of script statements allowed in this apex code context: ' + Limits.getLimitScriptStatements());

    USAGE
    System.debug('1.Number of Queries used in this apex code so far: ' + Limits.getQueries());
    System.debug('2.Number of rows queried in this apex code so far: ' + Limits.getDmlRows());
    System.debug('3. Number of script statements used so far : ' + Limits.getDmlStatements());
    System.debug('4.Number of Queries used in this apex code so far: ' + Limits.getQueries());
    System.debug('5.Number of rows queried in this apex code so far: ' + Limits.getDmlRows());

    Thanks.

  • Prachi

    Member
    August 9, 2019 at 12:37 pm in reply to: What is __r in salesforce?

    Hi Laveena,

    "__r" in salesforce is used for retrieving field values from the object's related another object when those objects have relationship via Lookup field.

    Thanks.

Page 6 of 7