You need to sign in to do that
Don't have an account?
DeepV
Insert/Save CustomObject and account fields using visualforce page?
Hi all,
For external users, we will be sending a link in the email to fill survey and when they click submit.
1) A record should be created/saved into salesforce customOBject(Survey__c)
2)This Survey object has a lookup field which is Account, this should also be saved.
How do I achieve this? Please can you post the code.
For external users, we will be sending a link in the email to fill survey and when they click submit.
1) A record should be created/saved into salesforce customOBject(Survey__c)
2)This Survey object has a lookup field which is Account, this should also be saved.
How do I achieve this? Please can you post the code.
Passing the id in the url as ..apex/myAudit?id=<Account record id pass here . >
public PageReference save() {
//Add your custom logic to update specific fields here
Survey__c aq = new Survey__c();
aq.Name = txtSurvey;
aq.account__c =apexpages.currentpage().getparameters().get('id');
insert aq;
return null;
}
All Answers
When you are creating a Survey Page, pass the account into the URL parameters from the page.
You can get the account id from the URL parameters and assign it while you are saving it.
Thanks ,
Raj
Below is my apex class:
public class myAudit {
public String account { get; set; }
public String txtAuditQ { get; set; }
public PageReference save() {
//Add your custom logic to update specific fields here
Survey__c aq = new Survey__c();
aq.Name = txtSurvey;
insert aq;
return null;
}
}
}
My VisualForce page:
<apex:page controller="myAudit">
<apex:form >
<apex:pageblock >
<apex:inputField value="{!account.name}"/>
<apex:inputText id="Survey" value="{!txtSurvey}"/>
<apex:commandButton action="{!save}" value="save"/>
</apex:pageblock>
</apex:form>
</apex:page>
public String account { get; set; }
public String txtAuditQ { get; set; }
public PageReference save() {
//Add your custom logic to update specific fields here
Survey__c aq = new Survey__c();
aq.Name = txtSurvey;
aq.account__c =account ;
insert aq;
return null;
}
}
}
<apex:page controller="myAudit">
<apex:form >
<apex:pageblock >
<apex:inputText value="{!account}"/>
<apex:inputText id="Survey" value="{!txtSurvey}"/>
<apex:commandButton action="{!save}" value="save"/>
</apex:pageblock>
</apex:form>
</apex:page>
public class myAudit {
public String account { get; set; }
public String txtSurvey{ get; set; }
public PageReference save() {
//Add your custom logic to update specific fields here
Survey__c aq = new Survey__c();
aq.Name = txtSurvey;
aq.account__c =account ;
insert aq;
return null;
}
}
}
<apex:page controller="myAudit">
<apex:form >
<apex:pageblock >
<apex:inputText value="{!account}"/>
<apex:inputText id="Survey" value="{!txtSurvey}"/>
<apex:commandButton action="{!save}" value="save"/>
</apex:pageblock>
</apex:form>
</apex:page>
System.StringException: Invalid id: new account survey
Error is in expression '{!save}' in component <apex:commandButton> in page myaudit: Class.myAudit.save: line 12, column 1
Passing the id in the url as ..apex/myAudit?id=06636000004OblF
Passing the id in the url as ..apex/myAudit?id=<Account record id pass here . >
public PageReference save() {
//Add your custom logic to update specific fields here
Survey__c aq = new Survey__c();
aq.Name = txtSurvey;
aq.account__c =apexpages.currentpage().getparameters().get('id');
insert aq;
return null;
}
Please help!
Thanks for your help RajaMohan, but I'm unable to see the account name as highlighted above