• ch ranjeeth
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 7
    Replies
<apex:page controller="Recordinsertion" action="{!method}">

</apex:page>

Controller:
public with sharing class Recordinsertion {

    public PageReference method()
     {
         list<account> acclist=new list<account>();
         for(integer i=50;i<51;i++)
         {
       
         account a=new account();
         a.name='acc'+i;
         acclist.add(a);
       }
     insert acclist;
      return null;
   }
}
global with sharing class recordcreation
{
  global void method1()
  {
 
    oldmapnewmap__c o=new oldmapnewmap__c();
    o.name='ranjith';
    insert o;
  }
}
Trigger:

trigger recordcreation on Account (before insert)
{
  recordcreation rc=new recordcreation();
   rc.method1();
}

The user dont have permissions on oldmapnewmap__c object but its inserting records... OWD is Private... Need help on this?
<apex:page controller="Recordinsertion" action="{!method}">
 
</apex:page>

Controller:
public with sharing class Recordinsertion {

    public PageReference method()
     {
         list<account> acclist=new list<account>();
         for(integer i=50;i<80;i++)
         {
        
         account a=new account();
         a.name='acc'+i;
         acclist.add(a);
       }
     insert acclist;
      return null;
   }
}
trigger contactcategory on Contact (before insert,before update)
{
  set<id> set1=new set<id>();
  map<id,string> map1=new map<id,id>();
   for(Contact c:trigger.new)
   {
    set1.add(c.ownerid);
   }
  
   list<user> userlist=[select id,profile.name from user where id in:set1];
   for(user u:userlist)
   {
   map1.put(u.id,u.profile.name);
   }
   for(contact c:trigger.new)
   {
        string s=map1.get(c.ownerid);
         if(s=='System Administrator')
         {
           c.Non_System_Admin_Case__c='yes';
         }
         else
         {
         c.Non_System_Admin_Case__c='No';
         }
           
   
   }
  
}
<apex:page controller="deleteclass">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!records}" var="r">

<apex:column headerValue="action">
<apex:commandLink value="Delete" action="{!Dodelete}">
<apex:param name="rid" value="{r.id}" />
</apex:commandLink>
</apex:column>

<apex:column headerValue="Name">{!r.name} </apex:column>

</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Custom controller: 
public with sharing class deleteclass {

     public string rid{get;set;}
     account acc1=new account();
    public PageReference Dodelete() {
        acc1=[select id,name from account where id=:rid];
     delete acc1;
     pagereference ref=new pagereference('/001?fcf=00B900000085iko');
        ref.setredirect(true);
        return ref;
    }

       list<account> acclist=new list<account>();
    public list<account> getRecords()
    {
       acclist=[select id,name from account];
      return acclist;
    }

}

i unable to crate a reord .i got an error like this  Initial term of field expression must be a concrete SObject: LIST<Id> at line 13 column 19

trigger createcontacts on Account (after insert) {
   
     list<contact> con=new list<contact>();
     
    list<id> l1=new list<id>();
   for(account acc:trigger.new)
  {
   l1.add(acc.id);  
 }
   if(l1.size()>0 && l1!=null)
    {
     contact c1=new contact();
     c1.accountid=l1.id;
     c1.firstname=l1.name;
     con.add(c1);
     }
     insert con;
     }
<apex:page controller="Recordinsertion" action="{!method}">
 
</apex:page>

Controller:
public with sharing class Recordinsertion {

    public PageReference method()
     {
         list<account> acclist=new list<account>();
         for(integer i=50;i<80;i++)
         {
        
         account a=new account();
         a.name='acc'+i;
         acclist.add(a);
       }
     insert acclist;
      return null;
   }
}
trigger contactcategory on Contact (before insert,before update)
{
  set<id> set1=new set<id>();
  map<id,string> map1=new map<id,id>();
   for(Contact c:trigger.new)
   {
    set1.add(c.ownerid);
   }
  
   list<user> userlist=[select id,profile.name from user where id in:set1];
   for(user u:userlist)
   {
   map1.put(u.id,u.profile.name);
   }
   for(contact c:trigger.new)
   {
        string s=map1.get(c.ownerid);
         if(s=='System Administrator')
         {
           c.Non_System_Admin_Case__c='yes';
         }
         else
         {
         c.Non_System_Admin_Case__c='No';
         }
           
   
   }
  
}