You need a controller or extension do this (controller is shown here):
public with sharing class controller {
public ObjectA__c objectA { get; set; }
public Task task { get; set; }
public controller() {
objectA = ...; // do query from page parameter, etc);
task = new schema.task();
}
public pagereference save() {
try {
update objecta;
task.whatid = objecta.id;
insert task;
return new apexpages.standardcontroller(objecta).view();
} catch(exception e) {
apexpages.addmessages(e);
return null;
}
}
}
Refer to your ObjectA fields as {!objecta.provider__c}, and task fields as {!task.category__c}. You can populate other data as well, change the logic around, etc. If you're using the standard controller, you can refer to {!ObjectA__c.Provider__c} instead; you'll want to save the standard controller so you can save the data correctly (calling controller.save()).
Hope this helps.
Kindly mark this as solved if the reply was helpful so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
You need a controller or extension do this (controller is shown here):
public with sharing class controller {
public ObjectA__c objectA { get; set; }
public Task task { get; set; }
public controller() {
objectA = ...; // do query from page parameter, etc);
task = new schema.task();
}
public pagereference save() {
try {
update objecta;
task.whatid = objecta.id;
insert task;
return new apexpages.standardcontroller(objecta).view();
} catch(exception e) {
apexpages.addmessages(e);
return null;
}
}
}
Refer to your ObjectA fields as {!objecta.provider__c}, and task fields as {!task.category__c}. You can populate other data as well, change the logic around, etc. If you're using the standard controller, you can refer to {!ObjectA__c.Provider__c} instead; you'll want to save the standard controller so you can save the data correctly (calling controller.save()).
Hope this helps.
Kindly mark this as solved if the reply was helpful so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
hello, can u give example with vf page and controller. and i have customer__c and agent__c object so i need to create two tabs and in that tabs i need to enter their respective details and save the details.
Hi Abhishek,
Refer to your ObjectA fields as {!objecta.provider__c}, and task fields as {!task.category__c}. You can populate other data as well, change the logic around, etc. If you're using the standard controller, you can refer to {!ObjectA__c.Provider__c} instead; you'll want to save the standard controller so you can save the data correctly (calling controller.save()).You need a controller or extension do this (controller is shown here):
Hope this helps.
Kindly mark this as solved if the reply was helpful so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Thanks,
Nagendra
All Answers
Hi Abhishek,
Refer to your ObjectA fields as {!objecta.provider__c}, and task fields as {!task.category__c}. You can populate other data as well, change the logic around, etc. If you're using the standard controller, you can refer to {!ObjectA__c.Provider__c} instead; you'll want to save the standard controller so you can save the data correctly (calling controller.save()).You need a controller or extension do this (controller is shown here):
Hope this helps.
Kindly mark this as solved if the reply was helpful so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Thanks,
Nagendra
can u give example with vf page and controller.
and i have customer__c and agent__c object so i need to create two tabs and in that tabs i need to enter their respective details and save the details.