Activity Forums Salesforce® Discussions What is the better approach to insert records in Salesforce everytime when a class is executed?

  • Ramcharan Theja

    July 1, 2019 at 7:41 pm

    Note: Visualforce is not involved here. class gets executed through rest call.

  • Deepak

    August 6, 2019 at 12:07 pm

    It is very simple you have to write "global with sharing" before your class, the class which you want to call.

    for example

    global with sharing class Addrec{
    public static void add(string name){
    account acc=new account();;
    insert acc;

    now calling will be like

    global with sharing class callfun {
    public List<Account> getres() {
    Addrec x = new Addrec();
    return x.add(string name);

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos