• nilangi
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies

Guys here is my vf page code:

<apex:page controller="addit" >
<apex:pageBlock title="Registration">
<apex:form >
<h1> Student Registration </h1><hr></hr>
<apex:pageBlockTable value="{!info}" var="new" id="stdid" width="100%" >
<apex:column >
       <apex:facet name="header"><b>Student Id</b></apex:facet>
{!new.Name}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Name</b></apex:facet>
{!new.name__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Date of Birth</b></apex:facet>
{!new.dob__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>College Name</b></apex:facet>
{!new.college_name__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Branch</b></apex:facet>
{!new.branch__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Year</b></apex:facet>
{!new.year__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Semester</b></apex:facet>
{!new.semester__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Roll No</b></apex:facet>
{!new.clgno__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Previous examid</b></apex:facet>
{!new.preexamid__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>10th percent</b></apex:facet>
{!new.ssc__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>12th percent</b></apex:facet>
{!new.hsc__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Emailid</b></apex:facet>
{!new.emailid__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Mobile</b></apex:facet>
{!new.phone__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Address</b></apex:facet>
{!new.address__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Accept/Reject</b></apex:facet>
       <a href="javascript&colon;if (window.confirm('Are you sure?')) DeleteAccount('{!new.Name}');" style="font-weight:bold">Del</a>

</apex:column>


</apex:pageBlockTable>
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel"/>
<apex:actionFunction action="{!DeleteAccount}" name="DeleteAccount" reRender="form" >
   <apex:param name="Name" value="" assignTo="{!SelectedAccountId}"/>
</apex:actionFunction>
</apex:form>
</apex:pageBlock>
</apex:page>

 

And here is my controller:

public class addit {
 public List<student__c> info { get; set; }
 
   //used to get a hold of the account record selected for deletion
   public string SelectedAccountId { get; set; }
   public addit(){
   LoadData();
   }
    public void DeleteAccount() {
         if (SelectedAccountId == null) {
      
         return;
      }
     
      // find the account record within the collection
      student__c tobeDeleted = null;
      for(student__c a : info)
       if (a.Name == SelectedAccountId) {
          tobeDeleted = a;
          break;
       }
      
      //if account record found delete it
      if (tobeDeleted != null) {
       Delete tobeDeleted;
      }
     
      //refresh the data
      LoadData();
       
    }
  private void LoadData() {
       info = [SELECT Name,name__c,dob__c,college_name__c,branch__c,year__c,semester__c,clgno__c,preexamid__c,ssc__c,hsc__c,emailid__c,phone__c,address__c FROM student__c];
   }

}

 

 

 

 

And i m getting this error since a long time

Error: Unable to complete the requested data change

Dont know wat is going wrong.Pls help....

 

<apex:page controller="resulttab" >
<apex:form >
<apex:pageBlock >
 <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!next}" rerender="error"/>
            </apex:pageBlockButtons>
 <apex:inputField value="{!res.examid__c}"/>
 </apex:pageBlock>
 </apex:form>
</apex:page>

 

 

 

public class resulttab
{
   public result__c res {get; set;}
   public String a {get; set;}
   
   public String save()
   {
       a = res.examid__c;
       return a;
       next();
   }
   
   public List<result__c> next()
   {
   return [SELECT name__c,college_name__c,branch__c,year__c,semester__c,clgno__c,total__c,status__c,percent__c,marks__c,examid__c FROM result__c WHERE examid__c = a ];
   }
}

 

 

error:

 Error Message: System.NullPointerException: Attempt to de-referen
Ok, I'm getting the following error when using this Apex Trigger.

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger copyMSGIdCases caused an unexpected exception, contact your administrator: copyMSGIdCases: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.copyMSGIdCases: line 21, column 56

Here is the code I am using:

Code:
// This trigger assigns a value to the MSG_ID__c custom field on cases before the new case
// is saved to the database.

trigger copyMSGIdCases on Case (before insert, before update) {
 // Determine the account
 Set<ID> accIds = new Set<ID>();
 for (Case cas : Trigger.new)
  accIds.add(cas.accountid);
 // Query the Account to get the MSG_ID__c entry
 Map<Id, Account> entries = new Map<Id, Account>(
  [select MSG_ID__c, PAS_ID__c from Account
  where id in :accIds]);
 
 // Now set the Account_MSG_ID__c on the Contact to be the same as MSG_ID__c on the
 // related account
 // Now set the PAS_Account_ID__c on the Case to be the same as PAS_ID__c on the
 // related account
 for (Case cas : Trigger.new)
 cas.MSG_ID__c = entries.get(cas.AccountId).MSG_ID__c;
 for (Case cas : Trigger.new)
 cas.PAS_Account_ID__c = entries.get(cas.AccountId).PAS_ID__c;

}
Now, I'm sure this can be done in a different way, but I went this route because I wanted to learn more about Apex Triggers.

So here is the funny thing, I only get this error if I am trying to create a new case as an regular user in SFDC. If I am logged in as the System Administrator, it all executes fine with no errors and does what I expect it to do.

Let me clarify, I am logged in as a System Admin User and then from there, go to Manage Users->Users, and choose the user I want to login as and then press the login button.

 Has anyone run into this before?

Any suggestions?
 

Message Edited by craskulinecz on 10-16-2007 10:36 PM

Message Edited by craskulinecz on 10-16-2007 10:38 PM