
Hi Abhishek,
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.Thanks,Nagendra
2 respostas