Giter Club home page Giter Club logo

Comments (4)

nmitrakis avatar nmitrakis commented on August 17, 2024

Hi @Pooja-sfdc, there is no need to modify the property.

The best practice for creating records with Forceea is totally different from what is included in your attached code.
Generally we create records by Templates (Forceea.Template class). There are plenty of examples in the Success Guide (see Data factory section).

If you insist on creating data without Forceea.Template, you should use the following sample:

FObject obj = new FObject(Account.SObjectType, 10) \\ 10 is the number of records
    .setDefinition(.Account.Name, '......'.)

or

FObject obj = new FObject(Account.SObjectType)
    .setNumberOfRecords(10)
    .setDefinition(.....)
``

Again, please see the Success Guide for examples. For you reference I attach a sample Data Factory class:

public with sharing class DataFactory {

public final static String ACCOUNTS = 'Accounts';
public final static String MAJOR_ACCOUNTS = 'MajorAccounts';
public final static String OPPORTUNITIES = 'Opportunities';
public final static String B2B_OPPORTUNITIES = 'B2BOpportunities';

public final static Integer DEFAULT_NUM_ACCOUNTS = 10;
public final static Integer DEFAULT_NUM_OPPORTUNITIES = 40;

public static Forceea.Template templateAccounts() {
    return new Forceea.Template()
        .add(ACCOUNTS, new FObject(Account.SObjectType)
            .setNumberOfRecords(DEFAULT_NUM_ACCOUNTS)
            .setDefinition(Account.Industry, 'random type(picklist) except(Electronics,Energy)')
            .setDefinition(Account.ShippingStreet, 'random type(street) group(shipping)')
            .setDefinition(Account.ShippingPostalCode, 'random type(postalCode) group(shipping)')
            .setDefinition(Account.ShippingCity, 'random type(city) group(shipping)')
            .setDefinition(Account.ShippingState, 'random type(state) group(shipping)')
            .setDefinition(Account.ShippingCountry, 'random type(country) group(shipping)')
        );
}

public static Forceea.Template templateMajorAccounts() {
    return new Forceea.Template()
        .add(MAJOR_ACCOUNTS, templateAccounts().getFObject(ACCOUNTS)
            .setVariable('recordType', 'MajorAccount')
            .setDefinition(Account.RecordTypeId, 'static value({@recordType})')
            .setDefinition(Account.Name, 'static value(Account-)')
            .setDefinition(Account.Name, 'serial type(number) from(1) step(1) scale(0)')
            .setDefinition(Account.AnnualRevenue, 'random type(number) from(1000000) to(100000000) scale(2)')
        );
}

public static Forceea.Template templateOpportunities() {
    return new Forceea.Template()
        .add(OPPORTUNITIES, new FObject(Opportunity.SObjectType)
            .setNumberOfRecords(DEFAULT_NUM_OPPORTUNITIES)
            .setVariable('today', Date.today())
            .setDefinition('$days', 'random type(number) from(-60) to(60) scale(0)')
            .setDefinition(Opportunity.CloseDate, 'static value({@today})')
            .setDefinition(Opportunity.CloseDate, 'function-add field($days)')
            .setDefinition(Opportunity.StageName, 'random type(list) value(Prospecting,Qualification, Needs Analysis)')
            .setDefinition(Opportunity.Amount, 'random type(number) from(1000) to(10000) scale(2)')
        );
}

public static Forceea.Template templateB2bOpportunitiesWithRelated() {
    return new Forceea.Template()
        .add(templateMajorAccounts())
        .add(B2B_OPPORTUNITIES, templateOpportunities().getFObject(OPPORTUNITIES)
            .setVariable('recordType', 'B2BOpportunity')
            .setDefinition(Opportunity.RecordTypeId, 'static value({@recordType})')
            .setDefinition(Opportunity.Name, 'static value(Opportunity-)')
            .setDefinition(Opportunity.Name, 'serial type(number) from(1) step(1) scale(0)')
            .setDefinition(Opportunity.AccountId, 'serial lookup(Account) mode(cyclical) source(forceea)')
        );
}

public static void insertAsync() {
    Forceea.Template template = DataFactory.templateB2bOpportunitiesWithRelated();
    new FObjectAsync(template)
        .setNumberOfIterations(1000)
        .setNumberOfJobs(20)
        .insertRecords();
}

public static void deleteAsync() {
    Forceea.Template template = DataFactory.templateB2bOpportunitiesWithRelated();
    new FObjectAsync(template)
        .deleteRecords();
}

}

from forceea-data-factory.

Pooja-sfdc avatar Pooja-sfdc commented on August 17, 2024

Hi @nmitrakis ,

Thanks for above clarification!

I tried accessing the Forceea user guide, which I was trying to access through below link:
https://nmitrakis.com/Forceea131-user-guide

But I'm unable to access the same.

Could you please send me the link to access the guide which i can access easily?

Thanks & Regards,
Pooja Agrawal

from forceea-data-factory.

nmitrakis avatar nmitrakis commented on August 17, 2024

@Pooja-sfdc you've been using a very very old version. Now we are on v2.6!
You can find the latest Success Guide at https://rebrand.ly/cgh14.

from forceea-data-factory.

Pooja-sfdc avatar Pooja-sfdc commented on August 17, 2024

Thanks @nmitrakis ! I will close the issue.

Kind Regards,
Pooja

from forceea-data-factory.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.