You need to sign in to do that
Don't have an account?

How to redirect to master page?
hi friends,
i have created two objects 1)Job 2)Job Task
and there is a master detail relationship between Job and JobTask...
i have created visualforc page to create new Job and Jobtask as well...
i am getting problem while deleting Job Task from its Detail page... Because after deleting it goes to standard list of jobtask...
i want that after deleting any jobtask it should go back to respected Job... i have written apex for this but not able to fetch id of master record...
could any one provide me code to override delete of job task
here is my code but not able to retrieve id ob JOB
public class DeleteJobTask
{
private final JobTask__c objJT;
public DeleteJobTask(ApexPages.StandardController controller)
{
this.objJT=(Holiday__c)controller.getrecord();
}
public PageReference checkDelete()
{
try
{
Database.delete(objJT);
}
catch(System.DMLException e)
{
return null;
}
PageReference p = new Pagereference('/apex/JobDetailPage?id=);
p.setRedirect(true);
return p;
}
}
hmm, field is not been added in the query in this line : Class.DeleteSpecItem.checkDelete: line 18,.
so either add the field in that query or I'm not sure here but give below code a try:
All Answers
This can be done, Before deleting a JobTask, store the Id of its Job and after deleting, redirect to that id.
Like:
Hope it helps.
i am getting error like
Compile Error: Type cannot be constructed
try this:
now when i am going to delete getting this error
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Holiday__c.Job__c
Class.DeleteSpecItem.checkDelete: line 18, column 14 External entry point
hmm, field is not been added in the query in this line : Class.DeleteSpecItem.checkDelete: line 18,.
so either add the field in that query or I'm not sure here but give below code a try:
Thank you Rahul, its working now... You are great dude :)