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

convert records form one sobj to another sobj
hello group,
i hav developed 2 vf pages enquiry and student, in enquiry i hav a picklist field called status(converted,pending, not converted).and also i hav some records in enquiry. so my requirement is when i click converted in status piclist,
the records associated with 'convetred' should move from 'enquiry' to 'student'.
pls send me code for this requirement
can any one help me ,
thanks for giving reply(in advance)
Hi,
I think you can handle this through trigger on 'Enquiry' object, write a trigger on this object after insert type of trigger.
Regards,
Sridhar Bonagiri
I agree with "Sridher" and you write a trigger on "Enquery" object after insert and after update type of trigger and in that trigger u can insert the "Student" object record withe the "Enquery" obj details.
I think its usefull to u
thanks for giving reply Ankush Samudrala and BSridhar............
can u both send me code for thias iam also working on it but iam not able to get it........
because iam new to salesforce.......
tahnks and regards
ravi
Just send your code we will help you
Hi,
Please post the code that you have written already.
Regards,
Sridhar Bonagiri
thanks for giving reply all of u here is my code,
in this code iam not able to connect particular piclist value to student pls change my code........
trigger insertstd on Enquiry__c (after insert) {
Set<Id> Ids= new Set<Id>();
for (Enquiry__c enquiry : Trigger.new){
Ids.add(enquiry.Id);
}
List<Student__c> stdList = new List<Student__c>([Select Id,Name From Student__c e1 where Id in :Ids]);
List<Enquiry__c> enquiryList = new List<Enquiry__c>([Select Id,Name,Status__c From Enquiry__c e where Id in :Ids]);
for(Enquiry__c temp : enquiryList ){
Student__c std = new Student__c();
temp.Name = std.Name;
insert temp;
}
}
thanks forgiving reply thanks,thanks,,.....
Hi
Follow this code
trigger insertstd on Enquiry__c (after insert) {
Set<Id> Ids= new Set<Id>();
List<String> st=new List<String>();
for (Enquiry__c enquiry : Trigger.new){
Ids.add(enquiry.Id);
st.add(enquiry.Status__c);
}
List<Enquiry__c> enquiryList = [Select Id,Name,Status__c From Enquiry__c where Id in :Ids];
List<Student__c> stdList = new List<Student__c>();
for(Enquiry__c e:enquiryList)
{
if(e.Status__c=='converted'){
Student__c s=new Student__c();
stdList.Name='st[i]';
stdList.add(s);
}
}
insert stdList;
}
Prem
hello Premanath
thanks for giving reply
but iam facing an error ( Initial term of field expression must be a concrete SObject: LIST<Student__c> at line 17 column 1) line 17=stdList.Name='st[i]';
i have tried like this even though iam facing the same error.
trigger insertstd on Enquiry__c (after insert) {
Set<Id> Ids= new Set<Id>();
List<String> st=new List<String>();
for (Enquiry__c enquiry : Trigger.new){
Ids.add(enquiry.Id);
st.add(enquiry.Status__c);
}
List<Enquiry__c> enquiryList = [Select Id,Name,Status__c From Enquiry__c where Id in :Ids];
List<Student__c> stdList = new List<Student__c>();
stdlist = [select Id,Name from Student__c];
for(Enquiry__c e:enquiryList)
{
if(e.Status__c=='converted'){
Student__c s=new Student__c();
stdList.Student_Name__c='st[i]';
stdList.add(s);
}
}
insert stdList;
}
pls help me premanath..................
thank u very much for guiding me in a r8 way...........
sorry try this changed some thing
trigger insertstd on Enquiry__c (after insert) {
Set<Id> Ids= new Set<Id>();
List<String> st=new List<String>();
for (Enquiry__c enquiry : Trigger.new){
Ids.add(enquiry.Id);
st.add(enquiry.Status__c);
}
List<Enquiry__c> enquiryList = [Select Id,Name,Status__c From Enquiry__c where Id in :Ids];
List<Student__c> stdList = new List<Student__c>();
for(Enquiry__c e:enquiryList)
{
if(e.Status__c=='converted'){
Student__c s=new Student__c();
s.Name=e.Name;
stdList.add(s);
}
}
insert stdList;
}
thanks for giving reply premanath,
sorry for disturbing u even though iam getting the error ' Field is not writeable: Student__c.Name at line 17 column 1' line 17's.Name=e.Name;'
thanks and regards
ravi varma
Your task is you need to create a record in Student object right?
so here
for(Enquiry__c e:enquiryList)
{
if(e.Status__c=='converted'){
Student__c s=new Student__c();
s.Name=e.Name; // e.name is Enquiry record and s.Name is student just i am inserting a new reocrd..
stdList.add(s);
}
}
Error is like check with your API Names of your object Student..
Check through the Name field is Text/Autonumber... if it is Text only it will work..
Check through the permisssions of that Student Object fields.. in a profile.. it should be Read/Write permissions to the Name field..
Prem