You need to sign in to do that
Don't have an account?
DeepV
update a field based on the contactid from the url
Hi,
I'm passing accountid as id and contactid in the url.
When the users click save, I need to update a datefield__c to today(without time) on contact object.
Here is my vf page -
<apex:page controller="myAudit">
<apex:form >
<apex:pageblock >
<apex:pageblockSection columns="1">
<p><apex:inputText value="{!account}" label="Account"/></p>
<apex:inputText id="Survey" value="{!txtSurvey}" label="SurveyName"/>
<apex:commandButton action="{!save}" value="save"/>
</apex:pageblockSection>
</apex:pageblock>
</apex:form>
</apex:page>
My apex class:
public class myAudit {
public myAudit() {
account = [SELECT Id, Name FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')].Name;
}
public String account { get; set; }
public String txtSurvey { get; set; }
public PageReference save() {
Audit_Questionnaire__c aq = new Audit_Questionnaire__c();
aq.Name = txtSurvey;
aq.account__c = apexpages.currentpage().getparameters().get('id');
insert aq;
return null;
}
}
I'm passing accountid as id and contactid in the url.
When the users click save, I need to update a datefield__c to today(without time) on contact object.
Here is my vf page -
<apex:page controller="myAudit">
<apex:form >
<apex:pageblock >
<apex:pageblockSection columns="1">
<p><apex:inputText value="{!account}" label="Account"/></p>
<apex:inputText id="Survey" value="{!txtSurvey}" label="SurveyName"/>
<apex:commandButton action="{!save}" value="save"/>
</apex:pageblockSection>
</apex:pageblock>
</apex:form>
</apex:page>
My apex class:
public class myAudit {
public myAudit() {
account = [SELECT Id, Name FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')].Name;
}
public String account { get; set; }
public String txtSurvey { get; set; }
public PageReference save() {
Audit_Questionnaire__c aq = new Audit_Questionnaire__c();
aq.Name = txtSurvey;
aq.account__c = apexpages.currentpage().getparameters().get('id');
insert aq;
return null;
}
}
Add the below ling in Save() method
Please do let me know if this helps.
Thanks,
Alex
All Answers
Add the below ling in Save() method
Please do let me know if this helps.
Thanks,
Alex
note: It is a date field not a datetime field
Good to know you got answer DeepV. :) I made a mistake in parameters get(used id instead of contactId). Glad you figured that out :)