You need to sign in to do that
Don't have an account?
Snehal Gaware 15
autofilled contact name on vf page by logged in community user's name
Hi All,
I have a vf page where i have a field Contact name on case which is a lookup to contact. I want when the user logged in as community user it should autopopulate his/her name in that contact field.
vf-page:
I have a vf page where i have a field Contact name on case which is a lookup to contact. I want when the user logged in as community user it should autopopulate his/her name in that contact field.
vf-page:
<apex:page standardController="Case" extensions="AutoPopulateExample"> <apex:form id="form"> <apex:pageBlock > <apex:pageBlockButtons location="top"> <apex:commandButton value="Save" action="{!Save}"/> <apex:commandButton value="Cancel" action="{!Cancel}"/> </apex:pageBlockButtons> <apex:actionRegion > <apex:pageBlockSection title="Basic Details" columns="2"> <apex:inputField label="Contact Name" value="{!Case.ContactId}" > <apex:actionSupport event="onchange" action="{!autoCal}" reRender="form"/> </apex:inputField> <apex:inputField label="Requestor First Name" value="{!Case.Requestor_First_Name__c}"/> <apex:inputField label="Account Name" value="{!Case.AccountId}"/> <apex:inputField label="Requestor Last Name" value="{!Case.Requestor_Last_Name__c}"/> <apex:inputField label="Status" value="{!Case.Status}"/> <apex:inputField label="Requestor Email" value="{!Case.Requester_Email__c}"/> <apex:inputField label="Subject" value="{!Case.Subject}"/> <apex:inputField label="Requestor Contact Number" value="{!Case.Requester_Contact_Number__c}"/> <apex:inputField label="Product" value="{!Case.Products__c}"/> <apex:inputField label="Business Impact" value="{!Case.Business_Impact__c}"/> <apex:inputField label="Components" value="{!Case.Componet__c}"/> <apex:inputField label="Business Urgency" value="{!Case.Business_Urgency__c}"/> <apex:inputField label="On Behalf of" value="{!Case.On_Behalf_of__c}"/> <apex:inputField label="Environment" value="{!Case.Environment__c}"/> <apex:inputField label="Description" value="{!Case.Description__c}"/> </apex:pageBlockSection> </apex:actionRegion> </apex:pageBlock> <!--<apex:commandButton value="Upload files" action="{!save}" reRender="theSection"/> --> <apex:outputPanel id="theSection" rendered="true"> <apex:pageblock > <apex:pageBlockSection title="Uploading the Attachment" collapsible="false" dir="LTR" columns="1"> <div id="upload" class="upload"> <apex:inputFile id="fileToUpload" value="{!fileBody}" filename="{!fileName}" styleClass="input-file"/> </div> </apex:pageBlockSection> </apex:pageBlock> </apex:outputPanel> </apex:form> </apex:page>
Yes, It will not autoFill because you are calling the autoCal() methond from VF Page when user changing the values,
Try this below code this will works fine.
Let me know if you have any questions, Mark this as a best answer if it solves your Problem.
Regards,
Prasath
All Answers
Try the below code
Let me know if you have any questions, Mark this as a best answer if it solves your Problem.
Regards,
Prasath
I have tried the above code. It is populating logged in user name, but fields related to it are not aupopulating now.
Before trying above code it was working fine, when i manually selecting contact name in field the related fields(Account, requester first name ,last name, phone) are autopopulating before saving the record.
Yes, It will not autoFill because you are calling the autoCal() methond from VF Page when user changing the values,
Try this below code this will works fine.
Let me know if you have any questions, Mark this as a best answer if it solves your Problem.
Regards,
Prasath