Forum Replies Created

Page 14 of 57
  • It is possible using Ajax Toolkiit.

    global class myClass {
    webService static Id makeContact (String lastName, Account a) {
    Contact c = new Contact(LastName = lastName, AccountId = a.Id);
    return c.id;
    }
    }

    we can execute above method from javascript like :

    {!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}
    {!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")}
    var account = sforce.sObject("Account");
    var id = sforce.apex.execute("myClass" , "makeContact",
    {lastName:"Smith", a:account});

  • shariq

    Member
    September 22, 2018 at 6:27 PM in reply to: What are few Considerations about Salesforce Trigger?

    upsert triggers fire both before and after insert or before and after update triggers as appropriate.
    merge triggers fire both before and after delete triggers for the losing records and before update triggers for the winning record only.
    Triggers that execute after a record has been undeleted only work with specific objects.
    Field history is not recorded until the end of a trigger. If you query field history in a trigger, you will not see any history for the current transaction.
    You can only use the webService keyword in a trigger when it is in a method defined as asynchronous; that is, when the method is defined with the @future keyword.
    A trigger invoked by an insert, delete, or update of a recurring event or recurring task results in a runtime error when the trigger is called in bulk from the Force.com API.
    Merge trigger doesn’t fire there own trigger instead they fire delete and update of loosing and winning records respectively.

  • Each savepoint you set counts against the governor limit for DML statements.
    Static variables are not reverted during a rollback. If you try to run the trigger again, the static variables retain the values from the first run.
    Each rollback counts against the governor limit for DML statements. You will receive a Runtime error if you try to rollback the database additional times.
    The ID on an sObject inserted after setting a savepoint is not cleared after a rollback.

  • if you generated savepoint SP1 first, savepoint SP2 after that, and then you rolled back to SP1, the variable SP2 would no longer be valid. You will receive a runtime error if you try to use it.

  • We will need “ALL Rows” clause of SOQL.
    Sample:

    SELECT COUNT() FROM Contact WHERE AccountId = a.Id ALL ROWS

  • It can be done with help of External Id.

    Date dt = Date.today().addDays(7);
    Opportunity newOpportunity = new Opportunity(Name = ‘shivasoft’, StageName = ‘Prospecting’, CloseDate = dt);
    
    /*
    Create the parent reference. Used only for foreign key reference and doesn’t contain any other fields. If we provide any other value it will give following error
    
    System.DmlException: Insert failed. First exception on row 1; first error: INVALID_FIELD, More than 1 field provided in an external foreign key reference in entity: Account: []
    */
    
    Account accountReference = new Account(MyExtID__c = ‘SHIVA1234567’);
    newOpportunity.Account = accountReference;
    
    // Create the Account object to insert. Same as above but has Name field. Used for the insert.
    Account parentAccount = new Account(Name = ‘Shiva’, MyExtID__c = ‘SHIVA1234567’);
    
    Database.SaveResult[]
    results = Database.insert(new SObject[] { parentAccount, newOpportunity });
  • Field Level Security (FLS) of Person Account fields ar controlled by Contact Fields. So, if you want to setup FLS of Person Account Fields navigate to fields of Contact and it will be reflected on Person Account

  • shariq

    Member
    September 22, 2018 at 6:21 PM in reply to: How do you import Converted Lead into Salesforce from Legacy System ?

    Fields we need for importing converted leads are “ISCONVERTED” , “CONVERTEDCONTACTID” , “CONVERTEDOPPORTUNITYID” and “CONVERTEDACCOUNTID“.

    Step 1: As above fields are not editable, we have to contact Salesforce Support to enable Audit fields. Enabling Audit fields means we can edit few Readonly fields like created date and above lead fields.

    Step 2: Import Account, Contact and Opportunity from Legacy system to Salesforce.

    Step 3: If you imported account, contact and opportunity in Step 2, Salesforce automatically generates Unique ID. We need that unique Id to insert Converted Lead. So Export Account, Contact and Opportunity, which is inserted in Step 2 from legacy System.

    Step 4: Create CSV File with All lead information with ISCONVERTED=TRUE and CONVERTEDCONTACTID, CONVERTEDOPPORTUNITYID, CONVERTEDACCOUNTID. CONVERTEDCONTACTID, CONVERTEDOPPORTUNITYID and CONVERTEDACCOUNTID should correspond to Ids generated by Salesforce for Contact, Opportunity and Account which will be related to converted lead.

    Step 5: Once CSV is properly created with all required Data, Insert it using DataLoader.

    Note: We cannot convert existing lead using this process. Leads must be inserted with these four fields. If you try to update lead it will not give you option to edit above fields.

  • shariq

    Member
    September 22, 2018 at 6:19 PM in reply to: How to use Datetime in Dynamic SOQL Query in Salesforce?

    This error is because of wrong construction of Dynamic Query with Datetime. following code snippet will give idea on how to construct dynamic query for Datetime ?

    //format the datetime to make it Dynamic Soql ready
    String formatedDt = cutOffDateTime.format('yyyy-MM-dd'T'HH:mm:ss'Z'');
    String sql = 'SELECT  a.Id  FROM  Agents_Answer__c a    WHERE  a.Agents_Test_Result__r.Agent_Name__r.IsActive__c = false AND  LastModifiedDate < '+ formatedDt ;
    Where, “cutOffDateTime” is variable of datetime type.

  • shariq

    Member
    September 22, 2018 at 6:18 PM in reply to: In below code snippet in Salesforce, what is going wrong?

    It will not send any email. Because “adderror” prevents all transactions from committing including emails.

  • Record locked error can be avoided by two ways

    Change schema of Object : Check every Lookup field and make sure that in Lookup Option you have notselected “Don’t allow deletion of the lookup record that’s part of lookup relationship”. Because of this selection, even during insert operation system hold lock against record and other batches accessing same record fails.
    Order Insert operations in CSV File : In this option, Sort column containing parent record Id for Lookup fields. So all records of same parent will be loaded in same batch and parent record locked problem across batch will be resolved

  • shariq

    Member
    September 22, 2018 at 6:15 PM in reply to: How can we load millions of records in Salesforce within an hour ?

    We can use Bulk Data loading and turn ON Parallel loading.

  • shariq

    Member
    September 22, 2018 at 6:15 PM in reply to: What is Defer Sharing Calculation in Salesforce?

    This feature allows users to defer the processing of sharing rules until after new users, rules, and other content have been loaded. This is very useful and handy feature to speed up data loading by avoiding calculation of Sharing rules.

  • shariq

    Member
    September 22, 2018 at 6:14 PM in reply to: Explain Two-Column Custom Indexes in Salesforce.

    Two-column custom indexes are a specialized feature of the Salesforce platform. They are useful for list views and other situations in which you want to use one field to select the records to display and a second field to sort those records.

    Two-column indexes are subject to the same restrictions as single-column indexes, with one exception. Two-column indexes can have nulls in the second column by default, whereas single-column indexes cannot, unless salesforce.com Customer Support has explicitly enabled the option to include nulls

  • Reference other entities (i.e., fields accessible through lookup fields
    Include other formula fields that span over other entities
    Use dynamic date and time functions (e.g., TODAY and NOW)

    A formula is also considered non-deterministic when it includes:

    Owner, autonumber, divisions, or audit fields (except for CreatedDate and CreatedByID fields
    References to fields that Force.com cannot index
    Multi-select picklists
    Currency fields in a multicurrency organization
    Long text area fields
    Binary fields (blob, file, or encrypted text)

  • shariq

    Member
    September 22, 2018 at 6:13 PM in reply to: When Salesforce will use Custom Indexed fields?

    Salesforce maintains statistics table which stores information about records present in Organization. If records going to be searched is less than or equal to 10% of total records or up to 333,333 records then only it makes sense to use standard Indexed fields to narrow result else total records going to be returned is more than 10% already so Salesforce will not use any indexing.

  • shariq

    Member
    September 22, 2018 at 6:13 PM in reply to: When Salesforce will use Standard Indexed fields?

    Salesforce maintains statistics table which stores information about records present in Organization. If records going to be searched is less than or equal to 30% of total records or up to 1 million records then only it makes sense to use standard Indexed fields to narrow result else total records going to be returned is more than 30% already so Salesforce will not use any indexing.

  • shariq

    Member
    September 22, 2018 at 6:11 PM in reply to: What are the considerations for Skinny Table in Salesforce?

    Skinny tables can contain a maximum of 100 columns.
    Skinny tables cannot contain fields from other objects.
    Skinny tables are not copied to sandbox organizations. To have production skinny tables activated in a sandbox organization, contact salesforce.com Customer Support.

  • shariq

    Member
    September 22, 2018 at 6:10 PM in reply to: Explain Skinny table in Salesforce?

    Salesforce creates skinny tables to contain frequently used fields and to avoid joins, and it keeps the skinny tables in sync with their source tables when the source tables are modified. To enable skinny tables, contact Salesforce.com Customer Support.
    For each object table, Salesforce maintains other, separate tables at the database level for standard and custom fields. This separation ordinarily necessitates a join when a query contains both kinds of fields. A skinny table contains both kinds of fields and does not include soft-deleted records.
    This table shows an Account view, a corresponding database table, and a skinny table that would speed up Account queries.

  • shariq

    Member
    September 22, 2018 at 6:09 PM in reply to: When records are created in Salesforce, How it is queued for Indexing?

    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.

  • As Salesforce doesn’t save data in traditional way. Data of all tenants are in common table, so traditional Query optimization query and technique will not work in this case, so there is no such tool available to optimize final generated SQL. We only have option to create SOQL which is optimized by custom inbuilt Force.com Query Optimizer.

    In Summer14, Salesforce released Query Plan Tool to analyze how query is performing. With help of this tool, we can get an idea how we can change our query to perform better.

  • Salesforce is using Multi-tenant architecture, means many organizations (Tenants) are using same infrastructure. Salesforce Database saves Metadata Information in hundreds of table. Run time engine then generates organization specific query to get information about their organizations and Data from common table as shown in below diagram. Below Database tables are partitioned by Organization ID and generates virtual table specific to Org.

  • No.

  • Using a dataloader update the user object’s field “DefaultGroupNotificationFrequency” with the options:

    Email on each post
    Daily digests
    Weekly digests
    Never

  • There is common missunderstanding that what is allowed in Trigger Context. Above Syntax will work on any other places like Visualforce Controller. However in Trigger, Lookup field or related list is not available implicitly, we need to query it.

Page 14 of 57