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

  • Ramcharan Theja

    Member
    July 1, 2019 at 7:41 pm

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

  • Deepak

    Member
    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();
    acc.name=name;
    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);
    }
    }

    • This reply was modified 4 years, 8 months ago by  Deepak.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos